babylon.module.d.ts 6.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757
  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. private _currentSrc;
  31492. /**
  31493. * Creates a video texture.
  31494. * If you want to display a video in your scene, this is the special texture for that.
  31495. * This special texture works similar to other textures, with the exception of a few parameters.
  31496. * @see https://doc.babylonjs.com/how_to/video_texture
  31497. * @param name optional name, will detect from video source, if not defined
  31498. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31499. * @param scene is obviously the current scene.
  31500. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31501. * @param invertY is false by default but can be used to invert video on Y axis
  31502. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31503. * @param settings allows finer control over video usage
  31504. */
  31505. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31506. private _getName;
  31507. private _getVideo;
  31508. private _createInternalTexture;
  31509. private reset;
  31510. /**
  31511. * @hidden Internal method to initiate `update`.
  31512. */
  31513. _rebuild(): void;
  31514. /**
  31515. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31516. */
  31517. update(): void;
  31518. /**
  31519. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31520. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31521. */
  31522. updateTexture(isVisible: boolean): void;
  31523. protected _updateInternalTexture: () => void;
  31524. /**
  31525. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31526. * @param url New url.
  31527. */
  31528. updateURL(url: string): void;
  31529. /**
  31530. * Clones the texture.
  31531. * @returns the cloned texture
  31532. */
  31533. clone(): VideoTexture;
  31534. /**
  31535. * Dispose the texture and release its associated resources.
  31536. */
  31537. dispose(): void;
  31538. /**
  31539. * Creates a video texture straight from a stream.
  31540. * @param scene Define the scene the texture should be created in
  31541. * @param stream Define the stream the texture should be created from
  31542. * @returns The created video texture as a promise
  31543. */
  31544. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31545. /**
  31546. * Creates a video texture straight from your WebCam video feed.
  31547. * @param scene Define the scene the texture should be created in
  31548. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31549. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31550. * @returns The created video texture as a promise
  31551. */
  31552. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31553. minWidth: number;
  31554. maxWidth: number;
  31555. minHeight: number;
  31556. maxHeight: number;
  31557. deviceId: string;
  31558. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31559. /**
  31560. * Creates a video texture straight from your WebCam video feed.
  31561. * @param scene Define the scene the texture should be created in
  31562. * @param onReady Define a callback to triggered once the texture will be ready
  31563. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31564. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31565. */
  31566. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31567. minWidth: number;
  31568. maxWidth: number;
  31569. minHeight: number;
  31570. maxHeight: number;
  31571. deviceId: string;
  31572. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31573. }
  31574. }
  31575. declare module "babylonjs/Engines/thinEngine" {
  31576. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31577. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31578. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31579. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31580. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31581. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31582. import { Observable } from "babylonjs/Misc/observable";
  31583. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31584. import { StencilState } from "babylonjs/States/stencilState";
  31585. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31586. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31587. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31588. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31589. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31590. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31591. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31592. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31593. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31594. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31595. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31596. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31597. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31598. import { WebRequest } from "babylonjs/Misc/webRequest";
  31599. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31600. /**
  31601. * Defines the interface used by objects working like Scene
  31602. * @hidden
  31603. */
  31604. interface ISceneLike {
  31605. _addPendingData(data: any): void;
  31606. _removePendingData(data: any): void;
  31607. offlineProvider: IOfflineProvider;
  31608. }
  31609. /** Interface defining initialization parameters for Engine class */
  31610. export interface EngineOptions extends WebGLContextAttributes {
  31611. /**
  31612. * Defines if the engine should no exceed a specified device ratio
  31613. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31614. */
  31615. limitDeviceRatio?: number;
  31616. /**
  31617. * Defines if webvr should be enabled automatically
  31618. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31619. */
  31620. autoEnableWebVR?: boolean;
  31621. /**
  31622. * Defines if webgl2 should be turned off even if supported
  31623. * @see http://doc.babylonjs.com/features/webgl2
  31624. */
  31625. disableWebGL2Support?: boolean;
  31626. /**
  31627. * Defines if webaudio should be initialized as well
  31628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31629. */
  31630. audioEngine?: boolean;
  31631. /**
  31632. * Defines if animations should run using a deterministic lock step
  31633. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31634. */
  31635. deterministicLockstep?: boolean;
  31636. /** Defines the maximum steps to use with deterministic lock step mode */
  31637. lockstepMaxSteps?: number;
  31638. /** Defines the seconds between each deterministic lock step */
  31639. timeStep?: number;
  31640. /**
  31641. * Defines that engine should ignore context lost events
  31642. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31643. */
  31644. doNotHandleContextLost?: boolean;
  31645. /**
  31646. * Defines that engine should ignore modifying touch action attribute and style
  31647. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31648. */
  31649. doNotHandleTouchAction?: boolean;
  31650. /**
  31651. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31652. */
  31653. useHighPrecisionFloats?: boolean;
  31654. }
  31655. /**
  31656. * The base engine class (root of all engines)
  31657. */
  31658. export class ThinEngine {
  31659. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31660. static ExceptionList: ({
  31661. key: string;
  31662. capture: string;
  31663. captureConstraint: number;
  31664. targets: string[];
  31665. } | {
  31666. key: string;
  31667. capture: null;
  31668. captureConstraint: null;
  31669. targets: string[];
  31670. })[];
  31671. /** @hidden */
  31672. static _TextureLoaders: IInternalTextureLoader[];
  31673. /**
  31674. * Returns the current npm package of the sdk
  31675. */
  31676. static get NpmPackage(): string;
  31677. /**
  31678. * Returns the current version of the framework
  31679. */
  31680. static get Version(): string;
  31681. /**
  31682. * Returns a string describing the current engine
  31683. */
  31684. get description(): string;
  31685. /**
  31686. * Gets or sets the epsilon value used by collision engine
  31687. */
  31688. static CollisionsEpsilon: number;
  31689. /**
  31690. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31691. */
  31692. static get ShadersRepository(): string;
  31693. static set ShadersRepository(value: string);
  31694. /**
  31695. * Gets or sets the textures that the engine should not attempt to load as compressed
  31696. */
  31697. protected _excludedCompressedTextures: string[];
  31698. /**
  31699. * Filters the compressed texture formats to only include
  31700. * files that are not included in the skippable list
  31701. *
  31702. * @param url the current extension
  31703. * @param textureFormatInUse the current compressed texture format
  31704. * @returns "format" string
  31705. */
  31706. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31707. /** @hidden */
  31708. _shaderProcessor: IShaderProcessor;
  31709. /**
  31710. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31711. */
  31712. forcePOTTextures: boolean;
  31713. /**
  31714. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31715. */
  31716. isFullscreen: boolean;
  31717. /**
  31718. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31719. */
  31720. cullBackFaces: boolean;
  31721. /**
  31722. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31723. */
  31724. renderEvenInBackground: boolean;
  31725. /**
  31726. * Gets or sets a boolean indicating that cache can be kept between frames
  31727. */
  31728. preventCacheWipeBetweenFrames: boolean;
  31729. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31730. validateShaderPrograms: boolean;
  31731. /**
  31732. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31733. * This can provide greater z depth for distant objects.
  31734. */
  31735. useReverseDepthBuffer: boolean;
  31736. /**
  31737. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31738. */
  31739. disableUniformBuffers: boolean;
  31740. /** @hidden */
  31741. _uniformBuffers: UniformBuffer[];
  31742. /**
  31743. * Gets a boolean indicating that the engine supports uniform buffers
  31744. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31745. */
  31746. get supportsUniformBuffers(): boolean;
  31747. /** @hidden */
  31748. _gl: WebGLRenderingContext;
  31749. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31750. protected _windowIsBackground: boolean;
  31751. protected _webGLVersion: number;
  31752. protected _creationOptions: EngineOptions;
  31753. protected _highPrecisionShadersAllowed: boolean;
  31754. /** @hidden */
  31755. get _shouldUseHighPrecisionShader(): boolean;
  31756. /**
  31757. * Gets a boolean indicating that only power of 2 textures are supported
  31758. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31759. */
  31760. get needPOTTextures(): boolean;
  31761. /** @hidden */
  31762. _badOS: boolean;
  31763. /** @hidden */
  31764. _badDesktopOS: boolean;
  31765. private _hardwareScalingLevel;
  31766. /** @hidden */
  31767. _caps: EngineCapabilities;
  31768. private _isStencilEnable;
  31769. private _glVersion;
  31770. private _glRenderer;
  31771. private _glVendor;
  31772. /** @hidden */
  31773. _videoTextureSupported: boolean;
  31774. protected _renderingQueueLaunched: boolean;
  31775. protected _activeRenderLoops: (() => void)[];
  31776. /**
  31777. * Observable signaled when a context lost event is raised
  31778. */
  31779. onContextLostObservable: Observable<ThinEngine>;
  31780. /**
  31781. * Observable signaled when a context restored event is raised
  31782. */
  31783. onContextRestoredObservable: Observable<ThinEngine>;
  31784. private _onContextLost;
  31785. private _onContextRestored;
  31786. protected _contextWasLost: boolean;
  31787. /** @hidden */
  31788. _doNotHandleContextLost: boolean;
  31789. /**
  31790. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31791. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31792. */
  31793. get doNotHandleContextLost(): boolean;
  31794. set doNotHandleContextLost(value: boolean);
  31795. /**
  31796. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31797. */
  31798. disableVertexArrayObjects: boolean;
  31799. /** @hidden */
  31800. protected _colorWrite: boolean;
  31801. /** @hidden */
  31802. protected _colorWriteChanged: boolean;
  31803. /** @hidden */
  31804. protected _depthCullingState: DepthCullingState;
  31805. /** @hidden */
  31806. protected _stencilState: StencilState;
  31807. /** @hidden */
  31808. _alphaState: AlphaState;
  31809. /** @hidden */
  31810. _alphaMode: number;
  31811. /** @hidden */
  31812. _alphaEquation: number;
  31813. /** @hidden */
  31814. _internalTexturesCache: InternalTexture[];
  31815. /** @hidden */
  31816. protected _activeChannel: number;
  31817. private _currentTextureChannel;
  31818. /** @hidden */
  31819. protected _boundTexturesCache: {
  31820. [key: string]: Nullable<InternalTexture>;
  31821. };
  31822. /** @hidden */
  31823. protected _currentEffect: Nullable<Effect>;
  31824. /** @hidden */
  31825. protected _currentProgram: Nullable<WebGLProgram>;
  31826. private _compiledEffects;
  31827. private _vertexAttribArraysEnabled;
  31828. /** @hidden */
  31829. protected _cachedViewport: Nullable<IViewportLike>;
  31830. private _cachedVertexArrayObject;
  31831. /** @hidden */
  31832. protected _cachedVertexBuffers: any;
  31833. /** @hidden */
  31834. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31835. /** @hidden */
  31836. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31837. /** @hidden */
  31838. _currentRenderTarget: Nullable<InternalTexture>;
  31839. private _uintIndicesCurrentlySet;
  31840. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31841. /** @hidden */
  31842. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31843. private _currentBufferPointers;
  31844. private _currentInstanceLocations;
  31845. private _currentInstanceBuffers;
  31846. private _textureUnits;
  31847. /** @hidden */
  31848. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31849. /** @hidden */
  31850. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31851. /** @hidden */
  31852. _boundRenderFunction: any;
  31853. private _vaoRecordInProgress;
  31854. private _mustWipeVertexAttributes;
  31855. private _emptyTexture;
  31856. private _emptyCubeTexture;
  31857. private _emptyTexture3D;
  31858. private _emptyTexture2DArray;
  31859. /** @hidden */
  31860. _frameHandler: number;
  31861. private _nextFreeTextureSlots;
  31862. private _maxSimultaneousTextures;
  31863. private _activeRequests;
  31864. protected _texturesSupported: string[];
  31865. /** @hidden */
  31866. _textureFormatInUse: Nullable<string>;
  31867. protected get _supportsHardwareTextureRescaling(): boolean;
  31868. /**
  31869. * Gets the list of texture formats supported
  31870. */
  31871. get texturesSupported(): Array<string>;
  31872. /**
  31873. * Gets the list of texture formats in use
  31874. */
  31875. get textureFormatInUse(): Nullable<string>;
  31876. /**
  31877. * Gets the current viewport
  31878. */
  31879. get currentViewport(): Nullable<IViewportLike>;
  31880. /**
  31881. * Gets the default empty texture
  31882. */
  31883. get emptyTexture(): InternalTexture;
  31884. /**
  31885. * Gets the default empty 3D texture
  31886. */
  31887. get emptyTexture3D(): InternalTexture;
  31888. /**
  31889. * Gets the default empty 2D array texture
  31890. */
  31891. get emptyTexture2DArray(): InternalTexture;
  31892. /**
  31893. * Gets the default empty cube texture
  31894. */
  31895. get emptyCubeTexture(): InternalTexture;
  31896. /**
  31897. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31898. */
  31899. readonly premultipliedAlpha: boolean;
  31900. /**
  31901. * Observable event triggered before each texture is initialized
  31902. */
  31903. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31904. /**
  31905. * Creates a new engine
  31906. * @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
  31907. * @param antialias defines enable antialiasing (default: false)
  31908. * @param options defines further options to be sent to the getContext() function
  31909. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31910. */
  31911. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31912. private _rebuildInternalTextures;
  31913. private _rebuildEffects;
  31914. /**
  31915. * Gets a boolean indicating if all created effects are ready
  31916. * @returns true if all effects are ready
  31917. */
  31918. areAllEffectsReady(): boolean;
  31919. protected _rebuildBuffers(): void;
  31920. private _initGLContext;
  31921. /**
  31922. * Gets version of the current webGL context
  31923. */
  31924. get webGLVersion(): number;
  31925. /**
  31926. * Gets a string idenfifying the name of the class
  31927. * @returns "Engine" string
  31928. */
  31929. getClassName(): string;
  31930. /**
  31931. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31932. */
  31933. get isStencilEnable(): boolean;
  31934. /** @hidden */
  31935. _prepareWorkingCanvas(): void;
  31936. /**
  31937. * Reset the texture cache to empty state
  31938. */
  31939. resetTextureCache(): void;
  31940. /**
  31941. * Gets an object containing information about the current webGL context
  31942. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31943. */
  31944. getGlInfo(): {
  31945. vendor: string;
  31946. renderer: string;
  31947. version: string;
  31948. };
  31949. /**
  31950. * Defines the hardware scaling level.
  31951. * By default the hardware scaling level is computed from the window device ratio.
  31952. * 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.
  31953. * @param level defines the level to use
  31954. */
  31955. setHardwareScalingLevel(level: number): void;
  31956. /**
  31957. * Gets the current hardware scaling level.
  31958. * By default the hardware scaling level is computed from the window device ratio.
  31959. * 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.
  31960. * @returns a number indicating the current hardware scaling level
  31961. */
  31962. getHardwareScalingLevel(): number;
  31963. /**
  31964. * Gets the list of loaded textures
  31965. * @returns an array containing all loaded textures
  31966. */
  31967. getLoadedTexturesCache(): InternalTexture[];
  31968. /**
  31969. * Gets the object containing all engine capabilities
  31970. * @returns the EngineCapabilities object
  31971. */
  31972. getCaps(): EngineCapabilities;
  31973. /**
  31974. * stop executing a render loop function and remove it from the execution array
  31975. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31976. */
  31977. stopRenderLoop(renderFunction?: () => void): void;
  31978. /** @hidden */
  31979. _renderLoop(): void;
  31980. /**
  31981. * Gets the HTML canvas attached with the current webGL context
  31982. * @returns a HTML canvas
  31983. */
  31984. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31985. /**
  31986. * Gets host window
  31987. * @returns the host window object
  31988. */
  31989. getHostWindow(): Nullable<Window>;
  31990. /**
  31991. * Gets the current render width
  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 width
  31994. */
  31995. getRenderWidth(useScreen?: boolean): number;
  31996. /**
  31997. * Gets the current render height
  31998. * @param useScreen defines if screen size must be used (or the current render target if any)
  31999. * @returns a number defining the current render height
  32000. */
  32001. getRenderHeight(useScreen?: boolean): number;
  32002. /**
  32003. * Can be used to override the current requestAnimationFrame requester.
  32004. * @hidden
  32005. */
  32006. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32007. /**
  32008. * Register and execute a render loop. The engine can have more than one render function
  32009. * @param renderFunction defines the function to continuously execute
  32010. */
  32011. runRenderLoop(renderFunction: () => void): void;
  32012. /**
  32013. * Clear the current render buffer or the current render target (if any is set up)
  32014. * @param color defines the color to use
  32015. * @param backBuffer defines if the back buffer must be cleared
  32016. * @param depth defines if the depth buffer must be cleared
  32017. * @param stencil defines if the stencil buffer must be cleared
  32018. */
  32019. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32020. private _viewportCached;
  32021. /** @hidden */
  32022. _viewport(x: number, y: number, width: number, height: number): void;
  32023. /**
  32024. * Set the WebGL's viewport
  32025. * @param viewport defines the viewport element to be used
  32026. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32027. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32028. */
  32029. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32030. /**
  32031. * Begin a new frame
  32032. */
  32033. beginFrame(): void;
  32034. /**
  32035. * Enf the current frame
  32036. */
  32037. endFrame(): void;
  32038. /**
  32039. * Resize the view according to the canvas' size
  32040. */
  32041. resize(): void;
  32042. /**
  32043. * Force a specific size of the canvas
  32044. * @param width defines the new canvas' width
  32045. * @param height defines the new canvas' height
  32046. */
  32047. setSize(width: number, height: number): void;
  32048. /**
  32049. * Binds the frame buffer to the specified texture.
  32050. * @param texture The texture to render to or null for the default canvas
  32051. * @param faceIndex The face of the texture to render to in case of cube texture
  32052. * @param requiredWidth The width of the target to render to
  32053. * @param requiredHeight The height of the target to render to
  32054. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32055. * @param depthStencilTexture The depth stencil texture to use to render
  32056. * @param lodLevel defines le lod level to bind to the frame buffer
  32057. */
  32058. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  32059. /** @hidden */
  32060. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32061. /**
  32062. * Unbind the current render target texture from the webGL context
  32063. * @param texture defines the render target texture to unbind
  32064. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32065. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32066. */
  32067. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32068. /**
  32069. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32070. */
  32071. flushFramebuffer(): void;
  32072. /**
  32073. * Unbind the current render target and bind the default framebuffer
  32074. */
  32075. restoreDefaultFramebuffer(): void;
  32076. /** @hidden */
  32077. protected _resetVertexBufferBinding(): void;
  32078. /**
  32079. * Creates a vertex buffer
  32080. * @param data the data for the vertex buffer
  32081. * @returns the new WebGL static buffer
  32082. */
  32083. createVertexBuffer(data: DataArray): DataBuffer;
  32084. private _createVertexBuffer;
  32085. /**
  32086. * Creates a dynamic vertex buffer
  32087. * @param data the data for the dynamic vertex buffer
  32088. * @returns the new WebGL dynamic buffer
  32089. */
  32090. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32091. protected _resetIndexBufferBinding(): void;
  32092. /**
  32093. * Creates a new index buffer
  32094. * @param indices defines the content of the index buffer
  32095. * @param updatable defines if the index buffer must be updatable
  32096. * @returns a new webGL buffer
  32097. */
  32098. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32099. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32100. /**
  32101. * Bind a webGL buffer to the webGL context
  32102. * @param buffer defines the buffer to bind
  32103. */
  32104. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32105. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32106. private bindBuffer;
  32107. /**
  32108. * update the bound buffer with the given data
  32109. * @param data defines the data to update
  32110. */
  32111. updateArrayBuffer(data: Float32Array): void;
  32112. private _vertexAttribPointer;
  32113. private _bindIndexBufferWithCache;
  32114. private _bindVertexBuffersAttributes;
  32115. /**
  32116. * Records a vertex array object
  32117. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32118. * @param vertexBuffers defines the list of vertex buffers to store
  32119. * @param indexBuffer defines the index buffer to store
  32120. * @param effect defines the effect to store
  32121. * @returns the new vertex array object
  32122. */
  32123. recordVertexArrayObject(vertexBuffers: {
  32124. [key: string]: VertexBuffer;
  32125. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32126. /**
  32127. * Bind a specific vertex array object
  32128. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32129. * @param vertexArrayObject defines the vertex array object to bind
  32130. * @param indexBuffer defines the index buffer to bind
  32131. */
  32132. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32133. /**
  32134. * Bind webGl buffers directly to the webGL context
  32135. * @param vertexBuffer defines the vertex buffer to bind
  32136. * @param indexBuffer defines the index buffer to bind
  32137. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32138. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32139. * @param effect defines the effect associated with the vertex buffer
  32140. */
  32141. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32142. private _unbindVertexArrayObject;
  32143. /**
  32144. * Bind a list of vertex buffers to the webGL context
  32145. * @param vertexBuffers defines the list of vertex buffers to bind
  32146. * @param indexBuffer defines the index buffer to bind
  32147. * @param effect defines the effect associated with the vertex buffers
  32148. */
  32149. bindBuffers(vertexBuffers: {
  32150. [key: string]: Nullable<VertexBuffer>;
  32151. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32152. /**
  32153. * Unbind all instance attributes
  32154. */
  32155. unbindInstanceAttributes(): void;
  32156. /**
  32157. * Release and free the memory of a vertex array object
  32158. * @param vao defines the vertex array object to delete
  32159. */
  32160. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32161. /** @hidden */
  32162. _releaseBuffer(buffer: DataBuffer): boolean;
  32163. protected _deleteBuffer(buffer: DataBuffer): void;
  32164. /**
  32165. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32166. * @param instancesBuffer defines the webGL buffer to update and bind
  32167. * @param data defines the data to store in the buffer
  32168. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32169. */
  32170. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32171. /**
  32172. * Bind the content of a webGL buffer used with instanciation
  32173. * @param instancesBuffer defines the webGL buffer to bind
  32174. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32175. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32176. */
  32177. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32178. /**
  32179. * Disable the instance attribute corresponding to the name in parameter
  32180. * @param name defines the name of the attribute to disable
  32181. */
  32182. disableInstanceAttributeByName(name: string): void;
  32183. /**
  32184. * Disable the instance attribute corresponding to the location in parameter
  32185. * @param attributeLocation defines the attribute location of the attribute to disable
  32186. */
  32187. disableInstanceAttribute(attributeLocation: number): void;
  32188. /**
  32189. * Disable the attribute corresponding to the location in parameter
  32190. * @param attributeLocation defines the attribute location of the attribute to disable
  32191. */
  32192. disableAttributeByIndex(attributeLocation: number): void;
  32193. /**
  32194. * Send a draw order
  32195. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32196. * @param indexStart defines the starting index
  32197. * @param indexCount defines the number of index to draw
  32198. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32199. */
  32200. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32201. /**
  32202. * Draw a list of points
  32203. * @param verticesStart defines the index of first vertex to draw
  32204. * @param verticesCount defines the count of vertices to draw
  32205. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32206. */
  32207. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32208. /**
  32209. * Draw a list of unindexed primitives
  32210. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32211. * @param verticesStart defines the index of first vertex to draw
  32212. * @param verticesCount defines the count of vertices to draw
  32213. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32214. */
  32215. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32216. /**
  32217. * Draw a list of indexed primitives
  32218. * @param fillMode defines the primitive to use
  32219. * @param indexStart defines the starting index
  32220. * @param indexCount defines the number of index to draw
  32221. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32222. */
  32223. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32224. /**
  32225. * Draw a list of unindexed primitives
  32226. * @param fillMode defines the primitive to use
  32227. * @param verticesStart defines the index of first vertex to draw
  32228. * @param verticesCount defines the count of vertices to draw
  32229. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32230. */
  32231. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32232. private _drawMode;
  32233. /** @hidden */
  32234. protected _reportDrawCall(): void;
  32235. /** @hidden */
  32236. _releaseEffect(effect: Effect): void;
  32237. /** @hidden */
  32238. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32239. /**
  32240. * Create a new effect (used to store vertex/fragment shaders)
  32241. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32242. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32243. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32244. * @param samplers defines an array of string used to represent textures
  32245. * @param defines defines the string containing the defines to use to compile the shaders
  32246. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32247. * @param onCompiled defines a function to call when the effect creation is successful
  32248. * @param onError defines a function to call when the effect creation has failed
  32249. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32250. * @returns the new Effect
  32251. */
  32252. 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;
  32253. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32254. private _compileShader;
  32255. private _compileRawShader;
  32256. /**
  32257. * Directly creates a webGL program
  32258. * @param pipelineContext defines the pipeline context to attach to
  32259. * @param vertexCode defines the vertex shader code to use
  32260. * @param fragmentCode defines the fragment shader code to use
  32261. * @param context defines the webGL context to use (if not set, the current one will be used)
  32262. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32263. * @returns the new webGL program
  32264. */
  32265. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32266. /**
  32267. * Creates a webGL program
  32268. * @param pipelineContext defines the pipeline context to attach to
  32269. * @param vertexCode defines the vertex shader code to use
  32270. * @param fragmentCode defines the fragment shader code to use
  32271. * @param defines defines the string containing the defines to use to compile the shaders
  32272. * @param context defines the webGL context to use (if not set, the current one will be used)
  32273. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32274. * @returns the new webGL program
  32275. */
  32276. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32277. /**
  32278. * Creates a new pipeline context
  32279. * @returns the new pipeline
  32280. */
  32281. createPipelineContext(): IPipelineContext;
  32282. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32283. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32284. /** @hidden */
  32285. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32286. /** @hidden */
  32287. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32288. /** @hidden */
  32289. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32290. /**
  32291. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32292. * @param pipelineContext defines the pipeline context to use
  32293. * @param uniformsNames defines the list of uniform names
  32294. * @returns an array of webGL uniform locations
  32295. */
  32296. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32297. /**
  32298. * Gets the lsit of active attributes for a given webGL program
  32299. * @param pipelineContext defines the pipeline context to use
  32300. * @param attributesNames defines the list of attribute names to get
  32301. * @returns an array of indices indicating the offset of each attribute
  32302. */
  32303. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32304. /**
  32305. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32306. * @param effect defines the effect to activate
  32307. */
  32308. enableEffect(effect: Nullable<Effect>): void;
  32309. /**
  32310. * Set the value of an uniform to a number (int)
  32311. * @param uniform defines the webGL uniform location where to store the value
  32312. * @param value defines the int number to store
  32313. */
  32314. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32315. /**
  32316. * Set the value of an uniform to an array of int32
  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. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32321. /**
  32322. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32327. /**
  32328. * Set the value of an uniform to an array of int32 (stored as vec3)
  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. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32333. /**
  32334. * Set the value of an uniform to an array of int32 (stored as vec4)
  32335. * @param uniform defines the webGL uniform location where to store the value
  32336. * @param array defines the array of int32 to store
  32337. */
  32338. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32339. /**
  32340. * Set the value of an uniform to an array of number
  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. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32345. /**
  32346. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32351. /**
  32352. * Set the value of an uniform to an array of number (stored as vec3)
  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. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32357. /**
  32358. * Set the value of an uniform to an array of number (stored as vec4)
  32359. * @param uniform defines the webGL uniform location where to store the value
  32360. * @param array defines the array of number to store
  32361. */
  32362. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32363. /**
  32364. * Set the value of an uniform to an array of float32 (stored as matrices)
  32365. * @param uniform defines the webGL uniform location where to store the value
  32366. * @param matrices defines the array of float32 to store
  32367. */
  32368. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32369. /**
  32370. * Set the value of an uniform to a matrix (3x3)
  32371. * @param uniform defines the webGL uniform location where to store the value
  32372. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32373. */
  32374. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32375. /**
  32376. * Set the value of an uniform to a matrix (2x2)
  32377. * @param uniform defines the webGL uniform location where to store the value
  32378. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32379. */
  32380. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32381. /**
  32382. * Set the value of an uniform to a number (float)
  32383. * @param uniform defines the webGL uniform location where to store the value
  32384. * @param value defines the float number to store
  32385. */
  32386. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32387. /**
  32388. * Set the value of an uniform to a vec2
  32389. * @param uniform defines the webGL uniform location where to store the value
  32390. * @param x defines the 1st component of the value
  32391. * @param y defines the 2nd component of the value
  32392. */
  32393. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32394. /**
  32395. * Set the value of an uniform to a vec3
  32396. * @param uniform defines the webGL uniform location where to store the value
  32397. * @param x defines the 1st component of the value
  32398. * @param y defines the 2nd component of the value
  32399. * @param z defines the 3rd component of the value
  32400. */
  32401. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32402. /**
  32403. * Set the value of an uniform to a vec4
  32404. * @param uniform defines the webGL uniform location where to store the value
  32405. * @param x defines the 1st component of the value
  32406. * @param y defines the 2nd component of the value
  32407. * @param z defines the 3rd component of the value
  32408. * @param w defines the 4th component of the value
  32409. */
  32410. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32411. /**
  32412. * Apply all cached states (depth, culling, stencil and alpha)
  32413. */
  32414. applyStates(): void;
  32415. /**
  32416. * Enable or disable color writing
  32417. * @param enable defines the state to set
  32418. */
  32419. setColorWrite(enable: boolean): void;
  32420. /**
  32421. * Gets a boolean indicating if color writing is enabled
  32422. * @returns the current color writing state
  32423. */
  32424. getColorWrite(): boolean;
  32425. /**
  32426. * Gets the depth culling state manager
  32427. */
  32428. get depthCullingState(): DepthCullingState;
  32429. /**
  32430. * Gets the alpha state manager
  32431. */
  32432. get alphaState(): AlphaState;
  32433. /**
  32434. * Gets the stencil state manager
  32435. */
  32436. get stencilState(): StencilState;
  32437. /**
  32438. * Clears the list of texture accessible through engine.
  32439. * This can help preventing texture load conflict due to name collision.
  32440. */
  32441. clearInternalTexturesCache(): void;
  32442. /**
  32443. * Force the entire cache to be cleared
  32444. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32445. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32446. */
  32447. wipeCaches(bruteForce?: boolean): void;
  32448. /** @hidden */
  32449. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32450. min: number;
  32451. mag: number;
  32452. };
  32453. /** @hidden */
  32454. _createTexture(): WebGLTexture;
  32455. /**
  32456. * Usually called from Texture.ts.
  32457. * Passed information to create a WebGLTexture
  32458. * @param urlArg defines a value which contains one of the following:
  32459. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32460. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32461. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32462. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32463. * @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)
  32464. * @param scene needed for loading to the correct scene
  32465. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32466. * @param onLoad optional callback to be called upon successful completion
  32467. * @param onError optional callback to be called upon failure
  32468. * @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
  32469. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32470. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32471. * @param forcedExtension defines the extension to use to pick the right loader
  32472. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32473. * @param mimeType defines an optional mime type
  32474. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32475. */
  32476. 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;
  32477. /**
  32478. * Loads an image as an HTMLImageElement.
  32479. * @param input url string, ArrayBuffer, or Blob to load
  32480. * @param onLoad callback called when the image successfully loads
  32481. * @param onError callback called when the image fails to load
  32482. * @param offlineProvider offline provider for caching
  32483. * @param mimeType optional mime type
  32484. * @returns the HTMLImageElement of the loaded image
  32485. * @hidden
  32486. */
  32487. 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>;
  32488. /**
  32489. * @hidden
  32490. */
  32491. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32492. /**
  32493. * Creates a raw texture
  32494. * @param data defines the data to store in the texture
  32495. * @param width defines the width of the texture
  32496. * @param height defines the height of the texture
  32497. * @param format defines the format of the data
  32498. * @param generateMipMaps defines if the engine should generate the mip levels
  32499. * @param invertY defines if data must be stored with Y axis inverted
  32500. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32501. * @param compression defines the compression used (null by default)
  32502. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32503. * @returns the raw texture inside an InternalTexture
  32504. */
  32505. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32506. /**
  32507. * Creates a new raw cube texture
  32508. * @param data defines the array of data to use to create each face
  32509. * @param size defines the size of the textures
  32510. * @param format defines the format of the data
  32511. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32512. * @param generateMipMaps defines if the engine should generate the mip levels
  32513. * @param invertY defines if data must be stored with Y axis inverted
  32514. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32515. * @param compression defines the compression used (null by default)
  32516. * @returns the cube texture as an InternalTexture
  32517. */
  32518. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32519. /**
  32520. * Creates a new raw 3D texture
  32521. * @param data defines the data used to create the texture
  32522. * @param width defines the width of the texture
  32523. * @param height defines the height of the texture
  32524. * @param depth defines the depth of the texture
  32525. * @param format defines the format of the texture
  32526. * @param generateMipMaps defines if the engine must generate mip levels
  32527. * @param invertY defines if data must be stored with Y axis inverted
  32528. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32529. * @param compression defines the compressed used (can be null)
  32530. * @param textureType defines the compressed used (can be null)
  32531. * @returns a new raw 3D texture (stored in an InternalTexture)
  32532. */
  32533. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32534. /**
  32535. * Creates a new raw 2D array texture
  32536. * @param data defines the data used to create the texture
  32537. * @param width defines the width of the texture
  32538. * @param height defines the height of the texture
  32539. * @param depth defines the number of layers of the texture
  32540. * @param format defines the format of the texture
  32541. * @param generateMipMaps defines if the engine must generate mip levels
  32542. * @param invertY defines if data must be stored with Y axis inverted
  32543. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32544. * @param compression defines the compressed used (can be null)
  32545. * @param textureType defines the compressed used (can be null)
  32546. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32547. */
  32548. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32549. private _unpackFlipYCached;
  32550. /**
  32551. * In case you are sharing the context with other applications, it might
  32552. * be interested to not cache the unpack flip y state to ensure a consistent
  32553. * value would be set.
  32554. */
  32555. enableUnpackFlipYCached: boolean;
  32556. /** @hidden */
  32557. _unpackFlipY(value: boolean): void;
  32558. /** @hidden */
  32559. _getUnpackAlignement(): number;
  32560. private _getTextureTarget;
  32561. /**
  32562. * Update the sampling mode of a given texture
  32563. * @param samplingMode defines the required sampling mode
  32564. * @param texture defines the texture to update
  32565. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32566. */
  32567. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32568. /**
  32569. * Update the sampling mode of a given texture
  32570. * @param texture defines the texture to update
  32571. * @param wrapU defines the texture wrap mode of the u coordinates
  32572. * @param wrapV defines the texture wrap mode of the v coordinates
  32573. * @param wrapR defines the texture wrap mode of the r coordinates
  32574. */
  32575. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32576. /** @hidden */
  32577. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32578. width: number;
  32579. height: number;
  32580. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32581. /** @hidden */
  32582. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32583. /** @hidden */
  32584. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32585. /**
  32586. * Update a portion of an internal texture
  32587. * @param texture defines the texture to update
  32588. * @param imageData defines the data to store into the texture
  32589. * @param xOffset defines the x coordinates of the update rectangle
  32590. * @param yOffset defines the y coordinates of the update rectangle
  32591. * @param width defines the width of the update rectangle
  32592. * @param height defines the height of the update rectangle
  32593. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32594. * @param lod defines the lod level to update (0 by default)
  32595. */
  32596. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32597. /** @hidden */
  32598. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32599. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32600. private _prepareWebGLTexture;
  32601. /** @hidden */
  32602. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32603. private _getDepthStencilBuffer;
  32604. /** @hidden */
  32605. _releaseFramebufferObjects(texture: InternalTexture): void;
  32606. /** @hidden */
  32607. _releaseTexture(texture: InternalTexture): void;
  32608. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32609. protected _setProgram(program: WebGLProgram): void;
  32610. protected _boundUniforms: {
  32611. [key: number]: WebGLUniformLocation;
  32612. };
  32613. /**
  32614. * Binds an effect to the webGL context
  32615. * @param effect defines the effect to bind
  32616. */
  32617. bindSamplers(effect: Effect): void;
  32618. private _activateCurrentTexture;
  32619. /** @hidden */
  32620. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32621. /** @hidden */
  32622. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32623. /**
  32624. * Unbind all textures from the webGL context
  32625. */
  32626. unbindAllTextures(): void;
  32627. /**
  32628. * Sets a texture to the according uniform.
  32629. * @param channel The texture channel
  32630. * @param uniform The uniform to set
  32631. * @param texture The texture to apply
  32632. */
  32633. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32634. private _bindSamplerUniformToChannel;
  32635. private _getTextureWrapMode;
  32636. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32637. /**
  32638. * Sets an array of texture to the webGL context
  32639. * @param channel defines the channel where the texture array must be set
  32640. * @param uniform defines the associated uniform location
  32641. * @param textures defines the array of textures to bind
  32642. */
  32643. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32644. /** @hidden */
  32645. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32646. private _setTextureParameterFloat;
  32647. private _setTextureParameterInteger;
  32648. /**
  32649. * Unbind all vertex attributes from the webGL context
  32650. */
  32651. unbindAllAttributes(): void;
  32652. /**
  32653. * 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
  32654. */
  32655. releaseEffects(): void;
  32656. /**
  32657. * Dispose and release all associated resources
  32658. */
  32659. dispose(): void;
  32660. /**
  32661. * Attach a new callback raised when context lost event is fired
  32662. * @param callback defines the callback to call
  32663. */
  32664. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32665. /**
  32666. * Attach a new callback raised when context restored event is fired
  32667. * @param callback defines the callback to call
  32668. */
  32669. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32670. /**
  32671. * Get the current error code of the webGL context
  32672. * @returns the error code
  32673. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32674. */
  32675. getError(): number;
  32676. private _canRenderToFloatFramebuffer;
  32677. private _canRenderToHalfFloatFramebuffer;
  32678. private _canRenderToFramebuffer;
  32679. /** @hidden */
  32680. _getWebGLTextureType(type: number): number;
  32681. /** @hidden */
  32682. _getInternalFormat(format: number): number;
  32683. /** @hidden */
  32684. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32685. /** @hidden */
  32686. _getRGBAMultiSampleBufferFormat(type: number): number;
  32687. /** @hidden */
  32688. _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;
  32689. /**
  32690. * Loads a file from a url
  32691. * @param url url to load
  32692. * @param onSuccess callback called when the file successfully loads
  32693. * @param onProgress callback called while file is loading (if the server supports this mode)
  32694. * @param offlineProvider defines the offline provider for caching
  32695. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32696. * @param onError callback called when the file fails to load
  32697. * @returns a file request object
  32698. * @hidden
  32699. */
  32700. 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;
  32701. /**
  32702. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32703. * @param x defines the x coordinate of the rectangle where pixels must be read
  32704. * @param y defines the y coordinate of the rectangle where pixels must be read
  32705. * @param width defines the width of the rectangle where pixels must be read
  32706. * @param height defines the height of the rectangle where pixels must be read
  32707. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32708. * @returns a Uint8Array containing RGBA colors
  32709. */
  32710. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32711. private static _isSupported;
  32712. /**
  32713. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32714. * @returns true if the engine can be created
  32715. * @ignorenaming
  32716. */
  32717. static isSupported(): boolean;
  32718. /**
  32719. * Find the next highest power of two.
  32720. * @param x Number to start search from.
  32721. * @return Next highest power of two.
  32722. */
  32723. static CeilingPOT(x: number): number;
  32724. /**
  32725. * Find the next lowest power of two.
  32726. * @param x Number to start search from.
  32727. * @return Next lowest power of two.
  32728. */
  32729. static FloorPOT(x: number): number;
  32730. /**
  32731. * Find the nearest power of two.
  32732. * @param x Number to start search from.
  32733. * @return Next nearest power of two.
  32734. */
  32735. static NearestPOT(x: number): number;
  32736. /**
  32737. * Get the closest exponent of two
  32738. * @param value defines the value to approximate
  32739. * @param max defines the maximum value to return
  32740. * @param mode defines how to define the closest value
  32741. * @returns closest exponent of two of the given value
  32742. */
  32743. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32744. /**
  32745. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32746. * @param func - the function to be called
  32747. * @param requester - the object that will request the next frame. Falls back to window.
  32748. * @returns frame number
  32749. */
  32750. static QueueNewFrame(func: () => void, requester?: any): number;
  32751. /**
  32752. * Gets host document
  32753. * @returns the host document object
  32754. */
  32755. getHostDocument(): Nullable<Document>;
  32756. }
  32757. }
  32758. declare module "babylonjs/Maths/sphericalPolynomial" {
  32759. import { Vector3 } from "babylonjs/Maths/math.vector";
  32760. import { Color3 } from "babylonjs/Maths/math.color";
  32761. /**
  32762. * Class representing spherical harmonics coefficients to the 3rd degree
  32763. */
  32764. export class SphericalHarmonics {
  32765. /**
  32766. * Defines whether or not the harmonics have been prescaled for rendering.
  32767. */
  32768. preScaled: boolean;
  32769. /**
  32770. * The l0,0 coefficients of the spherical harmonics
  32771. */
  32772. l00: Vector3;
  32773. /**
  32774. * The l1,-1 coefficients of the spherical harmonics
  32775. */
  32776. l1_1: Vector3;
  32777. /**
  32778. * The l1,0 coefficients of the spherical harmonics
  32779. */
  32780. l10: Vector3;
  32781. /**
  32782. * The l1,1 coefficients of the spherical harmonics
  32783. */
  32784. l11: Vector3;
  32785. /**
  32786. * The l2,-2 coefficients of the spherical harmonics
  32787. */
  32788. l2_2: Vector3;
  32789. /**
  32790. * The l2,-1 coefficients of the spherical harmonics
  32791. */
  32792. l2_1: Vector3;
  32793. /**
  32794. * The l2,0 coefficients of the spherical harmonics
  32795. */
  32796. l20: Vector3;
  32797. /**
  32798. * The l2,1 coefficients of the spherical harmonics
  32799. */
  32800. l21: Vector3;
  32801. /**
  32802. * The l2,2 coefficients of the spherical harmonics
  32803. */
  32804. l22: Vector3;
  32805. /**
  32806. * Adds a light to the spherical harmonics
  32807. * @param direction the direction of the light
  32808. * @param color the color of the light
  32809. * @param deltaSolidAngle the delta solid angle of the light
  32810. */
  32811. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32812. /**
  32813. * Scales the spherical harmonics by the given amount
  32814. * @param scale the amount to scale
  32815. */
  32816. scaleInPlace(scale: number): void;
  32817. /**
  32818. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32819. *
  32820. * ```
  32821. * E_lm = A_l * L_lm
  32822. * ```
  32823. *
  32824. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32825. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32826. * the scaling factors are given in equation 9.
  32827. */
  32828. convertIncidentRadianceToIrradiance(): void;
  32829. /**
  32830. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32831. *
  32832. * ```
  32833. * L = (1/pi) * E * rho
  32834. * ```
  32835. *
  32836. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32837. */
  32838. convertIrradianceToLambertianRadiance(): void;
  32839. /**
  32840. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32841. * required operations at run time.
  32842. *
  32843. * This is simply done by scaling back the SH with Ylm constants parameter.
  32844. * The trigonometric part being applied by the shader at run time.
  32845. */
  32846. preScaleForRendering(): void;
  32847. /**
  32848. * Constructs a spherical harmonics from an array.
  32849. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32850. * @returns the spherical harmonics
  32851. */
  32852. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32853. /**
  32854. * Gets the spherical harmonics from polynomial
  32855. * @param polynomial the spherical polynomial
  32856. * @returns the spherical harmonics
  32857. */
  32858. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32859. }
  32860. /**
  32861. * Class representing spherical polynomial coefficients to the 3rd degree
  32862. */
  32863. export class SphericalPolynomial {
  32864. private _harmonics;
  32865. /**
  32866. * The spherical harmonics used to create the polynomials.
  32867. */
  32868. get preScaledHarmonics(): SphericalHarmonics;
  32869. /**
  32870. * The x coefficients of the spherical polynomial
  32871. */
  32872. x: Vector3;
  32873. /**
  32874. * The y coefficients of the spherical polynomial
  32875. */
  32876. y: Vector3;
  32877. /**
  32878. * The z coefficients of the spherical polynomial
  32879. */
  32880. z: Vector3;
  32881. /**
  32882. * The xx coefficients of the spherical polynomial
  32883. */
  32884. xx: Vector3;
  32885. /**
  32886. * The yy coefficients of the spherical polynomial
  32887. */
  32888. yy: Vector3;
  32889. /**
  32890. * The zz coefficients of the spherical polynomial
  32891. */
  32892. zz: Vector3;
  32893. /**
  32894. * The xy coefficients of the spherical polynomial
  32895. */
  32896. xy: Vector3;
  32897. /**
  32898. * The yz coefficients of the spherical polynomial
  32899. */
  32900. yz: Vector3;
  32901. /**
  32902. * The zx coefficients of the spherical polynomial
  32903. */
  32904. zx: Vector3;
  32905. /**
  32906. * Adds an ambient color to the spherical polynomial
  32907. * @param color the color to add
  32908. */
  32909. addAmbient(color: Color3): void;
  32910. /**
  32911. * Scales the spherical polynomial by the given amount
  32912. * @param scale the amount to scale
  32913. */
  32914. scaleInPlace(scale: number): void;
  32915. /**
  32916. * Gets the spherical polynomial from harmonics
  32917. * @param harmonics the spherical harmonics
  32918. * @returns the spherical polynomial
  32919. */
  32920. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32921. /**
  32922. * Constructs a spherical polynomial from an array.
  32923. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32924. * @returns the spherical polynomial
  32925. */
  32926. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32927. }
  32928. }
  32929. declare module "babylonjs/Materials/Textures/internalTexture" {
  32930. import { Observable } from "babylonjs/Misc/observable";
  32931. import { Nullable, int } from "babylonjs/types";
  32932. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32934. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32935. /**
  32936. * Defines the source of the internal texture
  32937. */
  32938. export enum InternalTextureSource {
  32939. /**
  32940. * The source of the texture data is unknown
  32941. */
  32942. Unknown = 0,
  32943. /**
  32944. * Texture data comes from an URL
  32945. */
  32946. Url = 1,
  32947. /**
  32948. * Texture data is only used for temporary storage
  32949. */
  32950. Temp = 2,
  32951. /**
  32952. * Texture data comes from raw data (ArrayBuffer)
  32953. */
  32954. Raw = 3,
  32955. /**
  32956. * Texture content is dynamic (video or dynamic texture)
  32957. */
  32958. Dynamic = 4,
  32959. /**
  32960. * Texture content is generated by rendering to it
  32961. */
  32962. RenderTarget = 5,
  32963. /**
  32964. * Texture content is part of a multi render target process
  32965. */
  32966. MultiRenderTarget = 6,
  32967. /**
  32968. * Texture data comes from a cube data file
  32969. */
  32970. Cube = 7,
  32971. /**
  32972. * Texture data comes from a raw cube data
  32973. */
  32974. CubeRaw = 8,
  32975. /**
  32976. * Texture data come from a prefiltered cube data file
  32977. */
  32978. CubePrefiltered = 9,
  32979. /**
  32980. * Texture content is raw 3D data
  32981. */
  32982. Raw3D = 10,
  32983. /**
  32984. * Texture content is raw 2D array data
  32985. */
  32986. Raw2DArray = 11,
  32987. /**
  32988. * Texture content is a depth texture
  32989. */
  32990. Depth = 12,
  32991. /**
  32992. * Texture data comes from a raw cube data encoded with RGBD
  32993. */
  32994. CubeRawRGBD = 13
  32995. }
  32996. /**
  32997. * Class used to store data associated with WebGL texture data for the engine
  32998. * This class should not be used directly
  32999. */
  33000. export class InternalTexture {
  33001. /** @hidden */
  33002. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33003. /**
  33004. * Defines if the texture is ready
  33005. */
  33006. isReady: boolean;
  33007. /**
  33008. * Defines if the texture is a cube texture
  33009. */
  33010. isCube: boolean;
  33011. /**
  33012. * Defines if the texture contains 3D data
  33013. */
  33014. is3D: boolean;
  33015. /**
  33016. * Defines if the texture contains 2D array data
  33017. */
  33018. is2DArray: boolean;
  33019. /**
  33020. * Defines if the texture contains multiview data
  33021. */
  33022. isMultiview: boolean;
  33023. /**
  33024. * Gets the URL used to load this texture
  33025. */
  33026. url: string;
  33027. /**
  33028. * Gets the sampling mode of the texture
  33029. */
  33030. samplingMode: number;
  33031. /**
  33032. * Gets a boolean indicating if the texture needs mipmaps generation
  33033. */
  33034. generateMipMaps: boolean;
  33035. /**
  33036. * Gets the number of samples used by the texture (WebGL2+ only)
  33037. */
  33038. samples: number;
  33039. /**
  33040. * Gets the type of the texture (int, float...)
  33041. */
  33042. type: number;
  33043. /**
  33044. * Gets the format of the texture (RGB, RGBA...)
  33045. */
  33046. format: number;
  33047. /**
  33048. * Observable called when the texture is loaded
  33049. */
  33050. onLoadedObservable: Observable<InternalTexture>;
  33051. /**
  33052. * Gets the width of the texture
  33053. */
  33054. width: number;
  33055. /**
  33056. * Gets the height of the texture
  33057. */
  33058. height: number;
  33059. /**
  33060. * Gets the depth of the texture
  33061. */
  33062. depth: number;
  33063. /**
  33064. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33065. */
  33066. baseWidth: number;
  33067. /**
  33068. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33069. */
  33070. baseHeight: number;
  33071. /**
  33072. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33073. */
  33074. baseDepth: number;
  33075. /**
  33076. * Gets a boolean indicating if the texture is inverted on Y axis
  33077. */
  33078. invertY: boolean;
  33079. /** @hidden */
  33080. _invertVScale: boolean;
  33081. /** @hidden */
  33082. _associatedChannel: number;
  33083. /** @hidden */
  33084. _source: InternalTextureSource;
  33085. /** @hidden */
  33086. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33087. /** @hidden */
  33088. _bufferView: Nullable<ArrayBufferView>;
  33089. /** @hidden */
  33090. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33091. /** @hidden */
  33092. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33093. /** @hidden */
  33094. _size: number;
  33095. /** @hidden */
  33096. _extension: string;
  33097. /** @hidden */
  33098. _files: Nullable<string[]>;
  33099. /** @hidden */
  33100. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33101. /** @hidden */
  33102. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33103. /** @hidden */
  33104. _framebuffer: Nullable<WebGLFramebuffer>;
  33105. /** @hidden */
  33106. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33107. /** @hidden */
  33108. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33109. /** @hidden */
  33110. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33111. /** @hidden */
  33112. _attachments: Nullable<number[]>;
  33113. /** @hidden */
  33114. _cachedCoordinatesMode: Nullable<number>;
  33115. /** @hidden */
  33116. _cachedWrapU: Nullable<number>;
  33117. /** @hidden */
  33118. _cachedWrapV: Nullable<number>;
  33119. /** @hidden */
  33120. _cachedWrapR: Nullable<number>;
  33121. /** @hidden */
  33122. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33123. /** @hidden */
  33124. _isDisabled: boolean;
  33125. /** @hidden */
  33126. _compression: Nullable<string>;
  33127. /** @hidden */
  33128. _generateStencilBuffer: boolean;
  33129. /** @hidden */
  33130. _generateDepthBuffer: boolean;
  33131. /** @hidden */
  33132. _comparisonFunction: number;
  33133. /** @hidden */
  33134. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33135. /** @hidden */
  33136. _lodGenerationScale: number;
  33137. /** @hidden */
  33138. _lodGenerationOffset: number;
  33139. /** @hidden */
  33140. _colorTextureArray: Nullable<WebGLTexture>;
  33141. /** @hidden */
  33142. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33143. /** @hidden */
  33144. _lodTextureHigh: Nullable<BaseTexture>;
  33145. /** @hidden */
  33146. _lodTextureMid: Nullable<BaseTexture>;
  33147. /** @hidden */
  33148. _lodTextureLow: Nullable<BaseTexture>;
  33149. /** @hidden */
  33150. _isRGBD: boolean;
  33151. /** @hidden */
  33152. _linearSpecularLOD: boolean;
  33153. /** @hidden */
  33154. _irradianceTexture: Nullable<BaseTexture>;
  33155. /** @hidden */
  33156. _webGLTexture: Nullable<WebGLTexture>;
  33157. /** @hidden */
  33158. _references: number;
  33159. private _engine;
  33160. /**
  33161. * Gets the Engine the texture belongs to.
  33162. * @returns The babylon engine
  33163. */
  33164. getEngine(): ThinEngine;
  33165. /**
  33166. * Gets the data source type of the texture
  33167. */
  33168. get source(): InternalTextureSource;
  33169. /**
  33170. * Creates a new InternalTexture
  33171. * @param engine defines the engine to use
  33172. * @param source defines the type of data that will be used
  33173. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33174. */
  33175. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33176. /**
  33177. * Increments the number of references (ie. the number of Texture that point to it)
  33178. */
  33179. incrementReferences(): void;
  33180. /**
  33181. * Change the size of the texture (not the size of the content)
  33182. * @param width defines the new width
  33183. * @param height defines the new height
  33184. * @param depth defines the new depth (1 by default)
  33185. */
  33186. updateSize(width: int, height: int, depth?: int): void;
  33187. /** @hidden */
  33188. _rebuild(): void;
  33189. /** @hidden */
  33190. _swapAndDie(target: InternalTexture): void;
  33191. /**
  33192. * Dispose the current allocated resources
  33193. */
  33194. dispose(): void;
  33195. }
  33196. }
  33197. declare module "babylonjs/Audio/analyser" {
  33198. import { Scene } from "babylonjs/scene";
  33199. /**
  33200. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33202. */
  33203. export class Analyser {
  33204. /**
  33205. * Gets or sets the smoothing
  33206. * @ignorenaming
  33207. */
  33208. SMOOTHING: number;
  33209. /**
  33210. * Gets or sets the FFT table size
  33211. * @ignorenaming
  33212. */
  33213. FFT_SIZE: number;
  33214. /**
  33215. * Gets or sets the bar graph amplitude
  33216. * @ignorenaming
  33217. */
  33218. BARGRAPHAMPLITUDE: number;
  33219. /**
  33220. * Gets or sets the position of the debug canvas
  33221. * @ignorenaming
  33222. */
  33223. DEBUGCANVASPOS: {
  33224. x: number;
  33225. y: number;
  33226. };
  33227. /**
  33228. * Gets or sets the debug canvas size
  33229. * @ignorenaming
  33230. */
  33231. DEBUGCANVASSIZE: {
  33232. width: number;
  33233. height: number;
  33234. };
  33235. private _byteFreqs;
  33236. private _byteTime;
  33237. private _floatFreqs;
  33238. private _webAudioAnalyser;
  33239. private _debugCanvas;
  33240. private _debugCanvasContext;
  33241. private _scene;
  33242. private _registerFunc;
  33243. private _audioEngine;
  33244. /**
  33245. * Creates a new analyser
  33246. * @param scene defines hosting scene
  33247. */
  33248. constructor(scene: Scene);
  33249. /**
  33250. * Get the number of data values you will have to play with for the visualization
  33251. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33252. * @returns a number
  33253. */
  33254. getFrequencyBinCount(): number;
  33255. /**
  33256. * Gets the current frequency data as a byte array
  33257. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33258. * @returns a Uint8Array
  33259. */
  33260. getByteFrequencyData(): Uint8Array;
  33261. /**
  33262. * Gets the current waveform as a byte array
  33263. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33264. * @returns a Uint8Array
  33265. */
  33266. getByteTimeDomainData(): Uint8Array;
  33267. /**
  33268. * Gets the current frequency data as a float array
  33269. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33270. * @returns a Float32Array
  33271. */
  33272. getFloatFrequencyData(): Float32Array;
  33273. /**
  33274. * Renders the debug canvas
  33275. */
  33276. drawDebugCanvas(): void;
  33277. /**
  33278. * Stops rendering the debug canvas and removes it
  33279. */
  33280. stopDebugCanvas(): void;
  33281. /**
  33282. * Connects two audio nodes
  33283. * @param inputAudioNode defines first node to connect
  33284. * @param outputAudioNode defines second node to connect
  33285. */
  33286. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33287. /**
  33288. * Releases all associated resources
  33289. */
  33290. dispose(): void;
  33291. }
  33292. }
  33293. declare module "babylonjs/Audio/audioEngine" {
  33294. import { IDisposable } from "babylonjs/scene";
  33295. import { Analyser } from "babylonjs/Audio/analyser";
  33296. import { Nullable } from "babylonjs/types";
  33297. import { Observable } from "babylonjs/Misc/observable";
  33298. /**
  33299. * This represents an audio engine and it is responsible
  33300. * to play, synchronize and analyse sounds throughout the application.
  33301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33302. */
  33303. export interface IAudioEngine extends IDisposable {
  33304. /**
  33305. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33306. */
  33307. readonly canUseWebAudio: boolean;
  33308. /**
  33309. * Gets the current AudioContext if available.
  33310. */
  33311. readonly audioContext: Nullable<AudioContext>;
  33312. /**
  33313. * The master gain node defines the global audio volume of your audio engine.
  33314. */
  33315. readonly masterGain: GainNode;
  33316. /**
  33317. * Gets whether or not mp3 are supported by your browser.
  33318. */
  33319. readonly isMP3supported: boolean;
  33320. /**
  33321. * Gets whether or not ogg are supported by your browser.
  33322. */
  33323. readonly isOGGsupported: boolean;
  33324. /**
  33325. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33326. * @ignoreNaming
  33327. */
  33328. WarnedWebAudioUnsupported: boolean;
  33329. /**
  33330. * Defines if the audio engine relies on a custom unlocked button.
  33331. * In this case, the embedded button will not be displayed.
  33332. */
  33333. useCustomUnlockedButton: boolean;
  33334. /**
  33335. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33336. */
  33337. readonly unlocked: boolean;
  33338. /**
  33339. * Event raised when audio has been unlocked on the browser.
  33340. */
  33341. onAudioUnlockedObservable: Observable<AudioEngine>;
  33342. /**
  33343. * Event raised when audio has been locked on the browser.
  33344. */
  33345. onAudioLockedObservable: Observable<AudioEngine>;
  33346. /**
  33347. * Flags the audio engine in Locked state.
  33348. * This happens due to new browser policies preventing audio to autoplay.
  33349. */
  33350. lock(): void;
  33351. /**
  33352. * Unlocks the audio engine once a user action has been done on the dom.
  33353. * This is helpful to resume play once browser policies have been satisfied.
  33354. */
  33355. unlock(): void;
  33356. }
  33357. /**
  33358. * This represents the default audio engine used in babylon.
  33359. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33361. */
  33362. export class AudioEngine implements IAudioEngine {
  33363. private _audioContext;
  33364. private _audioContextInitialized;
  33365. private _muteButton;
  33366. private _hostElement;
  33367. /**
  33368. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33369. */
  33370. canUseWebAudio: boolean;
  33371. /**
  33372. * The master gain node defines the global audio volume of your audio engine.
  33373. */
  33374. masterGain: GainNode;
  33375. /**
  33376. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33377. * @ignoreNaming
  33378. */
  33379. WarnedWebAudioUnsupported: boolean;
  33380. /**
  33381. * Gets whether or not mp3 are supported by your browser.
  33382. */
  33383. isMP3supported: boolean;
  33384. /**
  33385. * Gets whether or not ogg are supported by your browser.
  33386. */
  33387. isOGGsupported: boolean;
  33388. /**
  33389. * Gets whether audio has been unlocked on the device.
  33390. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33391. * a user interaction has happened.
  33392. */
  33393. unlocked: boolean;
  33394. /**
  33395. * Defines if the audio engine relies on a custom unlocked button.
  33396. * In this case, the embedded button will not be displayed.
  33397. */
  33398. useCustomUnlockedButton: boolean;
  33399. /**
  33400. * Event raised when audio has been unlocked on the browser.
  33401. */
  33402. onAudioUnlockedObservable: Observable<AudioEngine>;
  33403. /**
  33404. * Event raised when audio has been locked on the browser.
  33405. */
  33406. onAudioLockedObservable: Observable<AudioEngine>;
  33407. /**
  33408. * Gets the current AudioContext if available.
  33409. */
  33410. get audioContext(): Nullable<AudioContext>;
  33411. private _connectedAnalyser;
  33412. /**
  33413. * Instantiates a new audio engine.
  33414. *
  33415. * There should be only one per page as some browsers restrict the number
  33416. * of audio contexts you can create.
  33417. * @param hostElement defines the host element where to display the mute icon if necessary
  33418. */
  33419. constructor(hostElement?: Nullable<HTMLElement>);
  33420. /**
  33421. * Flags the audio engine in Locked state.
  33422. * This happens due to new browser policies preventing audio to autoplay.
  33423. */
  33424. lock(): void;
  33425. /**
  33426. * Unlocks the audio engine once a user action has been done on the dom.
  33427. * This is helpful to resume play once browser policies have been satisfied.
  33428. */
  33429. unlock(): void;
  33430. private _resumeAudioContext;
  33431. private _initializeAudioContext;
  33432. private _tryToRun;
  33433. private _triggerRunningState;
  33434. private _triggerSuspendedState;
  33435. private _displayMuteButton;
  33436. private _moveButtonToTopLeft;
  33437. private _onResize;
  33438. private _hideMuteButton;
  33439. /**
  33440. * Destroy and release the resources associated with the audio ccontext.
  33441. */
  33442. dispose(): void;
  33443. /**
  33444. * Gets the global volume sets on the master gain.
  33445. * @returns the global volume if set or -1 otherwise
  33446. */
  33447. getGlobalVolume(): number;
  33448. /**
  33449. * Sets the global volume of your experience (sets on the master gain).
  33450. * @param newVolume Defines the new global volume of the application
  33451. */
  33452. setGlobalVolume(newVolume: number): void;
  33453. /**
  33454. * Connect the audio engine to an audio analyser allowing some amazing
  33455. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33457. * @param analyser The analyser to connect to the engine
  33458. */
  33459. connectToAnalyser(analyser: Analyser): void;
  33460. }
  33461. }
  33462. declare module "babylonjs/Loading/loadingScreen" {
  33463. /**
  33464. * Interface used to present a loading screen while loading a scene
  33465. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33466. */
  33467. export interface ILoadingScreen {
  33468. /**
  33469. * Function called to display the loading screen
  33470. */
  33471. displayLoadingUI: () => void;
  33472. /**
  33473. * Function called to hide the loading screen
  33474. */
  33475. hideLoadingUI: () => void;
  33476. /**
  33477. * Gets or sets the color to use for the background
  33478. */
  33479. loadingUIBackgroundColor: string;
  33480. /**
  33481. * Gets or sets the text to display while loading
  33482. */
  33483. loadingUIText: string;
  33484. }
  33485. /**
  33486. * Class used for the default loading screen
  33487. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33488. */
  33489. export class DefaultLoadingScreen implements ILoadingScreen {
  33490. private _renderingCanvas;
  33491. private _loadingText;
  33492. private _loadingDivBackgroundColor;
  33493. private _loadingDiv;
  33494. private _loadingTextDiv;
  33495. /** Gets or sets the logo url to use for the default loading screen */
  33496. static DefaultLogoUrl: string;
  33497. /** Gets or sets the spinner url to use for the default loading screen */
  33498. static DefaultSpinnerUrl: string;
  33499. /**
  33500. * Creates a new default loading screen
  33501. * @param _renderingCanvas defines the canvas used to render the scene
  33502. * @param _loadingText defines the default text to display
  33503. * @param _loadingDivBackgroundColor defines the default background color
  33504. */
  33505. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33506. /**
  33507. * Function called to display the loading screen
  33508. */
  33509. displayLoadingUI(): void;
  33510. /**
  33511. * Function called to hide the loading screen
  33512. */
  33513. hideLoadingUI(): void;
  33514. /**
  33515. * Gets or sets the text to display while loading
  33516. */
  33517. set loadingUIText(text: string);
  33518. get loadingUIText(): string;
  33519. /**
  33520. * Gets or sets the color to use for the background
  33521. */
  33522. get loadingUIBackgroundColor(): string;
  33523. set loadingUIBackgroundColor(color: string);
  33524. private _resizeLoadingUI;
  33525. }
  33526. }
  33527. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33528. /**
  33529. * Interface for any object that can request an animation frame
  33530. */
  33531. export interface ICustomAnimationFrameRequester {
  33532. /**
  33533. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33534. */
  33535. renderFunction?: Function;
  33536. /**
  33537. * Called to request the next frame to render to
  33538. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33539. */
  33540. requestAnimationFrame: Function;
  33541. /**
  33542. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33543. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33544. */
  33545. requestID?: number;
  33546. }
  33547. }
  33548. declare module "babylonjs/Misc/performanceMonitor" {
  33549. /**
  33550. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33551. */
  33552. export class PerformanceMonitor {
  33553. private _enabled;
  33554. private _rollingFrameTime;
  33555. private _lastFrameTimeMs;
  33556. /**
  33557. * constructor
  33558. * @param frameSampleSize The number of samples required to saturate the sliding window
  33559. */
  33560. constructor(frameSampleSize?: number);
  33561. /**
  33562. * Samples current frame
  33563. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33564. */
  33565. sampleFrame(timeMs?: number): void;
  33566. /**
  33567. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33568. */
  33569. get averageFrameTime(): number;
  33570. /**
  33571. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33572. */
  33573. get averageFrameTimeVariance(): number;
  33574. /**
  33575. * Returns the frame time of the most recent frame
  33576. */
  33577. get instantaneousFrameTime(): number;
  33578. /**
  33579. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33580. */
  33581. get averageFPS(): number;
  33582. /**
  33583. * Returns the average framerate in frames per second using the most recent frame time
  33584. */
  33585. get instantaneousFPS(): number;
  33586. /**
  33587. * Returns true if enough samples have been taken to completely fill the sliding window
  33588. */
  33589. get isSaturated(): boolean;
  33590. /**
  33591. * Enables contributions to the sliding window sample set
  33592. */
  33593. enable(): void;
  33594. /**
  33595. * Disables contributions to the sliding window sample set
  33596. * Samples will not be interpolated over the disabled period
  33597. */
  33598. disable(): void;
  33599. /**
  33600. * Returns true if sampling is enabled
  33601. */
  33602. get isEnabled(): boolean;
  33603. /**
  33604. * Resets performance monitor
  33605. */
  33606. reset(): void;
  33607. }
  33608. /**
  33609. * RollingAverage
  33610. *
  33611. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33612. */
  33613. export class RollingAverage {
  33614. /**
  33615. * Current average
  33616. */
  33617. average: number;
  33618. /**
  33619. * Current variance
  33620. */
  33621. variance: number;
  33622. protected _samples: Array<number>;
  33623. protected _sampleCount: number;
  33624. protected _pos: number;
  33625. protected _m2: number;
  33626. /**
  33627. * constructor
  33628. * @param length The number of samples required to saturate the sliding window
  33629. */
  33630. constructor(length: number);
  33631. /**
  33632. * Adds a sample to the sample set
  33633. * @param v The sample value
  33634. */
  33635. add(v: number): void;
  33636. /**
  33637. * Returns previously added values or null if outside of history or outside the sliding window domain
  33638. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33639. * @return Value previously recorded with add() or null if outside of range
  33640. */
  33641. history(i: number): number;
  33642. /**
  33643. * Returns true if enough samples have been taken to completely fill the sliding window
  33644. * @return true if sample-set saturated
  33645. */
  33646. isSaturated(): boolean;
  33647. /**
  33648. * Resets the rolling average (equivalent to 0 samples taken so far)
  33649. */
  33650. reset(): void;
  33651. /**
  33652. * Wraps a value around the sample range boundaries
  33653. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33654. * @return Wrapped position in sample range
  33655. */
  33656. protected _wrapPosition(i: number): number;
  33657. }
  33658. }
  33659. declare module "babylonjs/Misc/perfCounter" {
  33660. /**
  33661. * This class is used to track a performance counter which is number based.
  33662. * The user has access to many properties which give statistics of different nature.
  33663. *
  33664. * The implementer can track two kinds of Performance Counter: time and count.
  33665. * 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.
  33666. * 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.
  33667. */
  33668. export class PerfCounter {
  33669. /**
  33670. * Gets or sets a global boolean to turn on and off all the counters
  33671. */
  33672. static Enabled: boolean;
  33673. /**
  33674. * Returns the smallest value ever
  33675. */
  33676. get min(): number;
  33677. /**
  33678. * Returns the biggest value ever
  33679. */
  33680. get max(): number;
  33681. /**
  33682. * Returns the average value since the performance counter is running
  33683. */
  33684. get average(): number;
  33685. /**
  33686. * Returns the average value of the last second the counter was monitored
  33687. */
  33688. get lastSecAverage(): number;
  33689. /**
  33690. * Returns the current value
  33691. */
  33692. get current(): number;
  33693. /**
  33694. * Gets the accumulated total
  33695. */
  33696. get total(): number;
  33697. /**
  33698. * Gets the total value count
  33699. */
  33700. get count(): number;
  33701. /**
  33702. * Creates a new counter
  33703. */
  33704. constructor();
  33705. /**
  33706. * Call this method to start monitoring a new frame.
  33707. * 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.
  33708. */
  33709. fetchNewFrame(): void;
  33710. /**
  33711. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33712. * @param newCount the count value to add to the monitored count
  33713. * @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.
  33714. */
  33715. addCount(newCount: number, fetchResult: boolean): void;
  33716. /**
  33717. * Start monitoring this performance counter
  33718. */
  33719. beginMonitoring(): void;
  33720. /**
  33721. * Compute the time lapsed since the previous beginMonitoring() call.
  33722. * @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
  33723. */
  33724. endMonitoring(newFrame?: boolean): void;
  33725. private _fetchResult;
  33726. private _startMonitoringTime;
  33727. private _min;
  33728. private _max;
  33729. private _average;
  33730. private _current;
  33731. private _totalValueCount;
  33732. private _totalAccumulated;
  33733. private _lastSecAverage;
  33734. private _lastSecAccumulated;
  33735. private _lastSecTime;
  33736. private _lastSecValueCount;
  33737. }
  33738. }
  33739. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33740. module "babylonjs/Engines/thinEngine" {
  33741. interface ThinEngine {
  33742. /**
  33743. * Sets alpha constants used by some alpha blending modes
  33744. * @param r defines the red component
  33745. * @param g defines the green component
  33746. * @param b defines the blue component
  33747. * @param a defines the alpha component
  33748. */
  33749. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33750. /**
  33751. * Sets the current alpha mode
  33752. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33753. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33754. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33755. */
  33756. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33757. /**
  33758. * Gets the current alpha mode
  33759. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33760. * @returns the current alpha mode
  33761. */
  33762. getAlphaMode(): number;
  33763. /**
  33764. * Sets the current alpha equation
  33765. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33766. */
  33767. setAlphaEquation(equation: number): void;
  33768. /**
  33769. * Gets the current alpha equation.
  33770. * @returns the current alpha equation
  33771. */
  33772. getAlphaEquation(): number;
  33773. }
  33774. }
  33775. }
  33776. declare module "babylonjs/Engines/engine" {
  33777. import { Observable } from "babylonjs/Misc/observable";
  33778. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33779. import { Scene } from "babylonjs/scene";
  33780. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33781. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33782. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33783. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33784. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33785. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33786. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33787. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33788. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33789. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33790. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33791. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33792. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33793. import "babylonjs/Engines/Extensions/engine.alpha";
  33794. import { Material } from "babylonjs/Materials/material";
  33795. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33796. /**
  33797. * Defines the interface used by display changed events
  33798. */
  33799. export interface IDisplayChangedEventArgs {
  33800. /** Gets the vrDisplay object (if any) */
  33801. vrDisplay: Nullable<any>;
  33802. /** Gets a boolean indicating if webVR is supported */
  33803. vrSupported: boolean;
  33804. }
  33805. /**
  33806. * Defines the interface used by objects containing a viewport (like a camera)
  33807. */
  33808. interface IViewportOwnerLike {
  33809. /**
  33810. * Gets or sets the viewport
  33811. */
  33812. viewport: IViewportLike;
  33813. }
  33814. /**
  33815. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33816. */
  33817. export class Engine extends ThinEngine {
  33818. /** Defines that alpha blending is disabled */
  33819. static readonly ALPHA_DISABLE: number;
  33820. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33821. static readonly ALPHA_ADD: number;
  33822. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33823. static readonly ALPHA_COMBINE: number;
  33824. /** Defines that alpha blending to DEST - SRC * DEST */
  33825. static readonly ALPHA_SUBTRACT: number;
  33826. /** Defines that alpha blending to SRC * DEST */
  33827. static readonly ALPHA_MULTIPLY: number;
  33828. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33829. static readonly ALPHA_MAXIMIZED: number;
  33830. /** Defines that alpha blending to SRC + DEST */
  33831. static readonly ALPHA_ONEONE: number;
  33832. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33833. static readonly ALPHA_PREMULTIPLIED: number;
  33834. /**
  33835. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33836. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33837. */
  33838. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33839. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33840. static readonly ALPHA_INTERPOLATE: number;
  33841. /**
  33842. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33843. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33844. */
  33845. static readonly ALPHA_SCREENMODE: number;
  33846. /** Defines that the ressource is not delayed*/
  33847. static readonly DELAYLOADSTATE_NONE: number;
  33848. /** Defines that the ressource was successfully delay loaded */
  33849. static readonly DELAYLOADSTATE_LOADED: number;
  33850. /** Defines that the ressource is currently delay loading */
  33851. static readonly DELAYLOADSTATE_LOADING: number;
  33852. /** Defines that the ressource is delayed and has not started loading */
  33853. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33854. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33855. static readonly NEVER: number;
  33856. /** 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 */
  33857. static readonly ALWAYS: number;
  33858. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33859. static readonly LESS: number;
  33860. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33861. static readonly EQUAL: number;
  33862. /** 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 */
  33863. static readonly LEQUAL: number;
  33864. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33865. static readonly GREATER: number;
  33866. /** 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 */
  33867. static readonly GEQUAL: number;
  33868. /** 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 */
  33869. static readonly NOTEQUAL: number;
  33870. /** Passed to stencilOperation to specify that stencil value must be kept */
  33871. static readonly KEEP: number;
  33872. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33873. static readonly REPLACE: number;
  33874. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33875. static readonly INCR: number;
  33876. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33877. static readonly DECR: number;
  33878. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33879. static readonly INVERT: number;
  33880. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33881. static readonly INCR_WRAP: number;
  33882. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33883. static readonly DECR_WRAP: number;
  33884. /** Texture is not repeating outside of 0..1 UVs */
  33885. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33886. /** Texture is repeating outside of 0..1 UVs */
  33887. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33888. /** Texture is repeating and mirrored */
  33889. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33890. /** ALPHA */
  33891. static readonly TEXTUREFORMAT_ALPHA: number;
  33892. /** LUMINANCE */
  33893. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33894. /** LUMINANCE_ALPHA */
  33895. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33896. /** RGB */
  33897. static readonly TEXTUREFORMAT_RGB: number;
  33898. /** RGBA */
  33899. static readonly TEXTUREFORMAT_RGBA: number;
  33900. /** RED */
  33901. static readonly TEXTUREFORMAT_RED: number;
  33902. /** RED (2nd reference) */
  33903. static readonly TEXTUREFORMAT_R: number;
  33904. /** RG */
  33905. static readonly TEXTUREFORMAT_RG: number;
  33906. /** RED_INTEGER */
  33907. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33908. /** RED_INTEGER (2nd reference) */
  33909. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33910. /** RG_INTEGER */
  33911. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33912. /** RGB_INTEGER */
  33913. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33914. /** RGBA_INTEGER */
  33915. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33916. /** UNSIGNED_BYTE */
  33917. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33918. /** UNSIGNED_BYTE (2nd reference) */
  33919. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33920. /** FLOAT */
  33921. static readonly TEXTURETYPE_FLOAT: number;
  33922. /** HALF_FLOAT */
  33923. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33924. /** BYTE */
  33925. static readonly TEXTURETYPE_BYTE: number;
  33926. /** SHORT */
  33927. static readonly TEXTURETYPE_SHORT: number;
  33928. /** UNSIGNED_SHORT */
  33929. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33930. /** INT */
  33931. static readonly TEXTURETYPE_INT: number;
  33932. /** UNSIGNED_INT */
  33933. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33934. /** UNSIGNED_SHORT_4_4_4_4 */
  33935. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33936. /** UNSIGNED_SHORT_5_5_5_1 */
  33937. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33938. /** UNSIGNED_SHORT_5_6_5 */
  33939. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33940. /** UNSIGNED_INT_2_10_10_10_REV */
  33941. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33942. /** UNSIGNED_INT_24_8 */
  33943. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33944. /** UNSIGNED_INT_10F_11F_11F_REV */
  33945. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33946. /** UNSIGNED_INT_5_9_9_9_REV */
  33947. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33948. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33949. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33950. /** nearest is mag = nearest and min = nearest and mip = linear */
  33951. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33952. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33953. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33954. /** Trilinear is mag = linear and min = linear and mip = linear */
  33955. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33956. /** nearest is mag = nearest and min = nearest and mip = linear */
  33957. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33958. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33959. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33960. /** Trilinear is mag = linear and min = linear and mip = linear */
  33961. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33962. /** mag = nearest and min = nearest and mip = nearest */
  33963. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33964. /** mag = nearest and min = linear and mip = nearest */
  33965. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33966. /** mag = nearest and min = linear and mip = linear */
  33967. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33968. /** mag = nearest and min = linear and mip = none */
  33969. static readonly TEXTURE_NEAREST_LINEAR: number;
  33970. /** mag = nearest and min = nearest and mip = none */
  33971. static readonly TEXTURE_NEAREST_NEAREST: number;
  33972. /** mag = linear and min = nearest and mip = nearest */
  33973. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33974. /** mag = linear and min = nearest and mip = linear */
  33975. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33976. /** mag = linear and min = linear and mip = none */
  33977. static readonly TEXTURE_LINEAR_LINEAR: number;
  33978. /** mag = linear and min = nearest and mip = none */
  33979. static readonly TEXTURE_LINEAR_NEAREST: number;
  33980. /** Explicit coordinates mode */
  33981. static readonly TEXTURE_EXPLICIT_MODE: number;
  33982. /** Spherical coordinates mode */
  33983. static readonly TEXTURE_SPHERICAL_MODE: number;
  33984. /** Planar coordinates mode */
  33985. static readonly TEXTURE_PLANAR_MODE: number;
  33986. /** Cubic coordinates mode */
  33987. static readonly TEXTURE_CUBIC_MODE: number;
  33988. /** Projection coordinates mode */
  33989. static readonly TEXTURE_PROJECTION_MODE: number;
  33990. /** Skybox coordinates mode */
  33991. static readonly TEXTURE_SKYBOX_MODE: number;
  33992. /** Inverse Cubic coordinates mode */
  33993. static readonly TEXTURE_INVCUBIC_MODE: number;
  33994. /** Equirectangular coordinates mode */
  33995. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33996. /** Equirectangular Fixed coordinates mode */
  33997. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33998. /** Equirectangular Fixed Mirrored coordinates mode */
  33999. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34000. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34001. static readonly SCALEMODE_FLOOR: number;
  34002. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34003. static readonly SCALEMODE_NEAREST: number;
  34004. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34005. static readonly SCALEMODE_CEILING: number;
  34006. /**
  34007. * Returns the current npm package of the sdk
  34008. */
  34009. static get NpmPackage(): string;
  34010. /**
  34011. * Returns the current version of the framework
  34012. */
  34013. static get Version(): string;
  34014. /** Gets the list of created engines */
  34015. static get Instances(): Engine[];
  34016. /**
  34017. * Gets the latest created engine
  34018. */
  34019. static get LastCreatedEngine(): Nullable<Engine>;
  34020. /**
  34021. * Gets the latest created scene
  34022. */
  34023. static get LastCreatedScene(): Nullable<Scene>;
  34024. /**
  34025. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34026. * @param flag defines which part of the materials must be marked as dirty
  34027. * @param predicate defines a predicate used to filter which materials should be affected
  34028. */
  34029. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34030. /**
  34031. * Method called to create the default loading screen.
  34032. * This can be overriden in your own app.
  34033. * @param canvas The rendering canvas element
  34034. * @returns The loading screen
  34035. */
  34036. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34037. /**
  34038. * Method called to create the default rescale post process on each engine.
  34039. */
  34040. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34041. /**
  34042. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34043. **/
  34044. enableOfflineSupport: boolean;
  34045. /**
  34046. * 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)
  34047. **/
  34048. disableManifestCheck: boolean;
  34049. /**
  34050. * Gets the list of created scenes
  34051. */
  34052. scenes: Scene[];
  34053. /**
  34054. * Event raised when a new scene is created
  34055. */
  34056. onNewSceneAddedObservable: Observable<Scene>;
  34057. /**
  34058. * Gets the list of created postprocesses
  34059. */
  34060. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34061. /**
  34062. * Gets a boolean indicating if the pointer is currently locked
  34063. */
  34064. isPointerLock: boolean;
  34065. /**
  34066. * Observable event triggered each time the rendering canvas is resized
  34067. */
  34068. onResizeObservable: Observable<Engine>;
  34069. /**
  34070. * Observable event triggered each time the canvas loses focus
  34071. */
  34072. onCanvasBlurObservable: Observable<Engine>;
  34073. /**
  34074. * Observable event triggered each time the canvas gains focus
  34075. */
  34076. onCanvasFocusObservable: Observable<Engine>;
  34077. /**
  34078. * Observable event triggered each time the canvas receives pointerout event
  34079. */
  34080. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34081. /**
  34082. * Observable raised when the engine begins a new frame
  34083. */
  34084. onBeginFrameObservable: Observable<Engine>;
  34085. /**
  34086. * If set, will be used to request the next animation frame for the render loop
  34087. */
  34088. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34089. /**
  34090. * Observable raised when the engine ends the current frame
  34091. */
  34092. onEndFrameObservable: Observable<Engine>;
  34093. /**
  34094. * Observable raised when the engine is about to compile a shader
  34095. */
  34096. onBeforeShaderCompilationObservable: Observable<Engine>;
  34097. /**
  34098. * Observable raised when the engine has jsut compiled a shader
  34099. */
  34100. onAfterShaderCompilationObservable: Observable<Engine>;
  34101. /**
  34102. * Gets the audio engine
  34103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34104. * @ignorenaming
  34105. */
  34106. static audioEngine: IAudioEngine;
  34107. /**
  34108. * Default AudioEngine factory responsible of creating the Audio Engine.
  34109. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34110. */
  34111. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34112. /**
  34113. * Default offline support factory responsible of creating a tool used to store data locally.
  34114. * By default, this will create a Database object if the workload has been embedded.
  34115. */
  34116. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34117. private _loadingScreen;
  34118. private _pointerLockRequested;
  34119. private _dummyFramebuffer;
  34120. private _rescalePostProcess;
  34121. private _deterministicLockstep;
  34122. private _lockstepMaxSteps;
  34123. private _timeStep;
  34124. protected get _supportsHardwareTextureRescaling(): boolean;
  34125. private _fps;
  34126. private _deltaTime;
  34127. /** @hidden */
  34128. _drawCalls: PerfCounter;
  34129. /**
  34130. * Turn this value on if you want to pause FPS computation when in background
  34131. */
  34132. disablePerformanceMonitorInBackground: boolean;
  34133. private _performanceMonitor;
  34134. /**
  34135. * Gets the performance monitor attached to this engine
  34136. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34137. */
  34138. get performanceMonitor(): PerformanceMonitor;
  34139. private _onFocus;
  34140. private _onBlur;
  34141. private _onCanvasPointerOut;
  34142. private _onCanvasBlur;
  34143. private _onCanvasFocus;
  34144. private _onFullscreenChange;
  34145. private _onPointerLockChange;
  34146. /**
  34147. * Gets the HTML element used to attach event listeners
  34148. * @returns a HTML element
  34149. */
  34150. getInputElement(): Nullable<HTMLElement>;
  34151. /**
  34152. * Creates a new engine
  34153. * @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
  34154. * @param antialias defines enable antialiasing (default: false)
  34155. * @param options defines further options to be sent to the getContext() function
  34156. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34157. */
  34158. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34159. /**
  34160. * Gets current aspect ratio
  34161. * @param viewportOwner defines the camera to use to get the aspect ratio
  34162. * @param useScreen defines if screen size must be used (or the current render target if any)
  34163. * @returns a number defining the aspect ratio
  34164. */
  34165. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34166. /**
  34167. * Gets current screen aspect ratio
  34168. * @returns a number defining the aspect ratio
  34169. */
  34170. getScreenAspectRatio(): number;
  34171. /**
  34172. * Gets the client rect of the HTML canvas attached with the current webGL context
  34173. * @returns a client rectanglee
  34174. */
  34175. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34176. /**
  34177. * Gets the client rect of the HTML element used for events
  34178. * @returns a client rectanglee
  34179. */
  34180. getInputElementClientRect(): Nullable<ClientRect>;
  34181. /**
  34182. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34183. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34184. * @returns true if engine is in deterministic lock step mode
  34185. */
  34186. isDeterministicLockStep(): boolean;
  34187. /**
  34188. * Gets the max steps when engine is running in deterministic lock step
  34189. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34190. * @returns the max steps
  34191. */
  34192. getLockstepMaxSteps(): number;
  34193. /**
  34194. * Returns the time in ms between steps when using deterministic lock step.
  34195. * @returns time step in (ms)
  34196. */
  34197. getTimeStep(): number;
  34198. /**
  34199. * Force the mipmap generation for the given render target texture
  34200. * @param texture defines the render target texture to use
  34201. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34202. */
  34203. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34204. /** States */
  34205. /**
  34206. * Set various states to the webGL context
  34207. * @param culling defines backface culling state
  34208. * @param zOffset defines the value to apply to zOffset (0 by default)
  34209. * @param force defines if states must be applied even if cache is up to date
  34210. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34211. */
  34212. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34213. /**
  34214. * Set the z offset to apply to current rendering
  34215. * @param value defines the offset to apply
  34216. */
  34217. setZOffset(value: number): void;
  34218. /**
  34219. * Gets the current value of the zOffset
  34220. * @returns the current zOffset state
  34221. */
  34222. getZOffset(): number;
  34223. /**
  34224. * Enable or disable depth buffering
  34225. * @param enable defines the state to set
  34226. */
  34227. setDepthBuffer(enable: boolean): void;
  34228. /**
  34229. * Gets a boolean indicating if depth writing is enabled
  34230. * @returns the current depth writing state
  34231. */
  34232. getDepthWrite(): boolean;
  34233. /**
  34234. * Enable or disable depth writing
  34235. * @param enable defines the state to set
  34236. */
  34237. setDepthWrite(enable: boolean): void;
  34238. /**
  34239. * Gets a boolean indicating if stencil buffer is enabled
  34240. * @returns the current stencil buffer state
  34241. */
  34242. getStencilBuffer(): boolean;
  34243. /**
  34244. * Enable or disable the stencil buffer
  34245. * @param enable defines if the stencil buffer must be enabled or disabled
  34246. */
  34247. setStencilBuffer(enable: boolean): void;
  34248. /**
  34249. * Gets the current stencil mask
  34250. * @returns a number defining the new stencil mask to use
  34251. */
  34252. getStencilMask(): number;
  34253. /**
  34254. * Sets the current stencil mask
  34255. * @param mask defines the new stencil mask to use
  34256. */
  34257. setStencilMask(mask: number): void;
  34258. /**
  34259. * Gets the current stencil function
  34260. * @returns a number defining the stencil function to use
  34261. */
  34262. getStencilFunction(): number;
  34263. /**
  34264. * Gets the current stencil reference value
  34265. * @returns a number defining the stencil reference value to use
  34266. */
  34267. getStencilFunctionReference(): number;
  34268. /**
  34269. * Gets the current stencil mask
  34270. * @returns a number defining the stencil mask to use
  34271. */
  34272. getStencilFunctionMask(): number;
  34273. /**
  34274. * Sets the current stencil function
  34275. * @param stencilFunc defines the new stencil function to use
  34276. */
  34277. setStencilFunction(stencilFunc: number): void;
  34278. /**
  34279. * Sets the current stencil reference
  34280. * @param reference defines the new stencil reference to use
  34281. */
  34282. setStencilFunctionReference(reference: number): void;
  34283. /**
  34284. * Sets the current stencil mask
  34285. * @param mask defines the new stencil mask to use
  34286. */
  34287. setStencilFunctionMask(mask: number): void;
  34288. /**
  34289. * Gets the current stencil operation when stencil fails
  34290. * @returns a number defining stencil operation to use when stencil fails
  34291. */
  34292. getStencilOperationFail(): number;
  34293. /**
  34294. * Gets the current stencil operation when depth fails
  34295. * @returns a number defining stencil operation to use when depth fails
  34296. */
  34297. getStencilOperationDepthFail(): number;
  34298. /**
  34299. * Gets the current stencil operation when stencil passes
  34300. * @returns a number defining stencil operation to use when stencil passes
  34301. */
  34302. getStencilOperationPass(): number;
  34303. /**
  34304. * Sets the stencil operation to use when stencil fails
  34305. * @param operation defines the stencil operation to use when stencil fails
  34306. */
  34307. setStencilOperationFail(operation: number): void;
  34308. /**
  34309. * Sets the stencil operation to use when depth fails
  34310. * @param operation defines the stencil operation to use when depth fails
  34311. */
  34312. setStencilOperationDepthFail(operation: number): void;
  34313. /**
  34314. * Sets the stencil operation to use when stencil passes
  34315. * @param operation defines the stencil operation to use when stencil passes
  34316. */
  34317. setStencilOperationPass(operation: number): void;
  34318. /**
  34319. * Sets a boolean indicating if the dithering state is enabled or disabled
  34320. * @param value defines the dithering state
  34321. */
  34322. setDitheringState(value: boolean): void;
  34323. /**
  34324. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34325. * @param value defines the rasterizer state
  34326. */
  34327. setRasterizerState(value: boolean): void;
  34328. /**
  34329. * Gets the current depth function
  34330. * @returns a number defining the depth function
  34331. */
  34332. getDepthFunction(): Nullable<number>;
  34333. /**
  34334. * Sets the current depth function
  34335. * @param depthFunc defines the function to use
  34336. */
  34337. setDepthFunction(depthFunc: number): void;
  34338. /**
  34339. * Sets the current depth function to GREATER
  34340. */
  34341. setDepthFunctionToGreater(): void;
  34342. /**
  34343. * Sets the current depth function to GEQUAL
  34344. */
  34345. setDepthFunctionToGreaterOrEqual(): void;
  34346. /**
  34347. * Sets the current depth function to LESS
  34348. */
  34349. setDepthFunctionToLess(): void;
  34350. /**
  34351. * Sets the current depth function to LEQUAL
  34352. */
  34353. setDepthFunctionToLessOrEqual(): void;
  34354. private _cachedStencilBuffer;
  34355. private _cachedStencilFunction;
  34356. private _cachedStencilMask;
  34357. private _cachedStencilOperationPass;
  34358. private _cachedStencilOperationFail;
  34359. private _cachedStencilOperationDepthFail;
  34360. private _cachedStencilReference;
  34361. /**
  34362. * Caches the the state of the stencil buffer
  34363. */
  34364. cacheStencilState(): void;
  34365. /**
  34366. * Restores the state of the stencil buffer
  34367. */
  34368. restoreStencilState(): void;
  34369. /**
  34370. * Directly set the WebGL Viewport
  34371. * @param x defines the x coordinate of the viewport (in screen space)
  34372. * @param y defines the y coordinate of the viewport (in screen space)
  34373. * @param width defines the width of the viewport (in screen space)
  34374. * @param height defines the height of the viewport (in screen space)
  34375. * @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
  34376. */
  34377. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34378. /**
  34379. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34380. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34381. * @param y defines the y-coordinate of the corner of the clear rectangle
  34382. * @param width defines the width of the clear rectangle
  34383. * @param height defines the height of the clear rectangle
  34384. * @param clearColor defines the clear color
  34385. */
  34386. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34387. /**
  34388. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34389. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34390. * @param y defines the y-coordinate of the corner of the clear rectangle
  34391. * @param width defines the width of the clear rectangle
  34392. * @param height defines the height of the clear rectangle
  34393. */
  34394. enableScissor(x: number, y: number, width: number, height: number): void;
  34395. /**
  34396. * Disable previously set scissor test rectangle
  34397. */
  34398. disableScissor(): void;
  34399. protected _reportDrawCall(): void;
  34400. /**
  34401. * Initializes a webVR display and starts listening to display change events
  34402. * The onVRDisplayChangedObservable will be notified upon these changes
  34403. * @returns The onVRDisplayChangedObservable
  34404. */
  34405. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34406. /** @hidden */
  34407. _prepareVRComponent(): void;
  34408. /** @hidden */
  34409. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34410. /** @hidden */
  34411. _submitVRFrame(): void;
  34412. /**
  34413. * Call this function to leave webVR mode
  34414. * Will do nothing if webVR is not supported or if there is no webVR device
  34415. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34416. */
  34417. disableVR(): void;
  34418. /**
  34419. * Gets a boolean indicating that the system is in VR mode and is presenting
  34420. * @returns true if VR mode is engaged
  34421. */
  34422. isVRPresenting(): boolean;
  34423. /** @hidden */
  34424. _requestVRFrame(): void;
  34425. /** @hidden */
  34426. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34427. /**
  34428. * Gets the source code of the vertex shader associated with a specific webGL program
  34429. * @param program defines the program to use
  34430. * @returns a string containing the source code of the vertex shader associated with the program
  34431. */
  34432. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34433. /**
  34434. * Gets the source code of the fragment shader associated with a specific webGL program
  34435. * @param program defines the program to use
  34436. * @returns a string containing the source code of the fragment shader associated with the program
  34437. */
  34438. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34439. /**
  34440. * Sets a depth stencil texture from a render target to the according uniform.
  34441. * @param channel The texture channel
  34442. * @param uniform The uniform to set
  34443. * @param texture The render target texture containing the depth stencil texture to apply
  34444. */
  34445. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34446. /**
  34447. * Sets a texture to the webGL context from a postprocess
  34448. * @param channel defines the channel to use
  34449. * @param postProcess defines the source postprocess
  34450. */
  34451. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34452. /**
  34453. * Binds the output of the passed in post process to the texture channel specified
  34454. * @param channel The channel the texture should be bound to
  34455. * @param postProcess The post process which's output should be bound
  34456. */
  34457. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34458. /** @hidden */
  34459. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34460. protected _rebuildBuffers(): void;
  34461. /** @hidden */
  34462. _renderFrame(): void;
  34463. _renderLoop(): void;
  34464. /** @hidden */
  34465. _renderViews(): boolean;
  34466. /**
  34467. * Toggle full screen mode
  34468. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34469. */
  34470. switchFullscreen(requestPointerLock: boolean): void;
  34471. /**
  34472. * Enters full screen mode
  34473. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34474. */
  34475. enterFullscreen(requestPointerLock: boolean): void;
  34476. /**
  34477. * Exits full screen mode
  34478. */
  34479. exitFullscreen(): void;
  34480. /**
  34481. * Enters Pointerlock mode
  34482. */
  34483. enterPointerlock(): void;
  34484. /**
  34485. * Exits Pointerlock mode
  34486. */
  34487. exitPointerlock(): void;
  34488. /**
  34489. * Begin a new frame
  34490. */
  34491. beginFrame(): void;
  34492. /**
  34493. * Enf the current frame
  34494. */
  34495. endFrame(): void;
  34496. resize(): void;
  34497. /**
  34498. * Set the compressed texture format to use, based on the formats you have, and the formats
  34499. * supported by the hardware / browser.
  34500. *
  34501. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34502. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34503. * to API arguments needed to compressed textures. This puts the burden on the container
  34504. * generator to house the arcane code for determining these for current & future formats.
  34505. *
  34506. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34507. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34508. *
  34509. * Note: The result of this call is not taken into account when a texture is base64.
  34510. *
  34511. * @param formatsAvailable defines the list of those format families you have created
  34512. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34513. *
  34514. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34515. * @returns The extension selected.
  34516. */
  34517. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34518. /**
  34519. * Set the compressed texture extensions or file names to skip.
  34520. *
  34521. * @param skippedFiles defines the list of those texture files you want to skip
  34522. * Example: [".dds", ".env", "myfile.png"]
  34523. */
  34524. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34525. /**
  34526. * Force a specific size of the canvas
  34527. * @param width defines the new canvas' width
  34528. * @param height defines the new canvas' height
  34529. */
  34530. setSize(width: number, height: number): void;
  34531. /**
  34532. * Updates a dynamic vertex buffer.
  34533. * @param vertexBuffer the vertex buffer to update
  34534. * @param data the data used to update the vertex buffer
  34535. * @param byteOffset the byte offset of the data
  34536. * @param byteLength the byte length of the data
  34537. */
  34538. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34539. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34540. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34541. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34542. _releaseTexture(texture: InternalTexture): void;
  34543. /**
  34544. * @hidden
  34545. * Rescales a texture
  34546. * @param source input texutre
  34547. * @param destination destination texture
  34548. * @param scene scene to use to render the resize
  34549. * @param internalFormat format to use when resizing
  34550. * @param onComplete callback to be called when resize has completed
  34551. */
  34552. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34553. /**
  34554. * Gets the current framerate
  34555. * @returns a number representing the framerate
  34556. */
  34557. getFps(): number;
  34558. /**
  34559. * Gets the time spent between current and previous frame
  34560. * @returns a number representing the delta time in ms
  34561. */
  34562. getDeltaTime(): number;
  34563. private _measureFps;
  34564. /** @hidden */
  34565. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34566. /**
  34567. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34568. * @param renderTarget The render target to set the frame buffer for
  34569. */
  34570. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34571. /**
  34572. * Update a dynamic index buffer
  34573. * @param indexBuffer defines the target index buffer
  34574. * @param indices defines the data to update
  34575. * @param offset defines the offset in the target index buffer where update should start
  34576. */
  34577. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34578. /**
  34579. * Updates the sample count of a render target texture
  34580. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34581. * @param texture defines the texture to update
  34582. * @param samples defines the sample count to set
  34583. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34584. */
  34585. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34586. /**
  34587. * Updates a depth texture Comparison Mode and Function.
  34588. * If the comparison Function is equal to 0, the mode will be set to none.
  34589. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34590. * @param texture The texture to set the comparison function for
  34591. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34592. */
  34593. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34594. /**
  34595. * Creates a webGL buffer to use with instanciation
  34596. * @param capacity defines the size of the buffer
  34597. * @returns the webGL buffer
  34598. */
  34599. createInstancesBuffer(capacity: number): DataBuffer;
  34600. /**
  34601. * Delete a webGL buffer used with instanciation
  34602. * @param buffer defines the webGL buffer to delete
  34603. */
  34604. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34605. /** @hidden */
  34606. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34607. dispose(): void;
  34608. private _disableTouchAction;
  34609. /**
  34610. * Display the loading screen
  34611. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34612. */
  34613. displayLoadingUI(): void;
  34614. /**
  34615. * Hide the loading screen
  34616. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34617. */
  34618. hideLoadingUI(): void;
  34619. /**
  34620. * Gets the current loading screen object
  34621. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34622. */
  34623. get loadingScreen(): ILoadingScreen;
  34624. /**
  34625. * Sets the current loading screen object
  34626. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34627. */
  34628. set loadingScreen(loadingScreen: ILoadingScreen);
  34629. /**
  34630. * Sets the current loading screen text
  34631. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34632. */
  34633. set loadingUIText(text: string);
  34634. /**
  34635. * Sets the current loading screen background color
  34636. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34637. */
  34638. set loadingUIBackgroundColor(color: string);
  34639. /** Pointerlock and fullscreen */
  34640. /**
  34641. * Ask the browser to promote the current element to pointerlock mode
  34642. * @param element defines the DOM element to promote
  34643. */
  34644. static _RequestPointerlock(element: HTMLElement): void;
  34645. /**
  34646. * Asks the browser to exit pointerlock mode
  34647. */
  34648. static _ExitPointerlock(): void;
  34649. /**
  34650. * Ask the browser to promote the current element to fullscreen rendering mode
  34651. * @param element defines the DOM element to promote
  34652. */
  34653. static _RequestFullscreen(element: HTMLElement): void;
  34654. /**
  34655. * Asks the browser to exit fullscreen mode
  34656. */
  34657. static _ExitFullscreen(): void;
  34658. }
  34659. }
  34660. declare module "babylonjs/Engines/engineStore" {
  34661. import { Nullable } from "babylonjs/types";
  34662. import { Engine } from "babylonjs/Engines/engine";
  34663. import { Scene } from "babylonjs/scene";
  34664. /**
  34665. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34666. * during the life time of the application.
  34667. */
  34668. export class EngineStore {
  34669. /** Gets the list of created engines */
  34670. static Instances: import("babylonjs/Engines/engine").Engine[];
  34671. /** @hidden */
  34672. static _LastCreatedScene: Nullable<Scene>;
  34673. /**
  34674. * Gets the latest created engine
  34675. */
  34676. static get LastCreatedEngine(): Nullable<Engine>;
  34677. /**
  34678. * Gets the latest created scene
  34679. */
  34680. static get LastCreatedScene(): Nullable<Scene>;
  34681. /**
  34682. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34683. * @ignorenaming
  34684. */
  34685. static UseFallbackTexture: boolean;
  34686. /**
  34687. * Texture content used if a texture cannot loaded
  34688. * @ignorenaming
  34689. */
  34690. static FallbackTexture: string;
  34691. }
  34692. }
  34693. declare module "babylonjs/Misc/promise" {
  34694. /**
  34695. * Helper class that provides a small promise polyfill
  34696. */
  34697. export class PromisePolyfill {
  34698. /**
  34699. * Static function used to check if the polyfill is required
  34700. * If this is the case then the function will inject the polyfill to window.Promise
  34701. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34702. */
  34703. static Apply(force?: boolean): void;
  34704. }
  34705. }
  34706. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34707. /**
  34708. * Interface for screenshot methods with describe argument called `size` as object with options
  34709. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34710. */
  34711. export interface IScreenshotSize {
  34712. /**
  34713. * number in pixels for canvas height
  34714. */
  34715. height?: number;
  34716. /**
  34717. * multiplier allowing render at a higher or lower resolution
  34718. * If value is defined then height and width will be ignored and taken from camera
  34719. */
  34720. precision?: number;
  34721. /**
  34722. * number in pixels for canvas width
  34723. */
  34724. width?: number;
  34725. }
  34726. }
  34727. declare module "babylonjs/Misc/tools" {
  34728. import { Nullable, float } from "babylonjs/types";
  34729. import { DomManagement } from "babylonjs/Misc/domManagement";
  34730. import { WebRequest } from "babylonjs/Misc/webRequest";
  34731. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34732. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34733. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34734. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34735. import { Camera } from "babylonjs/Cameras/camera";
  34736. import { Engine } from "babylonjs/Engines/engine";
  34737. interface IColor4Like {
  34738. r: float;
  34739. g: float;
  34740. b: float;
  34741. a: float;
  34742. }
  34743. /**
  34744. * Class containing a set of static utilities functions
  34745. */
  34746. export class Tools {
  34747. /**
  34748. * Gets or sets the base URL to use to load assets
  34749. */
  34750. static get BaseUrl(): string;
  34751. static set BaseUrl(value: string);
  34752. /**
  34753. * Enable/Disable Custom HTTP Request Headers globally.
  34754. * default = false
  34755. * @see CustomRequestHeaders
  34756. */
  34757. static UseCustomRequestHeaders: boolean;
  34758. /**
  34759. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34760. * i.e. when loading files, where the server/service expects an Authorization header
  34761. */
  34762. static CustomRequestHeaders: {
  34763. [key: string]: string;
  34764. };
  34765. /**
  34766. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34767. */
  34768. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34769. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34770. /**
  34771. * Default behaviour for cors in the application.
  34772. * It can be a string if the expected behavior is identical in the entire app.
  34773. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34774. */
  34775. static CorsBehavior: string | ((url: string | string[]) => string);
  34776. /**
  34777. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34778. * @ignorenaming
  34779. */
  34780. static get UseFallbackTexture(): boolean;
  34781. static set UseFallbackTexture(value: boolean);
  34782. /**
  34783. * Use this object to register external classes like custom textures or material
  34784. * to allow the laoders to instantiate them
  34785. */
  34786. static get RegisteredExternalClasses(): {
  34787. [key: string]: Object;
  34788. };
  34789. static set RegisteredExternalClasses(classes: {
  34790. [key: string]: Object;
  34791. });
  34792. /**
  34793. * Texture content used if a texture cannot loaded
  34794. * @ignorenaming
  34795. */
  34796. static get fallbackTexture(): string;
  34797. static set fallbackTexture(value: string);
  34798. /**
  34799. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34800. * @param u defines the coordinate on X axis
  34801. * @param v defines the coordinate on Y axis
  34802. * @param width defines the width of the source data
  34803. * @param height defines the height of the source data
  34804. * @param pixels defines the source byte array
  34805. * @param color defines the output color
  34806. */
  34807. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34808. /**
  34809. * Interpolates between a and b via alpha
  34810. * @param a The lower value (returned when alpha = 0)
  34811. * @param b The upper value (returned when alpha = 1)
  34812. * @param alpha The interpolation-factor
  34813. * @return The mixed value
  34814. */
  34815. static Mix(a: number, b: number, alpha: number): number;
  34816. /**
  34817. * Tries to instantiate a new object from a given class name
  34818. * @param className defines the class name to instantiate
  34819. * @returns the new object or null if the system was not able to do the instantiation
  34820. */
  34821. static Instantiate(className: string): any;
  34822. /**
  34823. * Provides a slice function that will work even on IE
  34824. * @param data defines the array to slice
  34825. * @param start defines the start of the data (optional)
  34826. * @param end defines the end of the data (optional)
  34827. * @returns the new sliced array
  34828. */
  34829. static Slice<T>(data: T, start?: number, end?: number): T;
  34830. /**
  34831. * Polyfill for setImmediate
  34832. * @param action defines the action to execute after the current execution block
  34833. */
  34834. static SetImmediate(action: () => void): void;
  34835. /**
  34836. * Function indicating if a number is an exponent of 2
  34837. * @param value defines the value to test
  34838. * @returns true if the value is an exponent of 2
  34839. */
  34840. static IsExponentOfTwo(value: number): boolean;
  34841. private static _tmpFloatArray;
  34842. /**
  34843. * Returns the nearest 32-bit single precision float representation of a Number
  34844. * @param value A Number. If the parameter is of a different type, it will get converted
  34845. * to a number or to NaN if it cannot be converted
  34846. * @returns number
  34847. */
  34848. static FloatRound(value: number): number;
  34849. /**
  34850. * Extracts the filename from a path
  34851. * @param path defines the path to use
  34852. * @returns the filename
  34853. */
  34854. static GetFilename(path: string): string;
  34855. /**
  34856. * Extracts the "folder" part of a path (everything before the filename).
  34857. * @param uri The URI to extract the info from
  34858. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34859. * @returns The "folder" part of the path
  34860. */
  34861. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34862. /**
  34863. * Extracts text content from a DOM element hierarchy
  34864. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34865. */
  34866. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34867. /**
  34868. * Convert an angle in radians to degrees
  34869. * @param angle defines the angle to convert
  34870. * @returns the angle in degrees
  34871. */
  34872. static ToDegrees(angle: number): number;
  34873. /**
  34874. * Convert an angle in degrees to radians
  34875. * @param angle defines the angle to convert
  34876. * @returns the angle in radians
  34877. */
  34878. static ToRadians(angle: number): number;
  34879. /**
  34880. * Returns an array if obj is not an array
  34881. * @param obj defines the object to evaluate as an array
  34882. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34883. * @returns either obj directly if obj is an array or a new array containing obj
  34884. */
  34885. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34886. /**
  34887. * Gets the pointer prefix to use
  34888. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34889. */
  34890. static GetPointerPrefix(): string;
  34891. /**
  34892. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34893. * @param url define the url we are trying
  34894. * @param element define the dom element where to configure the cors policy
  34895. */
  34896. static SetCorsBehavior(url: string | string[], element: {
  34897. crossOrigin: string | null;
  34898. }): void;
  34899. /**
  34900. * Removes unwanted characters from an url
  34901. * @param url defines the url to clean
  34902. * @returns the cleaned url
  34903. */
  34904. static CleanUrl(url: string): string;
  34905. /**
  34906. * Gets or sets a function used to pre-process url before using them to load assets
  34907. */
  34908. static get PreprocessUrl(): (url: string) => string;
  34909. static set PreprocessUrl(processor: (url: string) => string);
  34910. /**
  34911. * Loads an image as an HTMLImageElement.
  34912. * @param input url string, ArrayBuffer, or Blob to load
  34913. * @param onLoad callback called when the image successfully loads
  34914. * @param onError callback called when the image fails to load
  34915. * @param offlineProvider offline provider for caching
  34916. * @param mimeType optional mime type
  34917. * @returns the HTMLImageElement of the loaded image
  34918. */
  34919. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34920. /**
  34921. * Loads a file from a url
  34922. * @param url url string, ArrayBuffer, or Blob to load
  34923. * @param onSuccess callback called when the file successfully loads
  34924. * @param onProgress callback called while file is loading (if the server supports this mode)
  34925. * @param offlineProvider defines the offline provider for caching
  34926. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34927. * @param onError callback called when the file fails to load
  34928. * @returns a file request object
  34929. */
  34930. 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;
  34931. /**
  34932. * Loads a file from a url
  34933. * @param url the file url to load
  34934. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34935. */
  34936. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34937. /**
  34938. * Load a script (identified by an url). When the url returns, the
  34939. * content of this file is added into a new script element, attached to the DOM (body element)
  34940. * @param scriptUrl defines the url of the script to laod
  34941. * @param onSuccess defines the callback called when the script is loaded
  34942. * @param onError defines the callback to call if an error occurs
  34943. * @param scriptId defines the id of the script element
  34944. */
  34945. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34946. /**
  34947. * Load an asynchronous script (identified by an url). When the url returns, the
  34948. * content of this file is added into a new script element, attached to the DOM (body element)
  34949. * @param scriptUrl defines the url of the script to laod
  34950. * @param scriptId defines the id of the script element
  34951. * @returns a promise request object
  34952. */
  34953. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34954. /**
  34955. * Loads a file from a blob
  34956. * @param fileToLoad defines the blob to use
  34957. * @param callback defines the callback to call when data is loaded
  34958. * @param progressCallback defines the callback to call during loading process
  34959. * @returns a file request object
  34960. */
  34961. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34962. /**
  34963. * Reads a file from a File object
  34964. * @param file defines the file to load
  34965. * @param onSuccess defines the callback to call when data is loaded
  34966. * @param onProgress defines the callback to call during loading process
  34967. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34968. * @param onError defines the callback to call when an error occurs
  34969. * @returns a file request object
  34970. */
  34971. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34972. /**
  34973. * Creates a data url from a given string content
  34974. * @param content defines the content to convert
  34975. * @returns the new data url link
  34976. */
  34977. static FileAsURL(content: string): string;
  34978. /**
  34979. * Format the given number to a specific decimal format
  34980. * @param value defines the number to format
  34981. * @param decimals defines the number of decimals to use
  34982. * @returns the formatted string
  34983. */
  34984. static Format(value: number, decimals?: number): string;
  34985. /**
  34986. * Tries to copy an object by duplicating every property
  34987. * @param source defines the source object
  34988. * @param destination defines the target object
  34989. * @param doNotCopyList defines a list of properties to avoid
  34990. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34991. */
  34992. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34993. /**
  34994. * Gets a boolean indicating if the given object has no own property
  34995. * @param obj defines the object to test
  34996. * @returns true if object has no own property
  34997. */
  34998. static IsEmpty(obj: any): boolean;
  34999. /**
  35000. * Function used to register events at window level
  35001. * @param windowElement defines the Window object to use
  35002. * @param events defines the events to register
  35003. */
  35004. static RegisterTopRootEvents(windowElement: Window, events: {
  35005. name: string;
  35006. handler: Nullable<(e: FocusEvent) => any>;
  35007. }[]): void;
  35008. /**
  35009. * Function used to unregister events from window level
  35010. * @param windowElement defines the Window object to use
  35011. * @param events defines the events to unregister
  35012. */
  35013. static UnregisterTopRootEvents(windowElement: Window, events: {
  35014. name: string;
  35015. handler: Nullable<(e: FocusEvent) => any>;
  35016. }[]): void;
  35017. /**
  35018. * @ignore
  35019. */
  35020. static _ScreenshotCanvas: HTMLCanvasElement;
  35021. /**
  35022. * Dumps the current bound framebuffer
  35023. * @param width defines the rendering width
  35024. * @param height defines the rendering height
  35025. * @param engine defines the hosting engine
  35026. * @param successCallback defines the callback triggered once the data are available
  35027. * @param mimeType defines the mime type of the result
  35028. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35029. */
  35030. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35031. /**
  35032. * Converts the canvas data to blob.
  35033. * This acts as a polyfill for browsers not supporting the to blob function.
  35034. * @param canvas Defines the canvas to extract the data from
  35035. * @param successCallback Defines the callback triggered once the data are available
  35036. * @param mimeType Defines the mime type of the result
  35037. */
  35038. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35039. /**
  35040. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35041. * @param successCallback defines the callback triggered once the data are available
  35042. * @param mimeType defines the mime type of the result
  35043. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35044. */
  35045. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35046. /**
  35047. * Downloads a blob in the browser
  35048. * @param blob defines the blob to download
  35049. * @param fileName defines the name of the downloaded file
  35050. */
  35051. static Download(blob: Blob, fileName: string): void;
  35052. /**
  35053. * Captures a screenshot of the current rendering
  35054. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35055. * @param engine defines the rendering engine
  35056. * @param camera defines the source camera
  35057. * @param size This parameter can be set to a single number or to an object with the
  35058. * following (optional) properties: precision, width, height. If a single number is passed,
  35059. * it will be used for both width and height. If an object is passed, the screenshot size
  35060. * will be derived from the parameters. The precision property is a multiplier allowing
  35061. * rendering at a higher or lower resolution
  35062. * @param successCallback defines the callback receives a single parameter which contains the
  35063. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35064. * src parameter of an <img> to display it
  35065. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35066. * Check your browser for supported MIME types
  35067. */
  35068. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35069. /**
  35070. * Captures a screenshot of the current rendering
  35071. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35072. * @param engine defines the rendering engine
  35073. * @param camera defines the source camera
  35074. * @param size This parameter can be set to a single number or to an object with the
  35075. * following (optional) properties: precision, width, height. If a single number is passed,
  35076. * it will be used for both width and height. If an object is passed, the screenshot size
  35077. * will be derived from the parameters. The precision property is a multiplier allowing
  35078. * rendering at a higher or lower resolution
  35079. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35080. * Check your browser for supported MIME types
  35081. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35082. * to the src parameter of an <img> to display it
  35083. */
  35084. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35085. /**
  35086. * Generates an image screenshot from the specified camera.
  35087. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35088. * @param engine The engine to use for rendering
  35089. * @param camera The camera to use for rendering
  35090. * @param size This parameter can be set to a single number or to an object with the
  35091. * following (optional) properties: precision, width, height. If a single number is passed,
  35092. * it will be used for both width and height. If an object is passed, the screenshot size
  35093. * will be derived from the parameters. The precision property is a multiplier allowing
  35094. * rendering at a higher or lower resolution
  35095. * @param successCallback The callback receives a single parameter which contains the
  35096. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35097. * src parameter of an <img> to display it
  35098. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35099. * Check your browser for supported MIME types
  35100. * @param samples Texture samples (default: 1)
  35101. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35102. * @param fileName A name for for the downloaded file.
  35103. */
  35104. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35105. /**
  35106. * Generates an image screenshot from the specified camera.
  35107. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35108. * @param engine The engine to use for rendering
  35109. * @param camera The camera to use for rendering
  35110. * @param size This parameter can be set to a single number or to an object with the
  35111. * following (optional) properties: precision, width, height. If a single number is passed,
  35112. * it will be used for both width and height. If an object is passed, the screenshot size
  35113. * will be derived from the parameters. The precision property is a multiplier allowing
  35114. * rendering at a higher or lower resolution
  35115. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35116. * Check your browser for supported MIME types
  35117. * @param samples Texture samples (default: 1)
  35118. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35119. * @param fileName A name for for the downloaded file.
  35120. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35121. * to the src parameter of an <img> to display it
  35122. */
  35123. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35124. /**
  35125. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35126. * Be aware Math.random() could cause collisions, but:
  35127. * "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"
  35128. * @returns a pseudo random id
  35129. */
  35130. static RandomId(): string;
  35131. /**
  35132. * Test if the given uri is a base64 string
  35133. * @param uri The uri to test
  35134. * @return True if the uri is a base64 string or false otherwise
  35135. */
  35136. static IsBase64(uri: string): boolean;
  35137. /**
  35138. * Decode the given base64 uri.
  35139. * @param uri The uri to decode
  35140. * @return The decoded base64 data.
  35141. */
  35142. static DecodeBase64(uri: string): ArrayBuffer;
  35143. /**
  35144. * Gets the absolute url.
  35145. * @param url the input url
  35146. * @return the absolute url
  35147. */
  35148. static GetAbsoluteUrl(url: string): string;
  35149. /**
  35150. * No log
  35151. */
  35152. static readonly NoneLogLevel: number;
  35153. /**
  35154. * Only message logs
  35155. */
  35156. static readonly MessageLogLevel: number;
  35157. /**
  35158. * Only warning logs
  35159. */
  35160. static readonly WarningLogLevel: number;
  35161. /**
  35162. * Only error logs
  35163. */
  35164. static readonly ErrorLogLevel: number;
  35165. /**
  35166. * All logs
  35167. */
  35168. static readonly AllLogLevel: number;
  35169. /**
  35170. * Gets a value indicating the number of loading errors
  35171. * @ignorenaming
  35172. */
  35173. static get errorsCount(): number;
  35174. /**
  35175. * Callback called when a new log is added
  35176. */
  35177. static OnNewCacheEntry: (entry: string) => void;
  35178. /**
  35179. * Log a message to the console
  35180. * @param message defines the message to log
  35181. */
  35182. static Log(message: string): void;
  35183. /**
  35184. * Write a warning message to the console
  35185. * @param message defines the message to log
  35186. */
  35187. static Warn(message: string): void;
  35188. /**
  35189. * Write an error message to the console
  35190. * @param message defines the message to log
  35191. */
  35192. static Error(message: string): void;
  35193. /**
  35194. * Gets current log cache (list of logs)
  35195. */
  35196. static get LogCache(): string;
  35197. /**
  35198. * Clears the log cache
  35199. */
  35200. static ClearLogCache(): void;
  35201. /**
  35202. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35203. */
  35204. static set LogLevels(level: number);
  35205. /**
  35206. * Checks if the window object exists
  35207. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35208. */
  35209. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35210. /**
  35211. * No performance log
  35212. */
  35213. static readonly PerformanceNoneLogLevel: number;
  35214. /**
  35215. * Use user marks to log performance
  35216. */
  35217. static readonly PerformanceUserMarkLogLevel: number;
  35218. /**
  35219. * Log performance to the console
  35220. */
  35221. static readonly PerformanceConsoleLogLevel: number;
  35222. private static _performance;
  35223. /**
  35224. * Sets the current performance log level
  35225. */
  35226. static set PerformanceLogLevel(level: number);
  35227. private static _StartPerformanceCounterDisabled;
  35228. private static _EndPerformanceCounterDisabled;
  35229. private static _StartUserMark;
  35230. private static _EndUserMark;
  35231. private static _StartPerformanceConsole;
  35232. private static _EndPerformanceConsole;
  35233. /**
  35234. * Starts a performance counter
  35235. */
  35236. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35237. /**
  35238. * Ends a specific performance coutner
  35239. */
  35240. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35241. /**
  35242. * Gets either window.performance.now() if supported or Date.now() else
  35243. */
  35244. static get Now(): number;
  35245. /**
  35246. * This method will return the name of the class used to create the instance of the given object.
  35247. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35248. * @param object the object to get the class name from
  35249. * @param isType defines if the object is actually a type
  35250. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35251. */
  35252. static GetClassName(object: any, isType?: boolean): string;
  35253. /**
  35254. * Gets the first element of an array satisfying a given predicate
  35255. * @param array defines the array to browse
  35256. * @param predicate defines the predicate to use
  35257. * @returns null if not found or the element
  35258. */
  35259. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35260. /**
  35261. * This method will return the name of the full name of the class, including its owning module (if any).
  35262. * 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).
  35263. * @param object the object to get the class name from
  35264. * @param isType defines if the object is actually a type
  35265. * @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.
  35266. * @ignorenaming
  35267. */
  35268. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35269. /**
  35270. * Returns a promise that resolves after the given amount of time.
  35271. * @param delay Number of milliseconds to delay
  35272. * @returns Promise that resolves after the given amount of time
  35273. */
  35274. static DelayAsync(delay: number): Promise<void>;
  35275. /**
  35276. * Utility function to detect if the current user agent is Safari
  35277. * @returns whether or not the current user agent is safari
  35278. */
  35279. static IsSafari(): boolean;
  35280. }
  35281. /**
  35282. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35283. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35284. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35285. * @param name The name of the class, case should be preserved
  35286. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35287. */
  35288. export function className(name: string, module?: string): (target: Object) => void;
  35289. /**
  35290. * An implementation of a loop for asynchronous functions.
  35291. */
  35292. export class AsyncLoop {
  35293. /**
  35294. * Defines the number of iterations for the loop
  35295. */
  35296. iterations: number;
  35297. /**
  35298. * Defines the current index of the loop.
  35299. */
  35300. index: number;
  35301. private _done;
  35302. private _fn;
  35303. private _successCallback;
  35304. /**
  35305. * Constructor.
  35306. * @param iterations the number of iterations.
  35307. * @param func the function to run each iteration
  35308. * @param successCallback the callback that will be called upon succesful execution
  35309. * @param offset starting offset.
  35310. */
  35311. constructor(
  35312. /**
  35313. * Defines the number of iterations for the loop
  35314. */
  35315. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35316. /**
  35317. * Execute the next iteration. Must be called after the last iteration was finished.
  35318. */
  35319. executeNext(): void;
  35320. /**
  35321. * Break the loop and run the success callback.
  35322. */
  35323. breakLoop(): void;
  35324. /**
  35325. * Create and run an async loop.
  35326. * @param iterations the number of iterations.
  35327. * @param fn the function to run each iteration
  35328. * @param successCallback the callback that will be called upon succesful execution
  35329. * @param offset starting offset.
  35330. * @returns the created async loop object
  35331. */
  35332. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35333. /**
  35334. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35335. * @param iterations total number of iterations
  35336. * @param syncedIterations number of synchronous iterations in each async iteration.
  35337. * @param fn the function to call each iteration.
  35338. * @param callback a success call back that will be called when iterating stops.
  35339. * @param breakFunction a break condition (optional)
  35340. * @param timeout timeout settings for the setTimeout function. default - 0.
  35341. * @returns the created async loop object
  35342. */
  35343. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35344. }
  35345. }
  35346. declare module "babylonjs/Misc/stringDictionary" {
  35347. import { Nullable } from "babylonjs/types";
  35348. /**
  35349. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35350. * The underlying implementation relies on an associative array to ensure the best performances.
  35351. * The value can be anything including 'null' but except 'undefined'
  35352. */
  35353. export class StringDictionary<T> {
  35354. /**
  35355. * This will clear this dictionary and copy the content from the 'source' one.
  35356. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35357. * @param source the dictionary to take the content from and copy to this dictionary
  35358. */
  35359. copyFrom(source: StringDictionary<T>): void;
  35360. /**
  35361. * Get a value based from its key
  35362. * @param key the given key to get the matching value from
  35363. * @return the value if found, otherwise undefined is returned
  35364. */
  35365. get(key: string): T | undefined;
  35366. /**
  35367. * Get a value from its key or add it if it doesn't exist.
  35368. * This method will ensure you that a given key/data will be present in the dictionary.
  35369. * @param key the given key to get the matching value from
  35370. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35371. * The factory will only be invoked if there's no data for the given key.
  35372. * @return the value corresponding to the key.
  35373. */
  35374. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35375. /**
  35376. * Get a value from its key if present in the dictionary otherwise add it
  35377. * @param key the key to get the value from
  35378. * @param val if there's no such key/value pair in the dictionary add it with this value
  35379. * @return the value corresponding to the key
  35380. */
  35381. getOrAdd(key: string, val: T): T;
  35382. /**
  35383. * Check if there's a given key in the dictionary
  35384. * @param key the key to check for
  35385. * @return true if the key is present, false otherwise
  35386. */
  35387. contains(key: string): boolean;
  35388. /**
  35389. * Add a new key and its corresponding value
  35390. * @param key the key to add
  35391. * @param value the value corresponding to the key
  35392. * @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
  35393. */
  35394. add(key: string, value: T): boolean;
  35395. /**
  35396. * Update a specific value associated to a key
  35397. * @param key defines the key to use
  35398. * @param value defines the value to store
  35399. * @returns true if the value was updated (or false if the key was not found)
  35400. */
  35401. set(key: string, value: T): boolean;
  35402. /**
  35403. * Get the element of the given key and remove it from the dictionary
  35404. * @param key defines the key to search
  35405. * @returns the value associated with the key or null if not found
  35406. */
  35407. getAndRemove(key: string): Nullable<T>;
  35408. /**
  35409. * Remove a key/value from the dictionary.
  35410. * @param key the key to remove
  35411. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35412. */
  35413. remove(key: string): boolean;
  35414. /**
  35415. * Clear the whole content of the dictionary
  35416. */
  35417. clear(): void;
  35418. /**
  35419. * Gets the current count
  35420. */
  35421. get count(): number;
  35422. /**
  35423. * Execute a callback on each key/val of the dictionary.
  35424. * Note that you can remove any element in this dictionary in the callback implementation
  35425. * @param callback the callback to execute on a given key/value pair
  35426. */
  35427. forEach(callback: (key: string, val: T) => void): void;
  35428. /**
  35429. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35430. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35431. * Note that you can remove any element in this dictionary in the callback implementation
  35432. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35433. * @returns the first item
  35434. */
  35435. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35436. private _count;
  35437. private _data;
  35438. }
  35439. }
  35440. declare module "babylonjs/Collisions/collisionCoordinator" {
  35441. import { Nullable } from "babylonjs/types";
  35442. import { Scene } from "babylonjs/scene";
  35443. import { Vector3 } from "babylonjs/Maths/math.vector";
  35444. import { Collider } from "babylonjs/Collisions/collider";
  35445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35446. /** @hidden */
  35447. export interface ICollisionCoordinator {
  35448. createCollider(): Collider;
  35449. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35450. init(scene: Scene): void;
  35451. }
  35452. /** @hidden */
  35453. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35454. private _scene;
  35455. private _scaledPosition;
  35456. private _scaledVelocity;
  35457. private _finalPosition;
  35458. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35459. createCollider(): Collider;
  35460. init(scene: Scene): void;
  35461. private _collideWithWorld;
  35462. }
  35463. }
  35464. declare module "babylonjs/Inputs/scene.inputManager" {
  35465. import { Nullable } from "babylonjs/types";
  35466. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35467. import { Vector2 } from "babylonjs/Maths/math.vector";
  35468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35469. import { Scene } from "babylonjs/scene";
  35470. /**
  35471. * Class used to manage all inputs for the scene.
  35472. */
  35473. export class InputManager {
  35474. /** The distance in pixel that you have to move to prevent some events */
  35475. static DragMovementThreshold: number;
  35476. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35477. static LongPressDelay: number;
  35478. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35479. static DoubleClickDelay: number;
  35480. /** If you need to check double click without raising a single click at first click, enable this flag */
  35481. static ExclusiveDoubleClickMode: boolean;
  35482. private _wheelEventName;
  35483. private _onPointerMove;
  35484. private _onPointerDown;
  35485. private _onPointerUp;
  35486. private _initClickEvent;
  35487. private _initActionManager;
  35488. private _delayedSimpleClick;
  35489. private _delayedSimpleClickTimeout;
  35490. private _previousDelayedSimpleClickTimeout;
  35491. private _meshPickProceed;
  35492. private _previousButtonPressed;
  35493. private _currentPickResult;
  35494. private _previousPickResult;
  35495. private _totalPointersPressed;
  35496. private _doubleClickOccured;
  35497. private _pointerOverMesh;
  35498. private _pickedDownMesh;
  35499. private _pickedUpMesh;
  35500. private _pointerX;
  35501. private _pointerY;
  35502. private _unTranslatedPointerX;
  35503. private _unTranslatedPointerY;
  35504. private _startingPointerPosition;
  35505. private _previousStartingPointerPosition;
  35506. private _startingPointerTime;
  35507. private _previousStartingPointerTime;
  35508. private _pointerCaptures;
  35509. private _onKeyDown;
  35510. private _onKeyUp;
  35511. private _onCanvasFocusObserver;
  35512. private _onCanvasBlurObserver;
  35513. private _scene;
  35514. /**
  35515. * Creates a new InputManager
  35516. * @param scene defines the hosting scene
  35517. */
  35518. constructor(scene: Scene);
  35519. /**
  35520. * Gets the mesh that is currently under the pointer
  35521. */
  35522. get meshUnderPointer(): Nullable<AbstractMesh>;
  35523. /**
  35524. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35525. */
  35526. get unTranslatedPointer(): Vector2;
  35527. /**
  35528. * Gets or sets the current on-screen X position of the pointer
  35529. */
  35530. get pointerX(): number;
  35531. set pointerX(value: number);
  35532. /**
  35533. * Gets or sets the current on-screen Y position of the pointer
  35534. */
  35535. get pointerY(): number;
  35536. set pointerY(value: number);
  35537. private _updatePointerPosition;
  35538. private _processPointerMove;
  35539. private _setRayOnPointerInfo;
  35540. private _checkPrePointerObservable;
  35541. /**
  35542. * Use this method to simulate a pointer move on a mesh
  35543. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35544. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35545. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35546. */
  35547. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35548. /**
  35549. * Use this method to simulate a pointer down on a mesh
  35550. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35551. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35552. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35553. */
  35554. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35555. private _processPointerDown;
  35556. /** @hidden */
  35557. _isPointerSwiping(): boolean;
  35558. /**
  35559. * Use this method to simulate a pointer up on a mesh
  35560. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35561. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35562. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35563. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35564. */
  35565. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35566. private _processPointerUp;
  35567. /**
  35568. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35569. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35570. * @returns true if the pointer was captured
  35571. */
  35572. isPointerCaptured(pointerId?: number): boolean;
  35573. /**
  35574. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35575. * @param attachUp defines if you want to attach events to pointerup
  35576. * @param attachDown defines if you want to attach events to pointerdown
  35577. * @param attachMove defines if you want to attach events to pointermove
  35578. */
  35579. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35580. /**
  35581. * Detaches all event handlers
  35582. */
  35583. detachControl(): void;
  35584. /**
  35585. * Force the value of meshUnderPointer
  35586. * @param mesh defines the mesh to use
  35587. */
  35588. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35589. /**
  35590. * Gets the mesh under the pointer
  35591. * @returns a Mesh or null if no mesh is under the pointer
  35592. */
  35593. getPointerOverMesh(): Nullable<AbstractMesh>;
  35594. }
  35595. }
  35596. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35597. /**
  35598. * Helper class used to generate session unique ID
  35599. */
  35600. export class UniqueIdGenerator {
  35601. private static _UniqueIdCounter;
  35602. /**
  35603. * Gets an unique (relatively to the current scene) Id
  35604. */
  35605. static get UniqueId(): number;
  35606. }
  35607. }
  35608. declare module "babylonjs/Animations/animationGroup" {
  35609. import { Animatable } from "babylonjs/Animations/animatable";
  35610. import { Animation } from "babylonjs/Animations/animation";
  35611. import { Scene, IDisposable } from "babylonjs/scene";
  35612. import { Observable } from "babylonjs/Misc/observable";
  35613. import { Nullable } from "babylonjs/types";
  35614. import "babylonjs/Animations/animatable";
  35615. /**
  35616. * This class defines the direct association between an animation and a target
  35617. */
  35618. export class TargetedAnimation {
  35619. /**
  35620. * Animation to perform
  35621. */
  35622. animation: Animation;
  35623. /**
  35624. * Target to animate
  35625. */
  35626. target: any;
  35627. /**
  35628. * Serialize the object
  35629. * @returns the JSON object representing the current entity
  35630. */
  35631. serialize(): any;
  35632. }
  35633. /**
  35634. * Use this class to create coordinated animations on multiple targets
  35635. */
  35636. export class AnimationGroup implements IDisposable {
  35637. /** The name of the animation group */
  35638. name: string;
  35639. private _scene;
  35640. private _targetedAnimations;
  35641. private _animatables;
  35642. private _from;
  35643. private _to;
  35644. private _isStarted;
  35645. private _isPaused;
  35646. private _speedRatio;
  35647. private _loopAnimation;
  35648. /**
  35649. * Gets or sets the unique id of the node
  35650. */
  35651. uniqueId: number;
  35652. /**
  35653. * This observable will notify when one animation have ended
  35654. */
  35655. onAnimationEndObservable: Observable<TargetedAnimation>;
  35656. /**
  35657. * Observer raised when one animation loops
  35658. */
  35659. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35660. /**
  35661. * Observer raised when all animations have looped
  35662. */
  35663. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35664. /**
  35665. * This observable will notify when all animations have ended.
  35666. */
  35667. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35668. /**
  35669. * This observable will notify when all animations have paused.
  35670. */
  35671. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35672. /**
  35673. * This observable will notify when all animations are playing.
  35674. */
  35675. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35676. /**
  35677. * Gets the first frame
  35678. */
  35679. get from(): number;
  35680. /**
  35681. * Gets the last frame
  35682. */
  35683. get to(): number;
  35684. /**
  35685. * Define if the animations are started
  35686. */
  35687. get isStarted(): boolean;
  35688. /**
  35689. * Gets a value indicating that the current group is playing
  35690. */
  35691. get isPlaying(): boolean;
  35692. /**
  35693. * Gets or sets the speed ratio to use for all animations
  35694. */
  35695. get speedRatio(): number;
  35696. /**
  35697. * Gets or sets the speed ratio to use for all animations
  35698. */
  35699. set speedRatio(value: number);
  35700. /**
  35701. * Gets or sets if all animations should loop or not
  35702. */
  35703. get loopAnimation(): boolean;
  35704. set loopAnimation(value: boolean);
  35705. /**
  35706. * Gets the targeted animations for this animation group
  35707. */
  35708. get targetedAnimations(): Array<TargetedAnimation>;
  35709. /**
  35710. * returning the list of animatables controlled by this animation group.
  35711. */
  35712. get animatables(): Array<Animatable>;
  35713. /**
  35714. * Instantiates a new Animation Group.
  35715. * This helps managing several animations at once.
  35716. * @see http://doc.babylonjs.com/how_to/group
  35717. * @param name Defines the name of the group
  35718. * @param scene Defines the scene the group belongs to
  35719. */
  35720. constructor(
  35721. /** The name of the animation group */
  35722. name: string, scene?: Nullable<Scene>);
  35723. /**
  35724. * Add an animation (with its target) in the group
  35725. * @param animation defines the animation we want to add
  35726. * @param target defines the target of the animation
  35727. * @returns the TargetedAnimation object
  35728. */
  35729. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35730. /**
  35731. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35732. * It can add constant keys at begin or end
  35733. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35734. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35735. * @returns the animation group
  35736. */
  35737. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35738. private _animationLoopCount;
  35739. private _animationLoopFlags;
  35740. private _processLoop;
  35741. /**
  35742. * Start all animations on given targets
  35743. * @param loop defines if animations must loop
  35744. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35745. * @param from defines the from key (optional)
  35746. * @param to defines the to key (optional)
  35747. * @returns the current animation group
  35748. */
  35749. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35750. /**
  35751. * Pause all animations
  35752. * @returns the animation group
  35753. */
  35754. pause(): AnimationGroup;
  35755. /**
  35756. * Play all animations to initial state
  35757. * This function will start() the animations if they were not started or will restart() them if they were paused
  35758. * @param loop defines if animations must loop
  35759. * @returns the animation group
  35760. */
  35761. play(loop?: boolean): AnimationGroup;
  35762. /**
  35763. * Reset all animations to initial state
  35764. * @returns the animation group
  35765. */
  35766. reset(): AnimationGroup;
  35767. /**
  35768. * Restart animations from key 0
  35769. * @returns the animation group
  35770. */
  35771. restart(): AnimationGroup;
  35772. /**
  35773. * Stop all animations
  35774. * @returns the animation group
  35775. */
  35776. stop(): AnimationGroup;
  35777. /**
  35778. * Set animation weight for all animatables
  35779. * @param weight defines the weight to use
  35780. * @return the animationGroup
  35781. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35782. */
  35783. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35784. /**
  35785. * Synchronize and normalize all animatables with a source animatable
  35786. * @param root defines the root animatable to synchronize with
  35787. * @return the animationGroup
  35788. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35789. */
  35790. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35791. /**
  35792. * Goes to a specific frame in this animation group
  35793. * @param frame the frame number to go to
  35794. * @return the animationGroup
  35795. */
  35796. goToFrame(frame: number): AnimationGroup;
  35797. /**
  35798. * Dispose all associated resources
  35799. */
  35800. dispose(): void;
  35801. private _checkAnimationGroupEnded;
  35802. /**
  35803. * Clone the current animation group and returns a copy
  35804. * @param newName defines the name of the new group
  35805. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35806. * @returns the new aniamtion group
  35807. */
  35808. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35809. /**
  35810. * Serializes the animationGroup to an object
  35811. * @returns Serialized object
  35812. */
  35813. serialize(): any;
  35814. /**
  35815. * Returns a new AnimationGroup object parsed from the source provided.
  35816. * @param parsedAnimationGroup defines the source
  35817. * @param scene defines the scene that will receive the animationGroup
  35818. * @returns a new AnimationGroup
  35819. */
  35820. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35821. /**
  35822. * Returns the string "AnimationGroup"
  35823. * @returns "AnimationGroup"
  35824. */
  35825. getClassName(): string;
  35826. /**
  35827. * Creates a detailled string about the object
  35828. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35829. * @returns a string representing the object
  35830. */
  35831. toString(fullDetails?: boolean): string;
  35832. }
  35833. }
  35834. declare module "babylonjs/scene" {
  35835. import { Nullable } from "babylonjs/types";
  35836. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35837. import { Observable } from "babylonjs/Misc/observable";
  35838. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35839. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35840. import { Geometry } from "babylonjs/Meshes/geometry";
  35841. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35842. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35844. import { Mesh } from "babylonjs/Meshes/mesh";
  35845. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35846. import { Bone } from "babylonjs/Bones/bone";
  35847. import { Skeleton } from "babylonjs/Bones/skeleton";
  35848. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35849. import { Camera } from "babylonjs/Cameras/camera";
  35850. import { AbstractScene } from "babylonjs/abstractScene";
  35851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35852. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35853. import { Material } from "babylonjs/Materials/material";
  35854. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35855. import { Effect } from "babylonjs/Materials/effect";
  35856. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35857. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35858. import { Light } from "babylonjs/Lights/light";
  35859. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35860. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35861. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35862. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35863. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35864. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35865. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35866. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35867. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35868. import { Engine } from "babylonjs/Engines/engine";
  35869. import { Node } from "babylonjs/node";
  35870. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35871. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35872. import { WebRequest } from "babylonjs/Misc/webRequest";
  35873. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35874. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35875. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35876. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35877. import { Plane } from "babylonjs/Maths/math.plane";
  35878. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35879. import { Ray } from "babylonjs/Culling/ray";
  35880. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35881. import { Animation } from "babylonjs/Animations/animation";
  35882. import { Animatable } from "babylonjs/Animations/animatable";
  35883. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35884. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35885. import { Collider } from "babylonjs/Collisions/collider";
  35886. /**
  35887. * Define an interface for all classes that will hold resources
  35888. */
  35889. export interface IDisposable {
  35890. /**
  35891. * Releases all held resources
  35892. */
  35893. dispose(): void;
  35894. }
  35895. /** Interface defining initialization parameters for Scene class */
  35896. export interface SceneOptions {
  35897. /**
  35898. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35899. * It will improve performance when the number of geometries becomes important.
  35900. */
  35901. useGeometryUniqueIdsMap?: boolean;
  35902. /**
  35903. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35904. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35905. */
  35906. useMaterialMeshMap?: boolean;
  35907. /**
  35908. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35909. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35910. */
  35911. useClonedMeshMap?: boolean;
  35912. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35913. virtual?: boolean;
  35914. }
  35915. /**
  35916. * Represents a scene to be rendered by the engine.
  35917. * @see http://doc.babylonjs.com/features/scene
  35918. */
  35919. export class Scene extends AbstractScene implements IAnimatable {
  35920. /** The fog is deactivated */
  35921. static readonly FOGMODE_NONE: number;
  35922. /** The fog density is following an exponential function */
  35923. static readonly FOGMODE_EXP: number;
  35924. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35925. static readonly FOGMODE_EXP2: number;
  35926. /** The fog density is following a linear function. */
  35927. static readonly FOGMODE_LINEAR: number;
  35928. /**
  35929. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35930. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35931. */
  35932. static MinDeltaTime: number;
  35933. /**
  35934. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35935. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35936. */
  35937. static MaxDeltaTime: number;
  35938. /**
  35939. * Factory used to create the default material.
  35940. * @param name The name of the material to create
  35941. * @param scene The scene to create the material for
  35942. * @returns The default material
  35943. */
  35944. static DefaultMaterialFactory(scene: Scene): Material;
  35945. /**
  35946. * Factory used to create the a collision coordinator.
  35947. * @returns The collision coordinator
  35948. */
  35949. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35950. /** @hidden */
  35951. _inputManager: InputManager;
  35952. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35953. cameraToUseForPointers: Nullable<Camera>;
  35954. /** @hidden */
  35955. readonly _isScene: boolean;
  35956. /**
  35957. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35958. */
  35959. autoClear: boolean;
  35960. /**
  35961. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35962. */
  35963. autoClearDepthAndStencil: boolean;
  35964. /**
  35965. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35966. */
  35967. clearColor: Color4;
  35968. /**
  35969. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35970. */
  35971. ambientColor: Color3;
  35972. /**
  35973. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35974. * It should only be one of the following (if not the default embedded one):
  35975. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35976. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35977. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35978. * The material properties need to be setup according to the type of texture in use.
  35979. */
  35980. environmentBRDFTexture: BaseTexture;
  35981. /** @hidden */
  35982. protected _environmentTexture: Nullable<BaseTexture>;
  35983. /**
  35984. * Texture used in all pbr material as the reflection texture.
  35985. * As in the majority of the scene they are the same (exception for multi room and so on),
  35986. * this is easier to reference from here than from all the materials.
  35987. */
  35988. get environmentTexture(): Nullable<BaseTexture>;
  35989. /**
  35990. * Texture used in all pbr material as the reflection texture.
  35991. * As in the majority of the scene they are the same (exception for multi room and so on),
  35992. * this is easier to set here than in all the materials.
  35993. */
  35994. set environmentTexture(value: Nullable<BaseTexture>);
  35995. /** @hidden */
  35996. protected _environmentIntensity: number;
  35997. /**
  35998. * Intensity of the environment in all pbr material.
  35999. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36000. * As in the majority of the scene they are the same (exception for multi room and so on),
  36001. * this is easier to reference from here than from all the materials.
  36002. */
  36003. get environmentIntensity(): number;
  36004. /**
  36005. * Intensity of the environment in all pbr material.
  36006. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36007. * As in the majority of the scene they are the same (exception for multi room and so on),
  36008. * this is easier to set here than in all the materials.
  36009. */
  36010. set environmentIntensity(value: number);
  36011. /** @hidden */
  36012. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36013. /**
  36014. * Default image processing configuration used either in the rendering
  36015. * Forward main pass or through the imageProcessingPostProcess if present.
  36016. * As in the majority of the scene they are the same (exception for multi camera),
  36017. * this is easier to reference from here than from all the materials and post process.
  36018. *
  36019. * No setter as we it is a shared configuration, you can set the values instead.
  36020. */
  36021. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36022. private _forceWireframe;
  36023. /**
  36024. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36025. */
  36026. set forceWireframe(value: boolean);
  36027. get forceWireframe(): boolean;
  36028. private _skipFrustumClipping;
  36029. /**
  36030. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36031. */
  36032. set skipFrustumClipping(value: boolean);
  36033. get skipFrustumClipping(): boolean;
  36034. private _forcePointsCloud;
  36035. /**
  36036. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36037. */
  36038. set forcePointsCloud(value: boolean);
  36039. get forcePointsCloud(): boolean;
  36040. /**
  36041. * Gets or sets the active clipplane 1
  36042. */
  36043. clipPlane: Nullable<Plane>;
  36044. /**
  36045. * Gets or sets the active clipplane 2
  36046. */
  36047. clipPlane2: Nullable<Plane>;
  36048. /**
  36049. * Gets or sets the active clipplane 3
  36050. */
  36051. clipPlane3: Nullable<Plane>;
  36052. /**
  36053. * Gets or sets the active clipplane 4
  36054. */
  36055. clipPlane4: Nullable<Plane>;
  36056. /**
  36057. * Gets or sets the active clipplane 5
  36058. */
  36059. clipPlane5: Nullable<Plane>;
  36060. /**
  36061. * Gets or sets the active clipplane 6
  36062. */
  36063. clipPlane6: Nullable<Plane>;
  36064. /**
  36065. * Gets or sets a boolean indicating if animations are enabled
  36066. */
  36067. animationsEnabled: boolean;
  36068. private _animationPropertiesOverride;
  36069. /**
  36070. * Gets or sets the animation properties override
  36071. */
  36072. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36073. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36074. /**
  36075. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36076. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36077. */
  36078. useConstantAnimationDeltaTime: boolean;
  36079. /**
  36080. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36081. * Please note that it requires to run a ray cast through the scene on every frame
  36082. */
  36083. constantlyUpdateMeshUnderPointer: boolean;
  36084. /**
  36085. * Defines the HTML cursor to use when hovering over interactive elements
  36086. */
  36087. hoverCursor: string;
  36088. /**
  36089. * Defines the HTML default cursor to use (empty by default)
  36090. */
  36091. defaultCursor: string;
  36092. /**
  36093. * Defines wether cursors are handled by the scene.
  36094. */
  36095. doNotHandleCursors: boolean;
  36096. /**
  36097. * This is used to call preventDefault() on pointer down
  36098. * in order to block unwanted artifacts like system double clicks
  36099. */
  36100. preventDefaultOnPointerDown: boolean;
  36101. /**
  36102. * This is used to call preventDefault() on pointer up
  36103. * in order to block unwanted artifacts like system double clicks
  36104. */
  36105. preventDefaultOnPointerUp: boolean;
  36106. /**
  36107. * Gets or sets user defined metadata
  36108. */
  36109. metadata: any;
  36110. /**
  36111. * For internal use only. Please do not use.
  36112. */
  36113. reservedDataStore: any;
  36114. /**
  36115. * Gets the name of the plugin used to load this scene (null by default)
  36116. */
  36117. loadingPluginName: string;
  36118. /**
  36119. * Use this array to add regular expressions used to disable offline support for specific urls
  36120. */
  36121. disableOfflineSupportExceptionRules: RegExp[];
  36122. /**
  36123. * An event triggered when the scene is disposed.
  36124. */
  36125. onDisposeObservable: Observable<Scene>;
  36126. private _onDisposeObserver;
  36127. /** Sets a function to be executed when this scene is disposed. */
  36128. set onDispose(callback: () => void);
  36129. /**
  36130. * An event triggered before rendering the scene (right after animations and physics)
  36131. */
  36132. onBeforeRenderObservable: Observable<Scene>;
  36133. private _onBeforeRenderObserver;
  36134. /** Sets a function to be executed before rendering this scene */
  36135. set beforeRender(callback: Nullable<() => void>);
  36136. /**
  36137. * An event triggered after rendering the scene
  36138. */
  36139. onAfterRenderObservable: Observable<Scene>;
  36140. /**
  36141. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36142. */
  36143. onAfterRenderCameraObservable: Observable<Camera>;
  36144. private _onAfterRenderObserver;
  36145. /** Sets a function to be executed after rendering this scene */
  36146. set afterRender(callback: Nullable<() => void>);
  36147. /**
  36148. * An event triggered before animating the scene
  36149. */
  36150. onBeforeAnimationsObservable: Observable<Scene>;
  36151. /**
  36152. * An event triggered after animations processing
  36153. */
  36154. onAfterAnimationsObservable: Observable<Scene>;
  36155. /**
  36156. * An event triggered before draw calls are ready to be sent
  36157. */
  36158. onBeforeDrawPhaseObservable: Observable<Scene>;
  36159. /**
  36160. * An event triggered after draw calls have been sent
  36161. */
  36162. onAfterDrawPhaseObservable: Observable<Scene>;
  36163. /**
  36164. * An event triggered when the scene is ready
  36165. */
  36166. onReadyObservable: Observable<Scene>;
  36167. /**
  36168. * An event triggered before rendering a camera
  36169. */
  36170. onBeforeCameraRenderObservable: Observable<Camera>;
  36171. private _onBeforeCameraRenderObserver;
  36172. /** Sets a function to be executed before rendering a camera*/
  36173. set beforeCameraRender(callback: () => void);
  36174. /**
  36175. * An event triggered after rendering a camera
  36176. */
  36177. onAfterCameraRenderObservable: Observable<Camera>;
  36178. private _onAfterCameraRenderObserver;
  36179. /** Sets a function to be executed after rendering a camera*/
  36180. set afterCameraRender(callback: () => void);
  36181. /**
  36182. * An event triggered when active meshes evaluation is about to start
  36183. */
  36184. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36185. /**
  36186. * An event triggered when active meshes evaluation is done
  36187. */
  36188. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36189. /**
  36190. * An event triggered when particles rendering is about to start
  36191. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36192. */
  36193. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36194. /**
  36195. * An event triggered when particles rendering is done
  36196. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36197. */
  36198. onAfterParticlesRenderingObservable: Observable<Scene>;
  36199. /**
  36200. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36201. */
  36202. onDataLoadedObservable: Observable<Scene>;
  36203. /**
  36204. * An event triggered when a camera is created
  36205. */
  36206. onNewCameraAddedObservable: Observable<Camera>;
  36207. /**
  36208. * An event triggered when a camera is removed
  36209. */
  36210. onCameraRemovedObservable: Observable<Camera>;
  36211. /**
  36212. * An event triggered when a light is created
  36213. */
  36214. onNewLightAddedObservable: Observable<Light>;
  36215. /**
  36216. * An event triggered when a light is removed
  36217. */
  36218. onLightRemovedObservable: Observable<Light>;
  36219. /**
  36220. * An event triggered when a geometry is created
  36221. */
  36222. onNewGeometryAddedObservable: Observable<Geometry>;
  36223. /**
  36224. * An event triggered when a geometry is removed
  36225. */
  36226. onGeometryRemovedObservable: Observable<Geometry>;
  36227. /**
  36228. * An event triggered when a transform node is created
  36229. */
  36230. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36231. /**
  36232. * An event triggered when a transform node is removed
  36233. */
  36234. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36235. /**
  36236. * An event triggered when a mesh is created
  36237. */
  36238. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36239. /**
  36240. * An event triggered when a mesh is removed
  36241. */
  36242. onMeshRemovedObservable: Observable<AbstractMesh>;
  36243. /**
  36244. * An event triggered when a skeleton is created
  36245. */
  36246. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36247. /**
  36248. * An event triggered when a skeleton is removed
  36249. */
  36250. onSkeletonRemovedObservable: Observable<Skeleton>;
  36251. /**
  36252. * An event triggered when a material is created
  36253. */
  36254. onNewMaterialAddedObservable: Observable<Material>;
  36255. /**
  36256. * An event triggered when a material is removed
  36257. */
  36258. onMaterialRemovedObservable: Observable<Material>;
  36259. /**
  36260. * An event triggered when a texture is created
  36261. */
  36262. onNewTextureAddedObservable: Observable<BaseTexture>;
  36263. /**
  36264. * An event triggered when a texture is removed
  36265. */
  36266. onTextureRemovedObservable: Observable<BaseTexture>;
  36267. /**
  36268. * An event triggered when render targets are about to be rendered
  36269. * Can happen multiple times per frame.
  36270. */
  36271. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36272. /**
  36273. * An event triggered when render targets were rendered.
  36274. * Can happen multiple times per frame.
  36275. */
  36276. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36277. /**
  36278. * An event triggered before calculating deterministic simulation step
  36279. */
  36280. onBeforeStepObservable: Observable<Scene>;
  36281. /**
  36282. * An event triggered after calculating deterministic simulation step
  36283. */
  36284. onAfterStepObservable: Observable<Scene>;
  36285. /**
  36286. * An event triggered when the activeCamera property is updated
  36287. */
  36288. onActiveCameraChanged: Observable<Scene>;
  36289. /**
  36290. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36291. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36292. * 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)
  36293. */
  36294. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36295. /**
  36296. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36297. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36298. * 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)
  36299. */
  36300. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36301. /**
  36302. * This Observable will when a mesh has been imported into the scene.
  36303. */
  36304. onMeshImportedObservable: Observable<AbstractMesh>;
  36305. /**
  36306. * This Observable will when an animation file has been imported into the scene.
  36307. */
  36308. onAnimationFileImportedObservable: Observable<Scene>;
  36309. /**
  36310. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36311. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36312. */
  36313. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36314. /** @hidden */
  36315. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36316. /**
  36317. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36318. */
  36319. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36320. /**
  36321. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36322. */
  36323. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36324. /**
  36325. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36326. */
  36327. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36328. /** Callback called when a pointer move is detected */
  36329. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36330. /** Callback called when a pointer down is detected */
  36331. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36332. /** Callback called when a pointer up is detected */
  36333. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36334. /** Callback called when a pointer pick is detected */
  36335. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36336. /**
  36337. * 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).
  36338. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36339. */
  36340. onPrePointerObservable: Observable<PointerInfoPre>;
  36341. /**
  36342. * Observable event triggered each time an input event is received from the rendering canvas
  36343. */
  36344. onPointerObservable: Observable<PointerInfo>;
  36345. /**
  36346. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36347. */
  36348. get unTranslatedPointer(): Vector2;
  36349. /**
  36350. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36351. */
  36352. static get DragMovementThreshold(): number;
  36353. static set DragMovementThreshold(value: number);
  36354. /**
  36355. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36356. */
  36357. static get LongPressDelay(): number;
  36358. static set LongPressDelay(value: number);
  36359. /**
  36360. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36361. */
  36362. static get DoubleClickDelay(): number;
  36363. static set DoubleClickDelay(value: number);
  36364. /** If you need to check double click without raising a single click at first click, enable this flag */
  36365. static get ExclusiveDoubleClickMode(): boolean;
  36366. static set ExclusiveDoubleClickMode(value: boolean);
  36367. /** @hidden */
  36368. _mirroredCameraPosition: Nullable<Vector3>;
  36369. /**
  36370. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36371. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36372. */
  36373. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36374. /**
  36375. * Observable event triggered each time an keyboard event is received from the hosting window
  36376. */
  36377. onKeyboardObservable: Observable<KeyboardInfo>;
  36378. private _useRightHandedSystem;
  36379. /**
  36380. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36381. */
  36382. set useRightHandedSystem(value: boolean);
  36383. get useRightHandedSystem(): boolean;
  36384. private _timeAccumulator;
  36385. private _currentStepId;
  36386. private _currentInternalStep;
  36387. /**
  36388. * Sets the step Id used by deterministic lock step
  36389. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36390. * @param newStepId defines the step Id
  36391. */
  36392. setStepId(newStepId: number): void;
  36393. /**
  36394. * Gets the step Id used by deterministic lock step
  36395. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36396. * @returns the step Id
  36397. */
  36398. getStepId(): number;
  36399. /**
  36400. * Gets the internal step used by deterministic lock step
  36401. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36402. * @returns the internal step
  36403. */
  36404. getInternalStep(): number;
  36405. private _fogEnabled;
  36406. /**
  36407. * Gets or sets a boolean indicating if fog is enabled on this scene
  36408. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36409. * (Default is true)
  36410. */
  36411. set fogEnabled(value: boolean);
  36412. get fogEnabled(): boolean;
  36413. private _fogMode;
  36414. /**
  36415. * Gets or sets the fog mode to use
  36416. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36417. * | mode | value |
  36418. * | --- | --- |
  36419. * | FOGMODE_NONE | 0 |
  36420. * | FOGMODE_EXP | 1 |
  36421. * | FOGMODE_EXP2 | 2 |
  36422. * | FOGMODE_LINEAR | 3 |
  36423. */
  36424. set fogMode(value: number);
  36425. get fogMode(): number;
  36426. /**
  36427. * Gets or sets the fog color to use
  36428. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36429. * (Default is Color3(0.2, 0.2, 0.3))
  36430. */
  36431. fogColor: Color3;
  36432. /**
  36433. * Gets or sets the fog density to use
  36434. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36435. * (Default is 0.1)
  36436. */
  36437. fogDensity: number;
  36438. /**
  36439. * Gets or sets the fog start distance to use
  36440. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36441. * (Default is 0)
  36442. */
  36443. fogStart: number;
  36444. /**
  36445. * Gets or sets the fog end distance to use
  36446. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36447. * (Default is 1000)
  36448. */
  36449. fogEnd: number;
  36450. private _shadowsEnabled;
  36451. /**
  36452. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36453. */
  36454. set shadowsEnabled(value: boolean);
  36455. get shadowsEnabled(): boolean;
  36456. private _lightsEnabled;
  36457. /**
  36458. * Gets or sets a boolean indicating if lights are enabled on this scene
  36459. */
  36460. set lightsEnabled(value: boolean);
  36461. get lightsEnabled(): boolean;
  36462. /** All of the active cameras added to this scene. */
  36463. activeCameras: Camera[];
  36464. /** @hidden */
  36465. _activeCamera: Nullable<Camera>;
  36466. /** Gets or sets the current active camera */
  36467. get activeCamera(): Nullable<Camera>;
  36468. set activeCamera(value: Nullable<Camera>);
  36469. private _defaultMaterial;
  36470. /** The default material used on meshes when no material is affected */
  36471. get defaultMaterial(): Material;
  36472. /** The default material used on meshes when no material is affected */
  36473. set defaultMaterial(value: Material);
  36474. private _texturesEnabled;
  36475. /**
  36476. * Gets or sets a boolean indicating if textures are enabled on this scene
  36477. */
  36478. set texturesEnabled(value: boolean);
  36479. get texturesEnabled(): boolean;
  36480. /**
  36481. * Gets or sets a boolean indicating if particles are enabled on this scene
  36482. */
  36483. particlesEnabled: boolean;
  36484. /**
  36485. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36486. */
  36487. spritesEnabled: boolean;
  36488. private _skeletonsEnabled;
  36489. /**
  36490. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36491. */
  36492. set skeletonsEnabled(value: boolean);
  36493. get skeletonsEnabled(): boolean;
  36494. /**
  36495. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36496. */
  36497. lensFlaresEnabled: boolean;
  36498. /**
  36499. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36500. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36501. */
  36502. collisionsEnabled: boolean;
  36503. private _collisionCoordinator;
  36504. /** @hidden */
  36505. get collisionCoordinator(): ICollisionCoordinator;
  36506. /**
  36507. * Defines the gravity applied to this scene (used only for collisions)
  36508. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36509. */
  36510. gravity: Vector3;
  36511. /**
  36512. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36513. */
  36514. postProcessesEnabled: boolean;
  36515. /**
  36516. * The list of postprocesses added to the scene
  36517. */
  36518. postProcesses: PostProcess[];
  36519. /**
  36520. * Gets the current postprocess manager
  36521. */
  36522. postProcessManager: PostProcessManager;
  36523. /**
  36524. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36525. */
  36526. renderTargetsEnabled: boolean;
  36527. /**
  36528. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36529. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36530. */
  36531. dumpNextRenderTargets: boolean;
  36532. /**
  36533. * The list of user defined render targets added to the scene
  36534. */
  36535. customRenderTargets: RenderTargetTexture[];
  36536. /**
  36537. * Defines if texture loading must be delayed
  36538. * If true, textures will only be loaded when they need to be rendered
  36539. */
  36540. useDelayedTextureLoading: boolean;
  36541. /**
  36542. * Gets the list of meshes imported to the scene through SceneLoader
  36543. */
  36544. importedMeshesFiles: String[];
  36545. /**
  36546. * Gets or sets a boolean indicating if probes are enabled on this scene
  36547. */
  36548. probesEnabled: boolean;
  36549. /**
  36550. * Gets or sets the current offline provider to use to store scene data
  36551. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36552. */
  36553. offlineProvider: IOfflineProvider;
  36554. /**
  36555. * Gets or sets the action manager associated with the scene
  36556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36557. */
  36558. actionManager: AbstractActionManager;
  36559. private _meshesForIntersections;
  36560. /**
  36561. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36562. */
  36563. proceduralTexturesEnabled: boolean;
  36564. private _engine;
  36565. private _totalVertices;
  36566. /** @hidden */
  36567. _activeIndices: PerfCounter;
  36568. /** @hidden */
  36569. _activeParticles: PerfCounter;
  36570. /** @hidden */
  36571. _activeBones: PerfCounter;
  36572. private _animationRatio;
  36573. /** @hidden */
  36574. _animationTimeLast: number;
  36575. /** @hidden */
  36576. _animationTime: number;
  36577. /**
  36578. * Gets or sets a general scale for animation speed
  36579. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36580. */
  36581. animationTimeScale: number;
  36582. /** @hidden */
  36583. _cachedMaterial: Nullable<Material>;
  36584. /** @hidden */
  36585. _cachedEffect: Nullable<Effect>;
  36586. /** @hidden */
  36587. _cachedVisibility: Nullable<number>;
  36588. private _renderId;
  36589. private _frameId;
  36590. private _executeWhenReadyTimeoutId;
  36591. private _intermediateRendering;
  36592. private _viewUpdateFlag;
  36593. private _projectionUpdateFlag;
  36594. /** @hidden */
  36595. _toBeDisposed: Nullable<IDisposable>[];
  36596. private _activeRequests;
  36597. /** @hidden */
  36598. _pendingData: any[];
  36599. private _isDisposed;
  36600. /**
  36601. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36602. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36603. */
  36604. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36605. private _activeMeshes;
  36606. private _processedMaterials;
  36607. private _renderTargets;
  36608. /** @hidden */
  36609. _activeParticleSystems: SmartArray<IParticleSystem>;
  36610. private _activeSkeletons;
  36611. private _softwareSkinnedMeshes;
  36612. private _renderingManager;
  36613. /** @hidden */
  36614. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36615. private _transformMatrix;
  36616. private _sceneUbo;
  36617. /** @hidden */
  36618. _viewMatrix: Matrix;
  36619. private _projectionMatrix;
  36620. /** @hidden */
  36621. _forcedViewPosition: Nullable<Vector3>;
  36622. /** @hidden */
  36623. _frustumPlanes: Plane[];
  36624. /**
  36625. * Gets the list of frustum planes (built from the active camera)
  36626. */
  36627. get frustumPlanes(): Plane[];
  36628. /**
  36629. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36630. * This is useful if there are more lights that the maximum simulteanous authorized
  36631. */
  36632. requireLightSorting: boolean;
  36633. /** @hidden */
  36634. readonly useMaterialMeshMap: boolean;
  36635. /** @hidden */
  36636. readonly useClonedMeshMap: boolean;
  36637. private _externalData;
  36638. private _uid;
  36639. /**
  36640. * @hidden
  36641. * Backing store of defined scene components.
  36642. */
  36643. _components: ISceneComponent[];
  36644. /**
  36645. * @hidden
  36646. * Backing store of defined scene components.
  36647. */
  36648. _serializableComponents: ISceneSerializableComponent[];
  36649. /**
  36650. * List of components to register on the next registration step.
  36651. */
  36652. private _transientComponents;
  36653. /**
  36654. * Registers the transient components if needed.
  36655. */
  36656. private _registerTransientComponents;
  36657. /**
  36658. * @hidden
  36659. * Add a component to the scene.
  36660. * Note that the ccomponent could be registered on th next frame if this is called after
  36661. * the register component stage.
  36662. * @param component Defines the component to add to the scene
  36663. */
  36664. _addComponent(component: ISceneComponent): void;
  36665. /**
  36666. * @hidden
  36667. * Gets a component from the scene.
  36668. * @param name defines the name of the component to retrieve
  36669. * @returns the component or null if not present
  36670. */
  36671. _getComponent(name: string): Nullable<ISceneComponent>;
  36672. /**
  36673. * @hidden
  36674. * Defines the actions happening before camera updates.
  36675. */
  36676. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36677. /**
  36678. * @hidden
  36679. * Defines the actions happening before clear the canvas.
  36680. */
  36681. _beforeClearStage: Stage<SimpleStageAction>;
  36682. /**
  36683. * @hidden
  36684. * Defines the actions when collecting render targets for the frame.
  36685. */
  36686. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36687. /**
  36688. * @hidden
  36689. * Defines the actions happening for one camera in the frame.
  36690. */
  36691. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36692. /**
  36693. * @hidden
  36694. * Defines the actions happening during the per mesh ready checks.
  36695. */
  36696. _isReadyForMeshStage: Stage<MeshStageAction>;
  36697. /**
  36698. * @hidden
  36699. * Defines the actions happening before evaluate active mesh checks.
  36700. */
  36701. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36702. /**
  36703. * @hidden
  36704. * Defines the actions happening during the evaluate sub mesh checks.
  36705. */
  36706. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36707. /**
  36708. * @hidden
  36709. * Defines the actions happening during the active mesh stage.
  36710. */
  36711. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36712. /**
  36713. * @hidden
  36714. * Defines the actions happening during the per camera render target step.
  36715. */
  36716. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36717. /**
  36718. * @hidden
  36719. * Defines the actions happening just before the active camera is drawing.
  36720. */
  36721. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36722. /**
  36723. * @hidden
  36724. * Defines the actions happening just before a render target is drawing.
  36725. */
  36726. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36727. /**
  36728. * @hidden
  36729. * Defines the actions happening just before a rendering group is drawing.
  36730. */
  36731. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36732. /**
  36733. * @hidden
  36734. * Defines the actions happening just before a mesh is drawing.
  36735. */
  36736. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36737. /**
  36738. * @hidden
  36739. * Defines the actions happening just after a mesh has been drawn.
  36740. */
  36741. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36742. /**
  36743. * @hidden
  36744. * Defines the actions happening just after a rendering group has been drawn.
  36745. */
  36746. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36747. /**
  36748. * @hidden
  36749. * Defines the actions happening just after the active camera has been drawn.
  36750. */
  36751. _afterCameraDrawStage: Stage<CameraStageAction>;
  36752. /**
  36753. * @hidden
  36754. * Defines the actions happening just after a render target has been drawn.
  36755. */
  36756. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36757. /**
  36758. * @hidden
  36759. * Defines the actions happening just after rendering all cameras and computing intersections.
  36760. */
  36761. _afterRenderStage: Stage<SimpleStageAction>;
  36762. /**
  36763. * @hidden
  36764. * Defines the actions happening when a pointer move event happens.
  36765. */
  36766. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36767. /**
  36768. * @hidden
  36769. * Defines the actions happening when a pointer down event happens.
  36770. */
  36771. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36772. /**
  36773. * @hidden
  36774. * Defines the actions happening when a pointer up event happens.
  36775. */
  36776. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36777. /**
  36778. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36779. */
  36780. private geometriesByUniqueId;
  36781. /**
  36782. * Creates a new Scene
  36783. * @param engine defines the engine to use to render this scene
  36784. * @param options defines the scene options
  36785. */
  36786. constructor(engine: Engine, options?: SceneOptions);
  36787. /**
  36788. * Gets a string idenfifying the name of the class
  36789. * @returns "Scene" string
  36790. */
  36791. getClassName(): string;
  36792. private _defaultMeshCandidates;
  36793. /**
  36794. * @hidden
  36795. */
  36796. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36797. private _defaultSubMeshCandidates;
  36798. /**
  36799. * @hidden
  36800. */
  36801. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36802. /**
  36803. * Sets the default candidate providers for the scene.
  36804. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36805. * and getCollidingSubMeshCandidates to their default function
  36806. */
  36807. setDefaultCandidateProviders(): void;
  36808. /**
  36809. * Gets the mesh that is currently under the pointer
  36810. */
  36811. get meshUnderPointer(): Nullable<AbstractMesh>;
  36812. /**
  36813. * Gets or sets the current on-screen X position of the pointer
  36814. */
  36815. get pointerX(): number;
  36816. set pointerX(value: number);
  36817. /**
  36818. * Gets or sets the current on-screen Y position of the pointer
  36819. */
  36820. get pointerY(): number;
  36821. set pointerY(value: number);
  36822. /**
  36823. * Gets the cached material (ie. the latest rendered one)
  36824. * @returns the cached material
  36825. */
  36826. getCachedMaterial(): Nullable<Material>;
  36827. /**
  36828. * Gets the cached effect (ie. the latest rendered one)
  36829. * @returns the cached effect
  36830. */
  36831. getCachedEffect(): Nullable<Effect>;
  36832. /**
  36833. * Gets the cached visibility state (ie. the latest rendered one)
  36834. * @returns the cached visibility state
  36835. */
  36836. getCachedVisibility(): Nullable<number>;
  36837. /**
  36838. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36839. * @param material defines the current material
  36840. * @param effect defines the current effect
  36841. * @param visibility defines the current visibility state
  36842. * @returns true if one parameter is not cached
  36843. */
  36844. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36845. /**
  36846. * Gets the engine associated with the scene
  36847. * @returns an Engine
  36848. */
  36849. getEngine(): Engine;
  36850. /**
  36851. * Gets the total number of vertices rendered per frame
  36852. * @returns the total number of vertices rendered per frame
  36853. */
  36854. getTotalVertices(): number;
  36855. /**
  36856. * Gets the performance counter for total vertices
  36857. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36858. */
  36859. get totalVerticesPerfCounter(): PerfCounter;
  36860. /**
  36861. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36862. * @returns the total number of active indices rendered per frame
  36863. */
  36864. getActiveIndices(): number;
  36865. /**
  36866. * Gets the performance counter for active indices
  36867. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36868. */
  36869. get totalActiveIndicesPerfCounter(): PerfCounter;
  36870. /**
  36871. * Gets the total number of active particles rendered per frame
  36872. * @returns the total number of active particles rendered per frame
  36873. */
  36874. getActiveParticles(): number;
  36875. /**
  36876. * Gets the performance counter for active particles
  36877. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36878. */
  36879. get activeParticlesPerfCounter(): PerfCounter;
  36880. /**
  36881. * Gets the total number of active bones rendered per frame
  36882. * @returns the total number of active bones rendered per frame
  36883. */
  36884. getActiveBones(): number;
  36885. /**
  36886. * Gets the performance counter for active bones
  36887. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36888. */
  36889. get activeBonesPerfCounter(): PerfCounter;
  36890. /**
  36891. * Gets the array of active meshes
  36892. * @returns an array of AbstractMesh
  36893. */
  36894. getActiveMeshes(): SmartArray<AbstractMesh>;
  36895. /**
  36896. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36897. * @returns a number
  36898. */
  36899. getAnimationRatio(): number;
  36900. /**
  36901. * Gets an unique Id for the current render phase
  36902. * @returns a number
  36903. */
  36904. getRenderId(): number;
  36905. /**
  36906. * Gets an unique Id for the current frame
  36907. * @returns a number
  36908. */
  36909. getFrameId(): number;
  36910. /** Call this function if you want to manually increment the render Id*/
  36911. incrementRenderId(): void;
  36912. private _createUbo;
  36913. /**
  36914. * Use this method to simulate a pointer move on a mesh
  36915. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36916. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36917. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36918. * @returns the current scene
  36919. */
  36920. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36921. /**
  36922. * Use this method to simulate a pointer down on a mesh
  36923. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36924. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36925. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36926. * @returns the current scene
  36927. */
  36928. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36929. /**
  36930. * Use this method to simulate a pointer up on a mesh
  36931. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36932. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36933. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36934. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36935. * @returns the current scene
  36936. */
  36937. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36938. /**
  36939. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36940. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36941. * @returns true if the pointer was captured
  36942. */
  36943. isPointerCaptured(pointerId?: number): boolean;
  36944. /**
  36945. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36946. * @param attachUp defines if you want to attach events to pointerup
  36947. * @param attachDown defines if you want to attach events to pointerdown
  36948. * @param attachMove defines if you want to attach events to pointermove
  36949. */
  36950. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36951. /** Detaches all event handlers*/
  36952. detachControl(): void;
  36953. /**
  36954. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36955. * Delay loaded resources are not taking in account
  36956. * @return true if all required resources are ready
  36957. */
  36958. isReady(): boolean;
  36959. /** Resets all cached information relative to material (including effect and visibility) */
  36960. resetCachedMaterial(): void;
  36961. /**
  36962. * Registers a function to be called before every frame render
  36963. * @param func defines the function to register
  36964. */
  36965. registerBeforeRender(func: () => void): void;
  36966. /**
  36967. * Unregisters a function called before every frame render
  36968. * @param func defines the function to unregister
  36969. */
  36970. unregisterBeforeRender(func: () => void): void;
  36971. /**
  36972. * Registers a function to be called after every frame render
  36973. * @param func defines the function to register
  36974. */
  36975. registerAfterRender(func: () => void): void;
  36976. /**
  36977. * Unregisters a function called after every frame render
  36978. * @param func defines the function to unregister
  36979. */
  36980. unregisterAfterRender(func: () => void): void;
  36981. private _executeOnceBeforeRender;
  36982. /**
  36983. * The provided function will run before render once and will be disposed afterwards.
  36984. * A timeout delay can be provided so that the function will be executed in N ms.
  36985. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36986. * @param func The function to be executed.
  36987. * @param timeout optional delay in ms
  36988. */
  36989. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36990. /** @hidden */
  36991. _addPendingData(data: any): void;
  36992. /** @hidden */
  36993. _removePendingData(data: any): void;
  36994. /**
  36995. * Returns the number of items waiting to be loaded
  36996. * @returns the number of items waiting to be loaded
  36997. */
  36998. getWaitingItemsCount(): number;
  36999. /**
  37000. * Returns a boolean indicating if the scene is still loading data
  37001. */
  37002. get isLoading(): boolean;
  37003. /**
  37004. * Registers a function to be executed when the scene is ready
  37005. * @param {Function} func - the function to be executed
  37006. */
  37007. executeWhenReady(func: () => void): void;
  37008. /**
  37009. * Returns a promise that resolves when the scene is ready
  37010. * @returns A promise that resolves when the scene is ready
  37011. */
  37012. whenReadyAsync(): Promise<void>;
  37013. /** @hidden */
  37014. _checkIsReady(): void;
  37015. /**
  37016. * Gets all animatable attached to the scene
  37017. */
  37018. get animatables(): Animatable[];
  37019. /**
  37020. * Resets the last animation time frame.
  37021. * Useful to override when animations start running when loading a scene for the first time.
  37022. */
  37023. resetLastAnimationTimeFrame(): void;
  37024. /**
  37025. * Gets the current view matrix
  37026. * @returns a Matrix
  37027. */
  37028. getViewMatrix(): Matrix;
  37029. /**
  37030. * Gets the current projection matrix
  37031. * @returns a Matrix
  37032. */
  37033. getProjectionMatrix(): Matrix;
  37034. /**
  37035. * Gets the current transform matrix
  37036. * @returns a Matrix made of View * Projection
  37037. */
  37038. getTransformMatrix(): Matrix;
  37039. /**
  37040. * Sets the current transform matrix
  37041. * @param viewL defines the View matrix to use
  37042. * @param projectionL defines the Projection matrix to use
  37043. * @param viewR defines the right View matrix to use (if provided)
  37044. * @param projectionR defines the right Projection matrix to use (if provided)
  37045. */
  37046. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37047. /**
  37048. * Gets the uniform buffer used to store scene data
  37049. * @returns a UniformBuffer
  37050. */
  37051. getSceneUniformBuffer(): UniformBuffer;
  37052. /**
  37053. * Gets an unique (relatively to the current scene) Id
  37054. * @returns an unique number for the scene
  37055. */
  37056. getUniqueId(): number;
  37057. /**
  37058. * Add a mesh to the list of scene's meshes
  37059. * @param newMesh defines the mesh to add
  37060. * @param recursive if all child meshes should also be added to the scene
  37061. */
  37062. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37063. /**
  37064. * Remove a mesh for the list of scene's meshes
  37065. * @param toRemove defines the mesh to remove
  37066. * @param recursive if all child meshes should also be removed from the scene
  37067. * @returns the index where the mesh was in the mesh list
  37068. */
  37069. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37070. /**
  37071. * Add a transform node to the list of scene's transform nodes
  37072. * @param newTransformNode defines the transform node to add
  37073. */
  37074. addTransformNode(newTransformNode: TransformNode): void;
  37075. /**
  37076. * Remove a transform node for the list of scene's transform nodes
  37077. * @param toRemove defines the transform node to remove
  37078. * @returns the index where the transform node was in the transform node list
  37079. */
  37080. removeTransformNode(toRemove: TransformNode): number;
  37081. /**
  37082. * Remove a skeleton for the list of scene's skeletons
  37083. * @param toRemove defines the skeleton to remove
  37084. * @returns the index where the skeleton was in the skeleton list
  37085. */
  37086. removeSkeleton(toRemove: Skeleton): number;
  37087. /**
  37088. * Remove a morph target for the list of scene's morph targets
  37089. * @param toRemove defines the morph target to remove
  37090. * @returns the index where the morph target was in the morph target list
  37091. */
  37092. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37093. /**
  37094. * Remove a light for the list of scene's lights
  37095. * @param toRemove defines the light to remove
  37096. * @returns the index where the light was in the light list
  37097. */
  37098. removeLight(toRemove: Light): number;
  37099. /**
  37100. * Remove a camera for the list of scene's cameras
  37101. * @param toRemove defines the camera to remove
  37102. * @returns the index where the camera was in the camera list
  37103. */
  37104. removeCamera(toRemove: Camera): number;
  37105. /**
  37106. * Remove a particle system for the list of scene's particle systems
  37107. * @param toRemove defines the particle system to remove
  37108. * @returns the index where the particle system was in the particle system list
  37109. */
  37110. removeParticleSystem(toRemove: IParticleSystem): number;
  37111. /**
  37112. * Remove a animation for the list of scene's animations
  37113. * @param toRemove defines the animation to remove
  37114. * @returns the index where the animation was in the animation list
  37115. */
  37116. removeAnimation(toRemove: Animation): number;
  37117. /**
  37118. * Will stop the animation of the given target
  37119. * @param target - the target
  37120. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37121. * @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)
  37122. */
  37123. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37124. /**
  37125. * Removes the given animation group from this scene.
  37126. * @param toRemove The animation group to remove
  37127. * @returns The index of the removed animation group
  37128. */
  37129. removeAnimationGroup(toRemove: AnimationGroup): number;
  37130. /**
  37131. * Removes the given multi-material from this scene.
  37132. * @param toRemove The multi-material to remove
  37133. * @returns The index of the removed multi-material
  37134. */
  37135. removeMultiMaterial(toRemove: MultiMaterial): number;
  37136. /**
  37137. * Removes the given material from this scene.
  37138. * @param toRemove The material to remove
  37139. * @returns The index of the removed material
  37140. */
  37141. removeMaterial(toRemove: Material): number;
  37142. /**
  37143. * Removes the given action manager from this scene.
  37144. * @param toRemove The action manager to remove
  37145. * @returns The index of the removed action manager
  37146. */
  37147. removeActionManager(toRemove: AbstractActionManager): number;
  37148. /**
  37149. * Removes the given texture from this scene.
  37150. * @param toRemove The texture to remove
  37151. * @returns The index of the removed texture
  37152. */
  37153. removeTexture(toRemove: BaseTexture): number;
  37154. /**
  37155. * Adds the given light to this scene
  37156. * @param newLight The light to add
  37157. */
  37158. addLight(newLight: Light): void;
  37159. /**
  37160. * Sorts the list list based on light priorities
  37161. */
  37162. sortLightsByPriority(): void;
  37163. /**
  37164. * Adds the given camera to this scene
  37165. * @param newCamera The camera to add
  37166. */
  37167. addCamera(newCamera: Camera): void;
  37168. /**
  37169. * Adds the given skeleton to this scene
  37170. * @param newSkeleton The skeleton to add
  37171. */
  37172. addSkeleton(newSkeleton: Skeleton): void;
  37173. /**
  37174. * Adds the given particle system to this scene
  37175. * @param newParticleSystem The particle system to add
  37176. */
  37177. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37178. /**
  37179. * Adds the given animation to this scene
  37180. * @param newAnimation The animation to add
  37181. */
  37182. addAnimation(newAnimation: Animation): void;
  37183. /**
  37184. * Adds the given animation group to this scene.
  37185. * @param newAnimationGroup The animation group to add
  37186. */
  37187. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37188. /**
  37189. * Adds the given multi-material to this scene
  37190. * @param newMultiMaterial The multi-material to add
  37191. */
  37192. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37193. /**
  37194. * Adds the given material to this scene
  37195. * @param newMaterial The material to add
  37196. */
  37197. addMaterial(newMaterial: Material): void;
  37198. /**
  37199. * Adds the given morph target to this scene
  37200. * @param newMorphTargetManager The morph target to add
  37201. */
  37202. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37203. /**
  37204. * Adds the given geometry to this scene
  37205. * @param newGeometry The geometry to add
  37206. */
  37207. addGeometry(newGeometry: Geometry): void;
  37208. /**
  37209. * Adds the given action manager to this scene
  37210. * @param newActionManager The action manager to add
  37211. */
  37212. addActionManager(newActionManager: AbstractActionManager): void;
  37213. /**
  37214. * Adds the given texture to this scene.
  37215. * @param newTexture The texture to add
  37216. */
  37217. addTexture(newTexture: BaseTexture): void;
  37218. /**
  37219. * Switch active camera
  37220. * @param newCamera defines the new active camera
  37221. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37222. */
  37223. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37224. /**
  37225. * sets the active camera of the scene using its ID
  37226. * @param id defines the camera's ID
  37227. * @return the new active camera or null if none found.
  37228. */
  37229. setActiveCameraByID(id: string): Nullable<Camera>;
  37230. /**
  37231. * sets the active camera of the scene using its name
  37232. * @param name defines the camera's name
  37233. * @returns the new active camera or null if none found.
  37234. */
  37235. setActiveCameraByName(name: string): Nullable<Camera>;
  37236. /**
  37237. * get an animation group using its name
  37238. * @param name defines the material's name
  37239. * @return the animation group or null if none found.
  37240. */
  37241. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37242. /**
  37243. * Get a material using its unique id
  37244. * @param uniqueId defines the material's unique id
  37245. * @return the material or null if none found.
  37246. */
  37247. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37248. /**
  37249. * get a material using its id
  37250. * @param id defines the material's ID
  37251. * @return the material or null if none found.
  37252. */
  37253. getMaterialByID(id: string): Nullable<Material>;
  37254. /**
  37255. * Gets a the last added material using a given id
  37256. * @param id defines the material's ID
  37257. * @return the last material with the given id or null if none found.
  37258. */
  37259. getLastMaterialByID(id: string): Nullable<Material>;
  37260. /**
  37261. * Gets a material using its name
  37262. * @param name defines the material's name
  37263. * @return the material or null if none found.
  37264. */
  37265. getMaterialByName(name: string): Nullable<Material>;
  37266. /**
  37267. * Get a texture using its unique id
  37268. * @param uniqueId defines the texture's unique id
  37269. * @return the texture or null if none found.
  37270. */
  37271. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37272. /**
  37273. * Gets a camera using its id
  37274. * @param id defines the id to look for
  37275. * @returns the camera or null if not found
  37276. */
  37277. getCameraByID(id: string): Nullable<Camera>;
  37278. /**
  37279. * Gets a camera using its unique id
  37280. * @param uniqueId defines the unique id to look for
  37281. * @returns the camera or null if not found
  37282. */
  37283. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37284. /**
  37285. * Gets a camera using its name
  37286. * @param name defines the camera's name
  37287. * @return the camera or null if none found.
  37288. */
  37289. getCameraByName(name: string): Nullable<Camera>;
  37290. /**
  37291. * Gets a bone using its id
  37292. * @param id defines the bone's id
  37293. * @return the bone or null if not found
  37294. */
  37295. getBoneByID(id: string): Nullable<Bone>;
  37296. /**
  37297. * Gets a bone using its id
  37298. * @param name defines the bone's name
  37299. * @return the bone or null if not found
  37300. */
  37301. getBoneByName(name: string): Nullable<Bone>;
  37302. /**
  37303. * Gets a light node using its name
  37304. * @param name defines the the light's name
  37305. * @return the light or null if none found.
  37306. */
  37307. getLightByName(name: string): Nullable<Light>;
  37308. /**
  37309. * Gets a light node using its id
  37310. * @param id defines the light's id
  37311. * @return the light or null if none found.
  37312. */
  37313. getLightByID(id: string): Nullable<Light>;
  37314. /**
  37315. * Gets a light node using its scene-generated unique ID
  37316. * @param uniqueId defines the light's unique id
  37317. * @return the light or null if none found.
  37318. */
  37319. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37320. /**
  37321. * Gets a particle system by id
  37322. * @param id defines the particle system id
  37323. * @return the corresponding system or null if none found
  37324. */
  37325. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37326. /**
  37327. * Gets a geometry using its ID
  37328. * @param id defines the geometry's id
  37329. * @return the geometry or null if none found.
  37330. */
  37331. getGeometryByID(id: string): Nullable<Geometry>;
  37332. private _getGeometryByUniqueID;
  37333. /**
  37334. * Add a new geometry to this scene
  37335. * @param geometry defines the geometry to be added to the scene.
  37336. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37337. * @return a boolean defining if the geometry was added or not
  37338. */
  37339. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37340. /**
  37341. * Removes an existing geometry
  37342. * @param geometry defines the geometry to be removed from the scene
  37343. * @return a boolean defining if the geometry was removed or not
  37344. */
  37345. removeGeometry(geometry: Geometry): boolean;
  37346. /**
  37347. * Gets the list of geometries attached to the scene
  37348. * @returns an array of Geometry
  37349. */
  37350. getGeometries(): Geometry[];
  37351. /**
  37352. * Gets the first added mesh found of a given ID
  37353. * @param id defines the id to search for
  37354. * @return the mesh found or null if not found at all
  37355. */
  37356. getMeshByID(id: string): Nullable<AbstractMesh>;
  37357. /**
  37358. * Gets a list of meshes using their id
  37359. * @param id defines the id to search for
  37360. * @returns a list of meshes
  37361. */
  37362. getMeshesByID(id: string): Array<AbstractMesh>;
  37363. /**
  37364. * Gets the first added transform node found of a given ID
  37365. * @param id defines the id to search for
  37366. * @return the found transform node or null if not found at all.
  37367. */
  37368. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37369. /**
  37370. * Gets a transform node with its auto-generated unique id
  37371. * @param uniqueId efines the unique id to search for
  37372. * @return the found transform node or null if not found at all.
  37373. */
  37374. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37375. /**
  37376. * Gets a list of transform nodes using their id
  37377. * @param id defines the id to search for
  37378. * @returns a list of transform nodes
  37379. */
  37380. getTransformNodesByID(id: string): Array<TransformNode>;
  37381. /**
  37382. * Gets a mesh with its auto-generated unique id
  37383. * @param uniqueId defines the unique id to search for
  37384. * @return the found mesh or null if not found at all.
  37385. */
  37386. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37387. /**
  37388. * Gets a the last added mesh using a given id
  37389. * @param id defines the id to search for
  37390. * @return the found mesh or null if not found at all.
  37391. */
  37392. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37393. /**
  37394. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37395. * @param id defines the id to search for
  37396. * @return the found node or null if not found at all
  37397. */
  37398. getLastEntryByID(id: string): Nullable<Node>;
  37399. /**
  37400. * Gets a node (Mesh, Camera, Light) using a given id
  37401. * @param id defines the id to search for
  37402. * @return the found node or null if not found at all
  37403. */
  37404. getNodeByID(id: string): Nullable<Node>;
  37405. /**
  37406. * Gets a node (Mesh, Camera, Light) using a given name
  37407. * @param name defines the name to search for
  37408. * @return the found node or null if not found at all.
  37409. */
  37410. getNodeByName(name: string): Nullable<Node>;
  37411. /**
  37412. * Gets a mesh using a given name
  37413. * @param name defines the name to search for
  37414. * @return the found mesh or null if not found at all.
  37415. */
  37416. getMeshByName(name: string): Nullable<AbstractMesh>;
  37417. /**
  37418. * Gets a transform node using a given name
  37419. * @param name defines the name to search for
  37420. * @return the found transform node or null if not found at all.
  37421. */
  37422. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37423. /**
  37424. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37425. * @param id defines the id to search for
  37426. * @return the found skeleton or null if not found at all.
  37427. */
  37428. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37429. /**
  37430. * Gets a skeleton using a given auto generated unique id
  37431. * @param uniqueId defines the unique id to search for
  37432. * @return the found skeleton or null if not found at all.
  37433. */
  37434. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37435. /**
  37436. * Gets a skeleton 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 skeleton or null if not found at all.
  37439. */
  37440. getSkeletonById(id: string): Nullable<Skeleton>;
  37441. /**
  37442. * Gets a skeleton using a given name
  37443. * @param name defines the name to search for
  37444. * @return the found skeleton or null if not found at all.
  37445. */
  37446. getSkeletonByName(name: string): Nullable<Skeleton>;
  37447. /**
  37448. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37449. * @param id defines the id to search for
  37450. * @return the found morph target manager or null if not found at all.
  37451. */
  37452. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37453. /**
  37454. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37455. * @param id defines the id to search for
  37456. * @return the found morph target or null if not found at all.
  37457. */
  37458. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37459. /**
  37460. * Gets a boolean indicating if the given mesh is active
  37461. * @param mesh defines the mesh to look for
  37462. * @returns true if the mesh is in the active list
  37463. */
  37464. isActiveMesh(mesh: AbstractMesh): boolean;
  37465. /**
  37466. * Return a unique id as a string which can serve as an identifier for the scene
  37467. */
  37468. get uid(): string;
  37469. /**
  37470. * Add an externaly attached data from its key.
  37471. * This method call will fail and return false, if such key already exists.
  37472. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37473. * @param key the unique key that identifies the data
  37474. * @param data the data object to associate to the key for this Engine instance
  37475. * @return true if no such key were already present and the data was added successfully, false otherwise
  37476. */
  37477. addExternalData<T>(key: string, data: T): boolean;
  37478. /**
  37479. * Get an externaly attached data from its key
  37480. * @param key the unique key that identifies the data
  37481. * @return the associated data, if present (can be null), or undefined if not present
  37482. */
  37483. getExternalData<T>(key: string): Nullable<T>;
  37484. /**
  37485. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37486. * @param key the unique key that identifies the data
  37487. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37488. * @return the associated data, can be null if the factory returned null.
  37489. */
  37490. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37491. /**
  37492. * Remove an externaly attached data from the Engine instance
  37493. * @param key the unique key that identifies the data
  37494. * @return true if the data was successfully removed, false if it doesn't exist
  37495. */
  37496. removeExternalData(key: string): boolean;
  37497. private _evaluateSubMesh;
  37498. /**
  37499. * Clear the processed materials smart array preventing retention point in material dispose.
  37500. */
  37501. freeProcessedMaterials(): void;
  37502. private _preventFreeActiveMeshesAndRenderingGroups;
  37503. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37504. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37505. * when disposing several meshes in a row or a hierarchy of meshes.
  37506. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37507. */
  37508. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37509. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37510. /**
  37511. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37512. */
  37513. freeActiveMeshes(): void;
  37514. /**
  37515. * Clear the info related to rendering groups preventing retention points during dispose.
  37516. */
  37517. freeRenderingGroups(): void;
  37518. /** @hidden */
  37519. _isInIntermediateRendering(): boolean;
  37520. /**
  37521. * Lambda returning the list of potentially active meshes.
  37522. */
  37523. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37524. /**
  37525. * Lambda returning the list of potentially active sub meshes.
  37526. */
  37527. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37528. /**
  37529. * Lambda returning the list of potentially intersecting sub meshes.
  37530. */
  37531. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37532. /**
  37533. * Lambda returning the list of potentially colliding sub meshes.
  37534. */
  37535. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37536. private _activeMeshesFrozen;
  37537. private _skipEvaluateActiveMeshesCompletely;
  37538. /**
  37539. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37540. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37541. * @returns the current scene
  37542. */
  37543. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37544. /**
  37545. * Use this function to restart evaluating active meshes on every frame
  37546. * @returns the current scene
  37547. */
  37548. unfreezeActiveMeshes(): Scene;
  37549. private _evaluateActiveMeshes;
  37550. private _activeMesh;
  37551. /**
  37552. * Update the transform matrix to update from the current active camera
  37553. * @param force defines a boolean used to force the update even if cache is up to date
  37554. */
  37555. updateTransformMatrix(force?: boolean): void;
  37556. private _bindFrameBuffer;
  37557. /** @hidden */
  37558. _allowPostProcessClearColor: boolean;
  37559. /** @hidden */
  37560. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37561. private _processSubCameras;
  37562. private _checkIntersections;
  37563. /** @hidden */
  37564. _advancePhysicsEngineStep(step: number): void;
  37565. /**
  37566. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37567. */
  37568. getDeterministicFrameTime: () => number;
  37569. /** @hidden */
  37570. _animate(): void;
  37571. /** Execute all animations (for a frame) */
  37572. animate(): void;
  37573. /**
  37574. * Render the scene
  37575. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37576. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37577. */
  37578. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37579. /**
  37580. * Freeze all materials
  37581. * A frozen material will not be updatable but should be faster to render
  37582. */
  37583. freezeMaterials(): void;
  37584. /**
  37585. * Unfreeze all materials
  37586. * A frozen material will not be updatable but should be faster to render
  37587. */
  37588. unfreezeMaterials(): void;
  37589. /**
  37590. * Releases all held ressources
  37591. */
  37592. dispose(): void;
  37593. /**
  37594. * Gets if the scene is already disposed
  37595. */
  37596. get isDisposed(): boolean;
  37597. /**
  37598. * Call this function to reduce memory footprint of the scene.
  37599. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37600. */
  37601. clearCachedVertexData(): void;
  37602. /**
  37603. * This function will remove the local cached buffer data from texture.
  37604. * It will save memory but will prevent the texture from being rebuilt
  37605. */
  37606. cleanCachedTextureBuffer(): void;
  37607. /**
  37608. * Get the world extend vectors with an optional filter
  37609. *
  37610. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37611. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37612. */
  37613. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37614. min: Vector3;
  37615. max: Vector3;
  37616. };
  37617. /**
  37618. * Creates a ray that can be used to pick in the scene
  37619. * @param x defines the x coordinate of the origin (on-screen)
  37620. * @param y defines the y coordinate of the origin (on-screen)
  37621. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37622. * @param camera defines the camera to use for the picking
  37623. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37624. * @returns a Ray
  37625. */
  37626. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37627. /**
  37628. * Creates a ray that can be used to pick in the scene
  37629. * @param x defines the x coordinate of the origin (on-screen)
  37630. * @param y defines the y coordinate of the origin (on-screen)
  37631. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37632. * @param result defines the ray where to store the picking ray
  37633. * @param camera defines the camera to use for the picking
  37634. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37635. * @returns the current scene
  37636. */
  37637. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37638. /**
  37639. * Creates a ray that can be used to pick in the scene
  37640. * @param x defines the x coordinate of the origin (on-screen)
  37641. * @param y defines the y coordinate of the origin (on-screen)
  37642. * @param camera defines the camera to use for the picking
  37643. * @returns a Ray
  37644. */
  37645. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37646. /**
  37647. * Creates a ray that can be used to pick in the scene
  37648. * @param x defines the x coordinate of the origin (on-screen)
  37649. * @param y defines the y coordinate of the origin (on-screen)
  37650. * @param result defines the ray where to store the picking ray
  37651. * @param camera defines the camera to use for the picking
  37652. * @returns the current scene
  37653. */
  37654. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37655. /** Launch a ray to try to pick a mesh in the scene
  37656. * @param x position on screen
  37657. * @param y position on screen
  37658. * @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
  37659. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37660. * @param 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 a PickingInfo
  37663. */
  37664. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37665. /** Use the given ray to pick a mesh in the scene
  37666. * @param ray The ray to use to pick meshes
  37667. * @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
  37668. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37669. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37670. * @returns a PickingInfo
  37671. */
  37672. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37673. /**
  37674. * Launch a ray to try to pick a mesh in the scene
  37675. * @param x X position on screen
  37676. * @param y Y position on screen
  37677. * @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
  37678. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37679. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37680. * @returns an array of PickingInfo
  37681. */
  37682. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37683. /**
  37684. * Launch a ray to try to pick a mesh in the scene
  37685. * @param ray Ray to use
  37686. * @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
  37687. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37688. * @returns an array of PickingInfo
  37689. */
  37690. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37691. /**
  37692. * Force the value of meshUnderPointer
  37693. * @param mesh defines the mesh to use
  37694. */
  37695. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37696. /**
  37697. * Gets the mesh under the pointer
  37698. * @returns a Mesh or null if no mesh is under the pointer
  37699. */
  37700. getPointerOverMesh(): Nullable<AbstractMesh>;
  37701. /** @hidden */
  37702. _rebuildGeometries(): void;
  37703. /** @hidden */
  37704. _rebuildTextures(): void;
  37705. private _getByTags;
  37706. /**
  37707. * Get a list of meshes by tags
  37708. * @param tagsQuery defines the tags query to use
  37709. * @param forEach defines a predicate used to filter results
  37710. * @returns an array of Mesh
  37711. */
  37712. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37713. /**
  37714. * Get a list of cameras by tags
  37715. * @param tagsQuery defines the tags query to use
  37716. * @param forEach defines a predicate used to filter results
  37717. * @returns an array of Camera
  37718. */
  37719. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37720. /**
  37721. * Get a list of lights by tags
  37722. * @param tagsQuery defines the tags query to use
  37723. * @param forEach defines a predicate used to filter results
  37724. * @returns an array of Light
  37725. */
  37726. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37727. /**
  37728. * Get a list of materials by tags
  37729. * @param tagsQuery defines the tags query to use
  37730. * @param forEach defines a predicate used to filter results
  37731. * @returns an array of Material
  37732. */
  37733. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37734. /**
  37735. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37736. * This allowed control for front to back rendering or reversly depending of the special needs.
  37737. *
  37738. * @param renderingGroupId The rendering group id corresponding to its index
  37739. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37740. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37741. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37742. */
  37743. 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;
  37744. /**
  37745. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37746. *
  37747. * @param renderingGroupId The rendering group id corresponding to its index
  37748. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37749. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37750. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37751. */
  37752. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37753. /**
  37754. * Gets the current auto clear configuration for one rendering group of the rendering
  37755. * manager.
  37756. * @param index the rendering group index to get the information for
  37757. * @returns The auto clear setup for the requested rendering group
  37758. */
  37759. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37760. private _blockMaterialDirtyMechanism;
  37761. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37762. get blockMaterialDirtyMechanism(): boolean;
  37763. set blockMaterialDirtyMechanism(value: boolean);
  37764. /**
  37765. * Will flag all materials as dirty to trigger new shader compilation
  37766. * @param flag defines the flag used to specify which material part must be marked as dirty
  37767. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37768. */
  37769. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37770. /** @hidden */
  37771. _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;
  37772. /** @hidden */
  37773. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37774. /** @hidden */
  37775. _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;
  37776. /** @hidden */
  37777. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37778. /** @hidden */
  37779. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37780. /** @hidden */
  37781. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37782. }
  37783. }
  37784. declare module "babylonjs/assetContainer" {
  37785. import { AbstractScene } from "babylonjs/abstractScene";
  37786. import { Scene } from "babylonjs/scene";
  37787. import { Mesh } from "babylonjs/Meshes/mesh";
  37788. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37789. import { Skeleton } from "babylonjs/Bones/skeleton";
  37790. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37791. import { Animatable } from "babylonjs/Animations/animatable";
  37792. import { Nullable } from "babylonjs/types";
  37793. import { Node } from "babylonjs/node";
  37794. /**
  37795. * Set of assets to keep when moving a scene into an asset container.
  37796. */
  37797. export class KeepAssets extends AbstractScene {
  37798. }
  37799. /**
  37800. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37801. */
  37802. export class InstantiatedEntries {
  37803. /**
  37804. * List of new root nodes (eg. nodes with no parent)
  37805. */
  37806. rootNodes: TransformNode[];
  37807. /**
  37808. * List of new skeletons
  37809. */
  37810. skeletons: Skeleton[];
  37811. /**
  37812. * List of new animation groups
  37813. */
  37814. animationGroups: AnimationGroup[];
  37815. }
  37816. /**
  37817. * Container with a set of assets that can be added or removed from a scene.
  37818. */
  37819. export class AssetContainer extends AbstractScene {
  37820. /**
  37821. * The scene the AssetContainer belongs to.
  37822. */
  37823. scene: Scene;
  37824. /**
  37825. * Instantiates an AssetContainer.
  37826. * @param scene The scene the AssetContainer belongs to.
  37827. */
  37828. constructor(scene: Scene);
  37829. /**
  37830. * Instantiate or clone all meshes and add the new ones to the scene.
  37831. * Skeletons and animation groups will all be cloned
  37832. * @param nameFunction defines an optional function used to get new names for clones
  37833. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37834. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37835. */
  37836. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37837. /**
  37838. * Adds all the assets from the container to the scene.
  37839. */
  37840. addAllToScene(): void;
  37841. /**
  37842. * Removes all the assets in the container from the scene
  37843. */
  37844. removeAllFromScene(): void;
  37845. /**
  37846. * Disposes all the assets in the container
  37847. */
  37848. dispose(): void;
  37849. private _moveAssets;
  37850. /**
  37851. * Removes all the assets contained in the scene and adds them to the container.
  37852. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37853. */
  37854. moveAllFromScene(keepAssets?: KeepAssets): void;
  37855. /**
  37856. * 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.
  37857. * @returns the root mesh
  37858. */
  37859. createRootMesh(): Mesh;
  37860. /**
  37861. * Merge animations from this asset container into a scene
  37862. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37863. * @param animatables set of animatables to retarget to a node from the scene
  37864. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37865. */
  37866. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37867. }
  37868. }
  37869. declare module "babylonjs/abstractScene" {
  37870. import { Scene } from "babylonjs/scene";
  37871. import { Nullable } from "babylonjs/types";
  37872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37873. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37874. import { Geometry } from "babylonjs/Meshes/geometry";
  37875. import { Skeleton } from "babylonjs/Bones/skeleton";
  37876. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37877. import { AssetContainer } from "babylonjs/assetContainer";
  37878. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37879. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37881. import { Material } from "babylonjs/Materials/material";
  37882. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37883. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37884. import { Camera } from "babylonjs/Cameras/camera";
  37885. import { Light } from "babylonjs/Lights/light";
  37886. import { Node } from "babylonjs/node";
  37887. import { Animation } from "babylonjs/Animations/animation";
  37888. /**
  37889. * Defines how the parser contract is defined.
  37890. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37891. */
  37892. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37893. /**
  37894. * Defines how the individual parser contract is defined.
  37895. * These parser can parse an individual asset
  37896. */
  37897. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37898. /**
  37899. * Base class of the scene acting as a container for the different elements composing a scene.
  37900. * This class is dynamically extended by the different components of the scene increasing
  37901. * flexibility and reducing coupling
  37902. */
  37903. export abstract class AbstractScene {
  37904. /**
  37905. * Stores the list of available parsers in the application.
  37906. */
  37907. private static _BabylonFileParsers;
  37908. /**
  37909. * Stores the list of available individual parsers in the application.
  37910. */
  37911. private static _IndividualBabylonFileParsers;
  37912. /**
  37913. * Adds a parser in the list of available ones
  37914. * @param name Defines the name of the parser
  37915. * @param parser Defines the parser to add
  37916. */
  37917. static AddParser(name: string, parser: BabylonFileParser): void;
  37918. /**
  37919. * Gets a general parser from the list of avaialble ones
  37920. * @param name Defines the name of the parser
  37921. * @returns the requested parser or null
  37922. */
  37923. static GetParser(name: string): Nullable<BabylonFileParser>;
  37924. /**
  37925. * Adds n individual parser in the list of available ones
  37926. * @param name Defines the name of the parser
  37927. * @param parser Defines the parser to add
  37928. */
  37929. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37930. /**
  37931. * Gets an individual parser from the list of avaialble ones
  37932. * @param name Defines the name of the parser
  37933. * @returns the requested parser or null
  37934. */
  37935. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37936. /**
  37937. * Parser json data and populate both a scene and its associated container object
  37938. * @param jsonData Defines the data to parse
  37939. * @param scene Defines the scene to parse the data for
  37940. * @param container Defines the container attached to the parsing sequence
  37941. * @param rootUrl Defines the root url of the data
  37942. */
  37943. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37944. /**
  37945. * Gets the list of root nodes (ie. nodes with no parent)
  37946. */
  37947. rootNodes: Node[];
  37948. /** All of the cameras added to this scene
  37949. * @see http://doc.babylonjs.com/babylon101/cameras
  37950. */
  37951. cameras: Camera[];
  37952. /**
  37953. * All of the lights added to this scene
  37954. * @see http://doc.babylonjs.com/babylon101/lights
  37955. */
  37956. lights: Light[];
  37957. /**
  37958. * All of the (abstract) meshes added to this scene
  37959. */
  37960. meshes: AbstractMesh[];
  37961. /**
  37962. * The list of skeletons added to the scene
  37963. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37964. */
  37965. skeletons: Skeleton[];
  37966. /**
  37967. * All of the particle systems added to this scene
  37968. * @see http://doc.babylonjs.com/babylon101/particles
  37969. */
  37970. particleSystems: IParticleSystem[];
  37971. /**
  37972. * Gets a list of Animations associated with the scene
  37973. */
  37974. animations: Animation[];
  37975. /**
  37976. * All of the animation groups added to this scene
  37977. * @see http://doc.babylonjs.com/how_to/group
  37978. */
  37979. animationGroups: AnimationGroup[];
  37980. /**
  37981. * All of the multi-materials added to this scene
  37982. * @see http://doc.babylonjs.com/how_to/multi_materials
  37983. */
  37984. multiMaterials: MultiMaterial[];
  37985. /**
  37986. * All of the materials added to this scene
  37987. * In the context of a Scene, it is not supposed to be modified manually.
  37988. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37989. * Note also that the order of the Material within the array is not significant and might change.
  37990. * @see http://doc.babylonjs.com/babylon101/materials
  37991. */
  37992. materials: Material[];
  37993. /**
  37994. * The list of morph target managers added to the scene
  37995. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37996. */
  37997. morphTargetManagers: MorphTargetManager[];
  37998. /**
  37999. * The list of geometries used in the scene.
  38000. */
  38001. geometries: Geometry[];
  38002. /**
  38003. * All of the tranform nodes added to this scene
  38004. * In the context of a Scene, it is not supposed to be modified manually.
  38005. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38006. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38007. * @see http://doc.babylonjs.com/how_to/transformnode
  38008. */
  38009. transformNodes: TransformNode[];
  38010. /**
  38011. * ActionManagers available on the scene.
  38012. */
  38013. actionManagers: AbstractActionManager[];
  38014. /**
  38015. * Textures to keep.
  38016. */
  38017. textures: BaseTexture[];
  38018. /**
  38019. * Environment texture for the scene
  38020. */
  38021. environmentTexture: Nullable<BaseTexture>;
  38022. /**
  38023. * @returns all meshes, lights, cameras, transformNodes and bones
  38024. */
  38025. getNodes(): Array<Node>;
  38026. }
  38027. }
  38028. declare module "babylonjs/Audio/sound" {
  38029. import { Observable } from "babylonjs/Misc/observable";
  38030. import { Vector3 } from "babylonjs/Maths/math.vector";
  38031. import { Nullable } from "babylonjs/types";
  38032. import { Scene } from "babylonjs/scene";
  38033. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38034. /**
  38035. * Interface used to define options for Sound class
  38036. */
  38037. export interface ISoundOptions {
  38038. /**
  38039. * Does the sound autoplay once loaded.
  38040. */
  38041. autoplay?: boolean;
  38042. /**
  38043. * Does the sound loop after it finishes playing once.
  38044. */
  38045. loop?: boolean;
  38046. /**
  38047. * Sound's volume
  38048. */
  38049. volume?: number;
  38050. /**
  38051. * Is it a spatial sound?
  38052. */
  38053. spatialSound?: boolean;
  38054. /**
  38055. * Maximum distance to hear that sound
  38056. */
  38057. maxDistance?: number;
  38058. /**
  38059. * Uses user defined attenuation function
  38060. */
  38061. useCustomAttenuation?: boolean;
  38062. /**
  38063. * Define the roll off factor of spatial sounds.
  38064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38065. */
  38066. rolloffFactor?: number;
  38067. /**
  38068. * Define the reference distance the sound should be heard perfectly.
  38069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38070. */
  38071. refDistance?: number;
  38072. /**
  38073. * Define the distance attenuation model the sound will follow.
  38074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38075. */
  38076. distanceModel?: string;
  38077. /**
  38078. * Defines the playback speed (1 by default)
  38079. */
  38080. playbackRate?: number;
  38081. /**
  38082. * Defines if the sound is from a streaming source
  38083. */
  38084. streaming?: boolean;
  38085. /**
  38086. * Defines an optional length (in seconds) inside the sound file
  38087. */
  38088. length?: number;
  38089. /**
  38090. * Defines an optional offset (in seconds) inside the sound file
  38091. */
  38092. offset?: number;
  38093. /**
  38094. * If true, URLs will not be required to state the audio file codec to use.
  38095. */
  38096. skipCodecCheck?: boolean;
  38097. }
  38098. /**
  38099. * Defines a sound that can be played in the application.
  38100. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38102. */
  38103. export class Sound {
  38104. /**
  38105. * The name of the sound in the scene.
  38106. */
  38107. name: string;
  38108. /**
  38109. * Does the sound autoplay once loaded.
  38110. */
  38111. autoplay: boolean;
  38112. /**
  38113. * Does the sound loop after it finishes playing once.
  38114. */
  38115. loop: boolean;
  38116. /**
  38117. * Does the sound use a custom attenuation curve to simulate the falloff
  38118. * happening when the source gets further away from the camera.
  38119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38120. */
  38121. useCustomAttenuation: boolean;
  38122. /**
  38123. * The sound track id this sound belongs to.
  38124. */
  38125. soundTrackId: number;
  38126. /**
  38127. * Is this sound currently played.
  38128. */
  38129. isPlaying: boolean;
  38130. /**
  38131. * Is this sound currently paused.
  38132. */
  38133. isPaused: boolean;
  38134. /**
  38135. * Does this sound enables spatial sound.
  38136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38137. */
  38138. spatialSound: boolean;
  38139. /**
  38140. * Define the reference distance the sound should be heard perfectly.
  38141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38142. */
  38143. refDistance: number;
  38144. /**
  38145. * Define the roll off factor of spatial sounds.
  38146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38147. */
  38148. rolloffFactor: number;
  38149. /**
  38150. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38152. */
  38153. maxDistance: number;
  38154. /**
  38155. * Define the distance attenuation model the sound will follow.
  38156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38157. */
  38158. distanceModel: string;
  38159. /**
  38160. * @hidden
  38161. * Back Compat
  38162. **/
  38163. onended: () => any;
  38164. /**
  38165. * Observable event when the current playing sound finishes.
  38166. */
  38167. onEndedObservable: Observable<Sound>;
  38168. private _panningModel;
  38169. private _playbackRate;
  38170. private _streaming;
  38171. private _startTime;
  38172. private _startOffset;
  38173. private _position;
  38174. /** @hidden */
  38175. _positionInEmitterSpace: boolean;
  38176. private _localDirection;
  38177. private _volume;
  38178. private _isReadyToPlay;
  38179. private _isDirectional;
  38180. private _readyToPlayCallback;
  38181. private _audioBuffer;
  38182. private _soundSource;
  38183. private _streamingSource;
  38184. private _soundPanner;
  38185. private _soundGain;
  38186. private _inputAudioNode;
  38187. private _outputAudioNode;
  38188. private _coneInnerAngle;
  38189. private _coneOuterAngle;
  38190. private _coneOuterGain;
  38191. private _scene;
  38192. private _connectedTransformNode;
  38193. private _customAttenuationFunction;
  38194. private _registerFunc;
  38195. private _isOutputConnected;
  38196. private _htmlAudioElement;
  38197. private _urlType;
  38198. private _length?;
  38199. private _offset?;
  38200. /** @hidden */
  38201. static _SceneComponentInitialization: (scene: Scene) => void;
  38202. /**
  38203. * Create a sound and attach it to a scene
  38204. * @param name Name of your sound
  38205. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38206. * @param scene defines the scene the sound belongs to
  38207. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38208. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38209. */
  38210. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38211. /**
  38212. * Release the sound and its associated resources
  38213. */
  38214. dispose(): void;
  38215. /**
  38216. * Gets if the sounds is ready to be played or not.
  38217. * @returns true if ready, otherwise false
  38218. */
  38219. isReady(): boolean;
  38220. private _soundLoaded;
  38221. /**
  38222. * Sets the data of the sound from an audiobuffer
  38223. * @param audioBuffer The audioBuffer containing the data
  38224. */
  38225. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38226. /**
  38227. * Updates the current sounds options such as maxdistance, loop...
  38228. * @param options A JSON object containing values named as the object properties
  38229. */
  38230. updateOptions(options: ISoundOptions): void;
  38231. private _createSpatialParameters;
  38232. private _updateSpatialParameters;
  38233. /**
  38234. * Switch the panning model to HRTF:
  38235. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38237. */
  38238. switchPanningModelToHRTF(): void;
  38239. /**
  38240. * Switch the panning model to Equal Power:
  38241. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38243. */
  38244. switchPanningModelToEqualPower(): void;
  38245. private _switchPanningModel;
  38246. /**
  38247. * Connect this sound to a sound track audio node like gain...
  38248. * @param soundTrackAudioNode the sound track audio node to connect to
  38249. */
  38250. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38251. /**
  38252. * Transform this sound into a directional source
  38253. * @param coneInnerAngle Size of the inner cone in degree
  38254. * @param coneOuterAngle Size of the outer cone in degree
  38255. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38256. */
  38257. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38258. /**
  38259. * Gets or sets the inner angle for the directional cone.
  38260. */
  38261. get directionalConeInnerAngle(): number;
  38262. /**
  38263. * Gets or sets the inner angle for the directional cone.
  38264. */
  38265. set directionalConeInnerAngle(value: number);
  38266. /**
  38267. * Gets or sets the outer angle for the directional cone.
  38268. */
  38269. get directionalConeOuterAngle(): number;
  38270. /**
  38271. * Gets or sets the outer angle for the directional cone.
  38272. */
  38273. set directionalConeOuterAngle(value: number);
  38274. /**
  38275. * Sets the position of the emitter if spatial sound is enabled
  38276. * @param newPosition Defines the new posisiton
  38277. */
  38278. setPosition(newPosition: Vector3): void;
  38279. /**
  38280. * Sets the local direction of the emitter if spatial sound is enabled
  38281. * @param newLocalDirection Defines the new local direction
  38282. */
  38283. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38284. private _updateDirection;
  38285. /** @hidden */
  38286. updateDistanceFromListener(): void;
  38287. /**
  38288. * Sets a new custom attenuation function for the sound.
  38289. * @param callback Defines the function used for the attenuation
  38290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38291. */
  38292. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38293. /**
  38294. * Play the sound
  38295. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38296. * @param offset (optional) Start the sound at a specific time in seconds
  38297. * @param length (optional) Sound duration (in seconds)
  38298. */
  38299. play(time?: number, offset?: number, length?: number): void;
  38300. private _onended;
  38301. /**
  38302. * Stop the sound
  38303. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38304. */
  38305. stop(time?: number): void;
  38306. /**
  38307. * Put the sound in pause
  38308. */
  38309. pause(): void;
  38310. /**
  38311. * Sets a dedicated volume for this sounds
  38312. * @param newVolume Define the new volume of the sound
  38313. * @param time Define time for gradual change to new volume
  38314. */
  38315. setVolume(newVolume: number, time?: number): void;
  38316. /**
  38317. * Set the sound play back rate
  38318. * @param newPlaybackRate Define the playback rate the sound should be played at
  38319. */
  38320. setPlaybackRate(newPlaybackRate: number): void;
  38321. /**
  38322. * Gets the volume of the sound.
  38323. * @returns the volume of the sound
  38324. */
  38325. getVolume(): number;
  38326. /**
  38327. * Attach the sound to a dedicated mesh
  38328. * @param transformNode The transform node to connect the sound with
  38329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38330. */
  38331. attachToMesh(transformNode: TransformNode): void;
  38332. /**
  38333. * Detach the sound from the previously attached mesh
  38334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38335. */
  38336. detachFromMesh(): void;
  38337. private _onRegisterAfterWorldMatrixUpdate;
  38338. /**
  38339. * Clone the current sound in the scene.
  38340. * @returns the new sound clone
  38341. */
  38342. clone(): Nullable<Sound>;
  38343. /**
  38344. * Gets the current underlying audio buffer containing the data
  38345. * @returns the audio buffer
  38346. */
  38347. getAudioBuffer(): Nullable<AudioBuffer>;
  38348. /**
  38349. * Serializes the Sound in a JSON representation
  38350. * @returns the JSON representation of the sound
  38351. */
  38352. serialize(): any;
  38353. /**
  38354. * Parse a JSON representation of a sound to innstantiate in a given scene
  38355. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38356. * @param scene Define the scene the new parsed sound should be created in
  38357. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38358. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38359. * @returns the newly parsed sound
  38360. */
  38361. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38362. }
  38363. }
  38364. declare module "babylonjs/Actions/directAudioActions" {
  38365. import { Action } from "babylonjs/Actions/action";
  38366. import { Condition } from "babylonjs/Actions/condition";
  38367. import { Sound } from "babylonjs/Audio/sound";
  38368. /**
  38369. * This defines an action helpful to play a defined sound on a triggered action.
  38370. */
  38371. export class PlaySoundAction extends Action {
  38372. private _sound;
  38373. /**
  38374. * Instantiate the action
  38375. * @param triggerOptions defines the trigger options
  38376. * @param sound defines the sound to play
  38377. * @param condition defines the trigger related conditions
  38378. */
  38379. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38380. /** @hidden */
  38381. _prepare(): void;
  38382. /**
  38383. * Execute the action and play the sound.
  38384. */
  38385. execute(): void;
  38386. /**
  38387. * Serializes the actions and its related information.
  38388. * @param parent defines the object to serialize in
  38389. * @returns the serialized object
  38390. */
  38391. serialize(parent: any): any;
  38392. }
  38393. /**
  38394. * This defines an action helpful to stop a defined sound on a triggered action.
  38395. */
  38396. export class StopSoundAction extends Action {
  38397. private _sound;
  38398. /**
  38399. * Instantiate the action
  38400. * @param triggerOptions defines the trigger options
  38401. * @param sound defines the sound to stop
  38402. * @param condition defines the trigger related conditions
  38403. */
  38404. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38405. /** @hidden */
  38406. _prepare(): void;
  38407. /**
  38408. * Execute the action and stop the sound.
  38409. */
  38410. execute(): void;
  38411. /**
  38412. * Serializes the actions and its related information.
  38413. * @param parent defines the object to serialize in
  38414. * @returns the serialized object
  38415. */
  38416. serialize(parent: any): any;
  38417. }
  38418. }
  38419. declare module "babylonjs/Actions/interpolateValueAction" {
  38420. import { Action } from "babylonjs/Actions/action";
  38421. import { Condition } from "babylonjs/Actions/condition";
  38422. import { Observable } from "babylonjs/Misc/observable";
  38423. /**
  38424. * This defines an action responsible to change the value of a property
  38425. * by interpolating between its current value and the newly set one once triggered.
  38426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38427. */
  38428. export class InterpolateValueAction extends Action {
  38429. /**
  38430. * Defines the path of the property where the value should be interpolated
  38431. */
  38432. propertyPath: string;
  38433. /**
  38434. * Defines the target value at the end of the interpolation.
  38435. */
  38436. value: any;
  38437. /**
  38438. * Defines the time it will take for the property to interpolate to the value.
  38439. */
  38440. duration: number;
  38441. /**
  38442. * Defines if the other scene animations should be stopped when the action has been triggered
  38443. */
  38444. stopOtherAnimations?: boolean;
  38445. /**
  38446. * Defines a callback raised once the interpolation animation has been done.
  38447. */
  38448. onInterpolationDone?: () => void;
  38449. /**
  38450. * Observable triggered once the interpolation animation has been done.
  38451. */
  38452. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38453. private _target;
  38454. private _effectiveTarget;
  38455. private _property;
  38456. /**
  38457. * Instantiate the action
  38458. * @param triggerOptions defines the trigger options
  38459. * @param target defines the object containing the value to interpolate
  38460. * @param propertyPath defines the path to the property in the target object
  38461. * @param value defines the target value at the end of the interpolation
  38462. * @param duration deines the time it will take for the property to interpolate to the value.
  38463. * @param condition defines the trigger related conditions
  38464. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38465. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38466. */
  38467. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38468. /** @hidden */
  38469. _prepare(): void;
  38470. /**
  38471. * Execute the action starts the value interpolation.
  38472. */
  38473. execute(): void;
  38474. /**
  38475. * Serializes the actions and its related information.
  38476. * @param parent defines the object to serialize in
  38477. * @returns the serialized object
  38478. */
  38479. serialize(parent: any): any;
  38480. }
  38481. }
  38482. declare module "babylonjs/Actions/index" {
  38483. export * from "babylonjs/Actions/abstractActionManager";
  38484. export * from "babylonjs/Actions/action";
  38485. export * from "babylonjs/Actions/actionEvent";
  38486. export * from "babylonjs/Actions/actionManager";
  38487. export * from "babylonjs/Actions/condition";
  38488. export * from "babylonjs/Actions/directActions";
  38489. export * from "babylonjs/Actions/directAudioActions";
  38490. export * from "babylonjs/Actions/interpolateValueAction";
  38491. }
  38492. declare module "babylonjs/Animations/index" {
  38493. export * from "babylonjs/Animations/animatable";
  38494. export * from "babylonjs/Animations/animation";
  38495. export * from "babylonjs/Animations/animationGroup";
  38496. export * from "babylonjs/Animations/animationPropertiesOverride";
  38497. export * from "babylonjs/Animations/easing";
  38498. export * from "babylonjs/Animations/runtimeAnimation";
  38499. export * from "babylonjs/Animations/animationEvent";
  38500. export * from "babylonjs/Animations/animationGroup";
  38501. export * from "babylonjs/Animations/animationKey";
  38502. export * from "babylonjs/Animations/animationRange";
  38503. export * from "babylonjs/Animations/animatable.interface";
  38504. }
  38505. declare module "babylonjs/Audio/soundTrack" {
  38506. import { Sound } from "babylonjs/Audio/sound";
  38507. import { Analyser } from "babylonjs/Audio/analyser";
  38508. import { Scene } from "babylonjs/scene";
  38509. /**
  38510. * Options allowed during the creation of a sound track.
  38511. */
  38512. export interface ISoundTrackOptions {
  38513. /**
  38514. * The volume the sound track should take during creation
  38515. */
  38516. volume?: number;
  38517. /**
  38518. * Define if the sound track is the main sound track of the scene
  38519. */
  38520. mainTrack?: boolean;
  38521. }
  38522. /**
  38523. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38524. * It will be also used in a future release to apply effects on a specific track.
  38525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38526. */
  38527. export class SoundTrack {
  38528. /**
  38529. * The unique identifier of the sound track in the scene.
  38530. */
  38531. id: number;
  38532. /**
  38533. * The list of sounds included in the sound track.
  38534. */
  38535. soundCollection: Array<Sound>;
  38536. private _outputAudioNode;
  38537. private _scene;
  38538. private _connectedAnalyser;
  38539. private _options;
  38540. private _isInitialized;
  38541. /**
  38542. * Creates a new sound track.
  38543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38544. * @param scene Define the scene the sound track belongs to
  38545. * @param options
  38546. */
  38547. constructor(scene: Scene, options?: ISoundTrackOptions);
  38548. private _initializeSoundTrackAudioGraph;
  38549. /**
  38550. * Release the sound track and its associated resources
  38551. */
  38552. dispose(): void;
  38553. /**
  38554. * Adds a sound to this sound track
  38555. * @param sound define the cound to add
  38556. * @ignoreNaming
  38557. */
  38558. AddSound(sound: Sound): void;
  38559. /**
  38560. * Removes a sound to this sound track
  38561. * @param sound define the cound to remove
  38562. * @ignoreNaming
  38563. */
  38564. RemoveSound(sound: Sound): void;
  38565. /**
  38566. * Set a global volume for the full sound track.
  38567. * @param newVolume Define the new volume of the sound track
  38568. */
  38569. setVolume(newVolume: number): void;
  38570. /**
  38571. * Switch the panning model to HRTF:
  38572. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38573. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38574. */
  38575. switchPanningModelToHRTF(): void;
  38576. /**
  38577. * Switch the panning model to Equal Power:
  38578. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38580. */
  38581. switchPanningModelToEqualPower(): void;
  38582. /**
  38583. * Connect the sound track to an audio analyser allowing some amazing
  38584. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38586. * @param analyser The analyser to connect to the engine
  38587. */
  38588. connectToAnalyser(analyser: Analyser): void;
  38589. }
  38590. }
  38591. declare module "babylonjs/Audio/audioSceneComponent" {
  38592. import { Sound } from "babylonjs/Audio/sound";
  38593. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38594. import { Nullable } from "babylonjs/types";
  38595. import { Vector3 } from "babylonjs/Maths/math.vector";
  38596. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38597. import { Scene } from "babylonjs/scene";
  38598. import { AbstractScene } from "babylonjs/abstractScene";
  38599. import "babylonjs/Audio/audioEngine";
  38600. module "babylonjs/abstractScene" {
  38601. interface AbstractScene {
  38602. /**
  38603. * The list of sounds used in the scene.
  38604. */
  38605. sounds: Nullable<Array<Sound>>;
  38606. }
  38607. }
  38608. module "babylonjs/scene" {
  38609. interface Scene {
  38610. /**
  38611. * @hidden
  38612. * Backing field
  38613. */
  38614. _mainSoundTrack: SoundTrack;
  38615. /**
  38616. * The main sound track played by the scene.
  38617. * It cotains your primary collection of sounds.
  38618. */
  38619. mainSoundTrack: SoundTrack;
  38620. /**
  38621. * The list of sound tracks added to the scene
  38622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38623. */
  38624. soundTracks: Nullable<Array<SoundTrack>>;
  38625. /**
  38626. * Gets a sound using a given name
  38627. * @param name defines the name to search for
  38628. * @return the found sound or null if not found at all.
  38629. */
  38630. getSoundByName(name: string): Nullable<Sound>;
  38631. /**
  38632. * Gets or sets if audio support is enabled
  38633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38634. */
  38635. audioEnabled: boolean;
  38636. /**
  38637. * Gets or sets if audio will be output to headphones
  38638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38639. */
  38640. headphone: boolean;
  38641. /**
  38642. * Gets or sets custom audio listener position provider
  38643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38644. */
  38645. audioListenerPositionProvider: Nullable<() => Vector3>;
  38646. /**
  38647. * Gets or sets a refresh rate when using 3D audio positioning
  38648. */
  38649. audioPositioningRefreshRate: number;
  38650. }
  38651. }
  38652. /**
  38653. * Defines the sound scene component responsible to manage any sounds
  38654. * in a given scene.
  38655. */
  38656. export class AudioSceneComponent implements ISceneSerializableComponent {
  38657. /**
  38658. * The component name helpfull to identify the component in the list of scene components.
  38659. */
  38660. readonly name: string;
  38661. /**
  38662. * The scene the component belongs to.
  38663. */
  38664. scene: Scene;
  38665. private _audioEnabled;
  38666. /**
  38667. * Gets whether audio is enabled or not.
  38668. * Please use related enable/disable method to switch state.
  38669. */
  38670. get audioEnabled(): boolean;
  38671. private _headphone;
  38672. /**
  38673. * Gets whether audio is outputing to headphone or not.
  38674. * Please use the according Switch methods to change output.
  38675. */
  38676. get headphone(): boolean;
  38677. /**
  38678. * Gets or sets a refresh rate when using 3D audio positioning
  38679. */
  38680. audioPositioningRefreshRate: number;
  38681. private _audioListenerPositionProvider;
  38682. /**
  38683. * Gets the current audio listener position provider
  38684. */
  38685. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38686. /**
  38687. * Sets a custom listener position for all sounds in the scene
  38688. * By default, this is the position of the first active camera
  38689. */
  38690. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38691. /**
  38692. * Creates a new instance of the component for the given scene
  38693. * @param scene Defines the scene to register the component in
  38694. */
  38695. constructor(scene: Scene);
  38696. /**
  38697. * Registers the component in a given scene
  38698. */
  38699. register(): void;
  38700. /**
  38701. * Rebuilds the elements related to this component in case of
  38702. * context lost for instance.
  38703. */
  38704. rebuild(): void;
  38705. /**
  38706. * Serializes the component data to the specified json object
  38707. * @param serializationObject The object to serialize to
  38708. */
  38709. serialize(serializationObject: any): void;
  38710. /**
  38711. * Adds all the elements from the container to the scene
  38712. * @param container the container holding the elements
  38713. */
  38714. addFromContainer(container: AbstractScene): void;
  38715. /**
  38716. * Removes all the elements in the container from the scene
  38717. * @param container contains the elements to remove
  38718. * @param dispose if the removed element should be disposed (default: false)
  38719. */
  38720. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38721. /**
  38722. * Disposes the component and the associated ressources.
  38723. */
  38724. dispose(): void;
  38725. /**
  38726. * Disables audio in the associated scene.
  38727. */
  38728. disableAudio(): void;
  38729. /**
  38730. * Enables audio in the associated scene.
  38731. */
  38732. enableAudio(): void;
  38733. /**
  38734. * Switch audio to headphone output.
  38735. */
  38736. switchAudioModeForHeadphones(): void;
  38737. /**
  38738. * Switch audio to normal speakers.
  38739. */
  38740. switchAudioModeForNormalSpeakers(): void;
  38741. private _cachedCameraDirection;
  38742. private _cachedCameraPosition;
  38743. private _lastCheck;
  38744. private _afterRender;
  38745. }
  38746. }
  38747. declare module "babylonjs/Audio/weightedsound" {
  38748. import { Sound } from "babylonjs/Audio/sound";
  38749. /**
  38750. * Wraps one or more Sound objects and selects one with random weight for playback.
  38751. */
  38752. export class WeightedSound {
  38753. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38754. loop: boolean;
  38755. private _coneInnerAngle;
  38756. private _coneOuterAngle;
  38757. private _volume;
  38758. /** A Sound is currently playing. */
  38759. isPlaying: boolean;
  38760. /** A Sound is currently paused. */
  38761. isPaused: boolean;
  38762. private _sounds;
  38763. private _weights;
  38764. private _currentIndex?;
  38765. /**
  38766. * Creates a new WeightedSound from the list of sounds given.
  38767. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38768. * @param sounds Array of Sounds that will be selected from.
  38769. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38770. */
  38771. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38772. /**
  38773. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38774. */
  38775. get directionalConeInnerAngle(): number;
  38776. /**
  38777. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38778. */
  38779. set directionalConeInnerAngle(value: number);
  38780. /**
  38781. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38782. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38783. */
  38784. get directionalConeOuterAngle(): number;
  38785. /**
  38786. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38787. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38788. */
  38789. set directionalConeOuterAngle(value: number);
  38790. /**
  38791. * Playback volume.
  38792. */
  38793. get volume(): number;
  38794. /**
  38795. * Playback volume.
  38796. */
  38797. set volume(value: number);
  38798. private _onended;
  38799. /**
  38800. * Suspend playback
  38801. */
  38802. pause(): void;
  38803. /**
  38804. * Stop playback
  38805. */
  38806. stop(): void;
  38807. /**
  38808. * Start playback.
  38809. * @param startOffset Position the clip head at a specific time in seconds.
  38810. */
  38811. play(startOffset?: number): void;
  38812. }
  38813. }
  38814. declare module "babylonjs/Audio/index" {
  38815. export * from "babylonjs/Audio/analyser";
  38816. export * from "babylonjs/Audio/audioEngine";
  38817. export * from "babylonjs/Audio/audioSceneComponent";
  38818. export * from "babylonjs/Audio/sound";
  38819. export * from "babylonjs/Audio/soundTrack";
  38820. export * from "babylonjs/Audio/weightedsound";
  38821. }
  38822. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38823. import { Behavior } from "babylonjs/Behaviors/behavior";
  38824. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38825. import { BackEase } from "babylonjs/Animations/easing";
  38826. /**
  38827. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38828. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38829. */
  38830. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38831. /**
  38832. * Gets the name of the behavior.
  38833. */
  38834. get name(): string;
  38835. /**
  38836. * The easing function used by animations
  38837. */
  38838. static EasingFunction: BackEase;
  38839. /**
  38840. * The easing mode used by animations
  38841. */
  38842. static EasingMode: number;
  38843. /**
  38844. * The duration of the animation, in milliseconds
  38845. */
  38846. transitionDuration: number;
  38847. /**
  38848. * Length of the distance animated by the transition when lower radius is reached
  38849. */
  38850. lowerRadiusTransitionRange: number;
  38851. /**
  38852. * Length of the distance animated by the transition when upper radius is reached
  38853. */
  38854. upperRadiusTransitionRange: number;
  38855. private _autoTransitionRange;
  38856. /**
  38857. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38858. */
  38859. get autoTransitionRange(): boolean;
  38860. /**
  38861. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38862. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38863. */
  38864. set autoTransitionRange(value: boolean);
  38865. private _attachedCamera;
  38866. private _onAfterCheckInputsObserver;
  38867. private _onMeshTargetChangedObserver;
  38868. /**
  38869. * Initializes the behavior.
  38870. */
  38871. init(): void;
  38872. /**
  38873. * Attaches the behavior to its arc rotate camera.
  38874. * @param camera Defines the camera to attach the behavior to
  38875. */
  38876. attach(camera: ArcRotateCamera): void;
  38877. /**
  38878. * Detaches the behavior from its current arc rotate camera.
  38879. */
  38880. detach(): void;
  38881. private _radiusIsAnimating;
  38882. private _radiusBounceTransition;
  38883. private _animatables;
  38884. private _cachedWheelPrecision;
  38885. /**
  38886. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38887. * @param radiusLimit The limit to check against.
  38888. * @return Bool to indicate if at limit.
  38889. */
  38890. private _isRadiusAtLimit;
  38891. /**
  38892. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38893. * @param radiusDelta The delta by which to animate to. Can be negative.
  38894. */
  38895. private _applyBoundRadiusAnimation;
  38896. /**
  38897. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38898. */
  38899. protected _clearAnimationLocks(): void;
  38900. /**
  38901. * Stops and removes all animations that have been applied to the camera
  38902. */
  38903. stopAllAnimations(): void;
  38904. }
  38905. }
  38906. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38907. import { Behavior } from "babylonjs/Behaviors/behavior";
  38908. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38909. import { ExponentialEase } from "babylonjs/Animations/easing";
  38910. import { Nullable } from "babylonjs/types";
  38911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38912. import { Vector3 } from "babylonjs/Maths/math.vector";
  38913. /**
  38914. * 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.
  38915. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38916. */
  38917. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38918. /**
  38919. * Gets the name of the behavior.
  38920. */
  38921. get name(): string;
  38922. private _mode;
  38923. private _radiusScale;
  38924. private _positionScale;
  38925. private _defaultElevation;
  38926. private _elevationReturnTime;
  38927. private _elevationReturnWaitTime;
  38928. private _zoomStopsAnimation;
  38929. private _framingTime;
  38930. /**
  38931. * The easing function used by animations
  38932. */
  38933. static EasingFunction: ExponentialEase;
  38934. /**
  38935. * The easing mode used by animations
  38936. */
  38937. static EasingMode: number;
  38938. /**
  38939. * Sets the current mode used by the behavior
  38940. */
  38941. set mode(mode: number);
  38942. /**
  38943. * Gets current mode used by the behavior.
  38944. */
  38945. get mode(): number;
  38946. /**
  38947. * Sets the scale applied to the radius (1 by default)
  38948. */
  38949. set radiusScale(radius: number);
  38950. /**
  38951. * Gets the scale applied to the radius
  38952. */
  38953. get radiusScale(): number;
  38954. /**
  38955. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38956. */
  38957. set positionScale(scale: number);
  38958. /**
  38959. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38960. */
  38961. get positionScale(): number;
  38962. /**
  38963. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38964. * behaviour is triggered, in radians.
  38965. */
  38966. set defaultElevation(elevation: number);
  38967. /**
  38968. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38969. * behaviour is triggered, in radians.
  38970. */
  38971. get defaultElevation(): number;
  38972. /**
  38973. * Sets the time (in milliseconds) taken to return to the default beta position.
  38974. * Negative value indicates camera should not return to default.
  38975. */
  38976. set elevationReturnTime(speed: number);
  38977. /**
  38978. * Gets the time (in milliseconds) taken to return to the default beta position.
  38979. * Negative value indicates camera should not return to default.
  38980. */
  38981. get elevationReturnTime(): number;
  38982. /**
  38983. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38984. */
  38985. set elevationReturnWaitTime(time: number);
  38986. /**
  38987. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38988. */
  38989. get elevationReturnWaitTime(): number;
  38990. /**
  38991. * Sets the flag that indicates if user zooming should stop animation.
  38992. */
  38993. set zoomStopsAnimation(flag: boolean);
  38994. /**
  38995. * Gets the flag that indicates if user zooming should stop animation.
  38996. */
  38997. get zoomStopsAnimation(): boolean;
  38998. /**
  38999. * Sets the transition time when framing the mesh, in milliseconds
  39000. */
  39001. set framingTime(time: number);
  39002. /**
  39003. * Gets the transition time when framing the mesh, in milliseconds
  39004. */
  39005. get framingTime(): number;
  39006. /**
  39007. * Define if the behavior should automatically change the configured
  39008. * camera limits and sensibilities.
  39009. */
  39010. autoCorrectCameraLimitsAndSensibility: boolean;
  39011. private _onPrePointerObservableObserver;
  39012. private _onAfterCheckInputsObserver;
  39013. private _onMeshTargetChangedObserver;
  39014. private _attachedCamera;
  39015. private _isPointerDown;
  39016. private _lastInteractionTime;
  39017. /**
  39018. * Initializes the behavior.
  39019. */
  39020. init(): void;
  39021. /**
  39022. * Attaches the behavior to its arc rotate camera.
  39023. * @param camera Defines the camera to attach the behavior to
  39024. */
  39025. attach(camera: ArcRotateCamera): void;
  39026. /**
  39027. * Detaches the behavior from its current arc rotate camera.
  39028. */
  39029. detach(): void;
  39030. private _animatables;
  39031. private _betaIsAnimating;
  39032. private _betaTransition;
  39033. private _radiusTransition;
  39034. private _vectorTransition;
  39035. /**
  39036. * Targets the given mesh and updates zoom level accordingly.
  39037. * @param mesh 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. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39044. /**
  39045. * Targets the given mesh with its children and updates zoom level accordingly.
  39046. * @param mesh The mesh to target.
  39047. * @param radius Optional. If a cached radius position already exists, overrides default.
  39048. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39049. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39050. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39051. */
  39052. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39053. /**
  39054. * Targets the given meshes with their children and updates zoom level accordingly.
  39055. * @param meshes The mesh to target.
  39056. * @param radius Optional. If a cached radius position already exists, overrides default.
  39057. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39058. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39059. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39060. */
  39061. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39062. /**
  39063. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39064. * @param minimumWorld Determines the smaller position of the bounding box extend
  39065. * @param maximumWorld Determines the bigger position of the bounding box extend
  39066. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39067. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39068. */
  39069. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39070. /**
  39071. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39072. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39073. * frustum width.
  39074. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39075. * to fully enclose the mesh in the viewing frustum.
  39076. */
  39077. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39078. /**
  39079. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39080. * is automatically returned to its default position (expected to be above ground plane).
  39081. */
  39082. private _maintainCameraAboveGround;
  39083. /**
  39084. * Returns the frustum slope based on the canvas ratio and camera FOV
  39085. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39086. */
  39087. private _getFrustumSlope;
  39088. /**
  39089. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39090. */
  39091. private _clearAnimationLocks;
  39092. /**
  39093. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39094. */
  39095. private _applyUserInteraction;
  39096. /**
  39097. * Stops and removes all animations that have been applied to the camera
  39098. */
  39099. stopAllAnimations(): void;
  39100. /**
  39101. * Gets a value indicating if the user is moving the camera
  39102. */
  39103. get isUserIsMoving(): boolean;
  39104. /**
  39105. * The camera can move all the way towards the mesh.
  39106. */
  39107. static IgnoreBoundsSizeMode: number;
  39108. /**
  39109. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39110. */
  39111. static FitFrustumSidesMode: number;
  39112. }
  39113. }
  39114. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39115. import { Nullable } from "babylonjs/types";
  39116. import { Camera } from "babylonjs/Cameras/camera";
  39117. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39118. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39119. /**
  39120. * Base class for Camera Pointer Inputs.
  39121. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39122. * for example usage.
  39123. */
  39124. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39125. /**
  39126. * Defines the camera the input is attached to.
  39127. */
  39128. abstract camera: Camera;
  39129. /**
  39130. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39131. */
  39132. protected _altKey: boolean;
  39133. protected _ctrlKey: boolean;
  39134. protected _metaKey: boolean;
  39135. protected _shiftKey: boolean;
  39136. /**
  39137. * Which mouse buttons were pressed at time of last mouse event.
  39138. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39139. */
  39140. protected _buttonsPressed: number;
  39141. /**
  39142. * Defines the buttons associated with the input to handle camera move.
  39143. */
  39144. buttons: number[];
  39145. /**
  39146. * Attach the input controls to a specific dom element to get the input from.
  39147. * @param element Defines the element the controls should be listened from
  39148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39149. */
  39150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39151. /**
  39152. * Detach the current controls from the specified dom element.
  39153. * @param element Defines the element to stop listening the inputs from
  39154. */
  39155. detachControl(element: Nullable<HTMLElement>): void;
  39156. /**
  39157. * Gets the class name of the current input.
  39158. * @returns the class name
  39159. */
  39160. getClassName(): string;
  39161. /**
  39162. * Get the friendly name associated with the input class.
  39163. * @returns the input friendly name
  39164. */
  39165. getSimpleName(): string;
  39166. /**
  39167. * Called on pointer POINTERDOUBLETAP event.
  39168. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39169. */
  39170. protected onDoubleTap(type: string): void;
  39171. /**
  39172. * Called on pointer POINTERMOVE event if only a single touch is active.
  39173. * Override this method to provide functionality.
  39174. */
  39175. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39176. /**
  39177. * Called on pointer POINTERMOVE event if multiple touches are active.
  39178. * Override this method to provide functionality.
  39179. */
  39180. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39181. /**
  39182. * Called on JS contextmenu event.
  39183. * Override this method to provide functionality.
  39184. */
  39185. protected onContextMenu(evt: PointerEvent): void;
  39186. /**
  39187. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39188. * press.
  39189. * Override this method to provide functionality.
  39190. */
  39191. protected onButtonDown(evt: PointerEvent): void;
  39192. /**
  39193. * Called each time a new POINTERUP event occurs. Ie, for each button
  39194. * release.
  39195. * Override this method to provide functionality.
  39196. */
  39197. protected onButtonUp(evt: PointerEvent): void;
  39198. /**
  39199. * Called when window becomes inactive.
  39200. * Override this method to provide functionality.
  39201. */
  39202. protected onLostFocus(): void;
  39203. private _pointerInput;
  39204. private _observer;
  39205. private _onLostFocus;
  39206. private pointA;
  39207. private pointB;
  39208. }
  39209. }
  39210. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39211. import { Nullable } from "babylonjs/types";
  39212. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39213. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39214. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39215. /**
  39216. * Manage the pointers inputs to control an arc rotate camera.
  39217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39218. */
  39219. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39220. /**
  39221. * Defines the camera the input is attached to.
  39222. */
  39223. camera: ArcRotateCamera;
  39224. /**
  39225. * Gets the class name of the current input.
  39226. * @returns the class name
  39227. */
  39228. getClassName(): string;
  39229. /**
  39230. * Defines the buttons associated with the input to handle camera move.
  39231. */
  39232. buttons: number[];
  39233. /**
  39234. * Defines the pointer angular sensibility along the X axis or how fast is
  39235. * the camera rotating.
  39236. */
  39237. angularSensibilityX: number;
  39238. /**
  39239. * Defines the pointer angular sensibility along the Y axis or how fast is
  39240. * the camera rotating.
  39241. */
  39242. angularSensibilityY: number;
  39243. /**
  39244. * Defines the pointer pinch precision or how fast is the camera zooming.
  39245. */
  39246. pinchPrecision: number;
  39247. /**
  39248. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39249. * from 0.
  39250. * It defines the percentage of current camera.radius to use as delta when
  39251. * pinch zoom is used.
  39252. */
  39253. pinchDeltaPercentage: number;
  39254. /**
  39255. * Defines the pointer panning sensibility or how fast is the camera moving.
  39256. */
  39257. panningSensibility: number;
  39258. /**
  39259. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39260. */
  39261. multiTouchPanning: boolean;
  39262. /**
  39263. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39264. * zoom (pinch) through multitouch.
  39265. */
  39266. multiTouchPanAndZoom: boolean;
  39267. /**
  39268. * Revers pinch action direction.
  39269. */
  39270. pinchInwards: boolean;
  39271. private _isPanClick;
  39272. private _twoFingerActivityCount;
  39273. private _isPinching;
  39274. /**
  39275. * Called on pointer POINTERMOVE event if only a single touch is active.
  39276. */
  39277. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39278. /**
  39279. * Called on pointer POINTERDOUBLETAP event.
  39280. */
  39281. protected onDoubleTap(type: string): void;
  39282. /**
  39283. * Called on pointer POINTERMOVE event if multiple touches are active.
  39284. */
  39285. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39286. /**
  39287. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39288. * press.
  39289. */
  39290. protected onButtonDown(evt: PointerEvent): void;
  39291. /**
  39292. * Called each time a new POINTERUP event occurs. Ie, for each button
  39293. * release.
  39294. */
  39295. protected onButtonUp(evt: PointerEvent): void;
  39296. /**
  39297. * Called when window becomes inactive.
  39298. */
  39299. protected onLostFocus(): void;
  39300. }
  39301. }
  39302. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39303. import { Nullable } from "babylonjs/types";
  39304. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39305. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39306. /**
  39307. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39308. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39309. */
  39310. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39311. /**
  39312. * Defines the camera the input is attached to.
  39313. */
  39314. camera: ArcRotateCamera;
  39315. /**
  39316. * Defines the list of key codes associated with the up action (increase alpha)
  39317. */
  39318. keysUp: number[];
  39319. /**
  39320. * Defines the list of key codes associated with the down action (decrease alpha)
  39321. */
  39322. keysDown: number[];
  39323. /**
  39324. * Defines the list of key codes associated with the left action (increase beta)
  39325. */
  39326. keysLeft: number[];
  39327. /**
  39328. * Defines the list of key codes associated with the right action (decrease beta)
  39329. */
  39330. keysRight: number[];
  39331. /**
  39332. * Defines the list of key codes associated with the reset action.
  39333. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39334. */
  39335. keysReset: number[];
  39336. /**
  39337. * Defines the panning sensibility of the inputs.
  39338. * (How fast is the camera paning)
  39339. */
  39340. panningSensibility: number;
  39341. /**
  39342. * Defines the zooming sensibility of the inputs.
  39343. * (How fast is the camera zooming)
  39344. */
  39345. zoomingSensibility: number;
  39346. /**
  39347. * Defines wether maintaining the alt key down switch the movement mode from
  39348. * orientation to zoom.
  39349. */
  39350. useAltToZoom: boolean;
  39351. /**
  39352. * Rotation speed of the camera
  39353. */
  39354. angularSpeed: number;
  39355. private _keys;
  39356. private _ctrlPressed;
  39357. private _altPressed;
  39358. private _onCanvasBlurObserver;
  39359. private _onKeyboardObserver;
  39360. private _engine;
  39361. private _scene;
  39362. /**
  39363. * Attach the input controls to a specific dom element to get the input from.
  39364. * @param element Defines the element the controls should be listened from
  39365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39366. */
  39367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39368. /**
  39369. * Detach the current controls from the specified dom element.
  39370. * @param element Defines the element to stop listening the inputs from
  39371. */
  39372. detachControl(element: Nullable<HTMLElement>): void;
  39373. /**
  39374. * Update the current camera state depending on the inputs that have been used this frame.
  39375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39376. */
  39377. checkInputs(): void;
  39378. /**
  39379. * Gets the class name of the current intput.
  39380. * @returns the class name
  39381. */
  39382. getClassName(): string;
  39383. /**
  39384. * Get the friendly name associated with the input class.
  39385. * @returns the input friendly name
  39386. */
  39387. getSimpleName(): string;
  39388. }
  39389. }
  39390. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39391. import { Nullable } from "babylonjs/types";
  39392. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39393. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39394. /**
  39395. * Manage the mouse wheel inputs to control an arc rotate camera.
  39396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39397. */
  39398. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39399. /**
  39400. * Defines the camera the input is attached to.
  39401. */
  39402. camera: ArcRotateCamera;
  39403. /**
  39404. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39405. */
  39406. wheelPrecision: number;
  39407. /**
  39408. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39409. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39410. */
  39411. wheelDeltaPercentage: number;
  39412. private _wheel;
  39413. private _observer;
  39414. private computeDeltaFromMouseWheelLegacyEvent;
  39415. /**
  39416. * Attach the input controls to a specific dom element to get the input from.
  39417. * @param element Defines the element the controls should be listened from
  39418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39419. */
  39420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39421. /**
  39422. * Detach the current controls from the specified dom element.
  39423. * @param element Defines the element to stop listening the inputs from
  39424. */
  39425. detachControl(element: Nullable<HTMLElement>): void;
  39426. /**
  39427. * Gets the class name of the current intput.
  39428. * @returns the class name
  39429. */
  39430. getClassName(): string;
  39431. /**
  39432. * Get the friendly name associated with the input class.
  39433. * @returns the input friendly name
  39434. */
  39435. getSimpleName(): string;
  39436. }
  39437. }
  39438. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39439. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39440. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39441. /**
  39442. * Default Inputs manager for the ArcRotateCamera.
  39443. * It groups all the default supported inputs for ease of use.
  39444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39445. */
  39446. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39447. /**
  39448. * Instantiates a new ArcRotateCameraInputsManager.
  39449. * @param camera Defines the camera the inputs belong to
  39450. */
  39451. constructor(camera: ArcRotateCamera);
  39452. /**
  39453. * Add mouse wheel input support to the input manager.
  39454. * @returns the current input manager
  39455. */
  39456. addMouseWheel(): ArcRotateCameraInputsManager;
  39457. /**
  39458. * Add pointers input support to the input manager.
  39459. * @returns the current input manager
  39460. */
  39461. addPointers(): ArcRotateCameraInputsManager;
  39462. /**
  39463. * Add keyboard input support to the input manager.
  39464. * @returns the current input manager
  39465. */
  39466. addKeyboard(): ArcRotateCameraInputsManager;
  39467. }
  39468. }
  39469. declare module "babylonjs/Cameras/arcRotateCamera" {
  39470. import { Observable } from "babylonjs/Misc/observable";
  39471. import { Nullable } from "babylonjs/types";
  39472. import { Scene } from "babylonjs/scene";
  39473. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39475. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39476. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39477. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39478. import { Camera } from "babylonjs/Cameras/camera";
  39479. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39480. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39481. import { Collider } from "babylonjs/Collisions/collider";
  39482. /**
  39483. * This represents an orbital type of camera.
  39484. *
  39485. * 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.
  39486. * 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.
  39487. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39488. */
  39489. export class ArcRotateCamera extends TargetCamera {
  39490. /**
  39491. * Defines the rotation angle of the camera along the longitudinal axis.
  39492. */
  39493. alpha: number;
  39494. /**
  39495. * Defines the rotation angle of the camera along the latitudinal axis.
  39496. */
  39497. beta: number;
  39498. /**
  39499. * Defines the radius of the camera from it s target point.
  39500. */
  39501. radius: number;
  39502. protected _target: Vector3;
  39503. protected _targetHost: Nullable<AbstractMesh>;
  39504. /**
  39505. * Defines the target point of the camera.
  39506. * The camera looks towards it form the radius distance.
  39507. */
  39508. get target(): Vector3;
  39509. set target(value: Vector3);
  39510. /**
  39511. * Define the current local position of the camera in the scene
  39512. */
  39513. get position(): Vector3;
  39514. set position(newPosition: Vector3);
  39515. protected _upVector: Vector3;
  39516. protected _upToYMatrix: Matrix;
  39517. protected _YToUpMatrix: Matrix;
  39518. /**
  39519. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39520. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39521. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39522. */
  39523. set upVector(vec: Vector3);
  39524. get upVector(): Vector3;
  39525. /**
  39526. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39527. */
  39528. setMatUp(): void;
  39529. /**
  39530. * Current inertia value on the longitudinal axis.
  39531. * The bigger this number the longer it will take for the camera to stop.
  39532. */
  39533. inertialAlphaOffset: number;
  39534. /**
  39535. * Current inertia value on the latitudinal axis.
  39536. * The bigger this number the longer it will take for the camera to stop.
  39537. */
  39538. inertialBetaOffset: number;
  39539. /**
  39540. * Current inertia value on the radius axis.
  39541. * The bigger this number the longer it will take for the camera to stop.
  39542. */
  39543. inertialRadiusOffset: number;
  39544. /**
  39545. * Minimum allowed angle on the longitudinal axis.
  39546. * This can help limiting how the Camera is able to move in the scene.
  39547. */
  39548. lowerAlphaLimit: Nullable<number>;
  39549. /**
  39550. * Maximum allowed angle on the longitudinal axis.
  39551. * This can help limiting how the Camera is able to move in the scene.
  39552. */
  39553. upperAlphaLimit: Nullable<number>;
  39554. /**
  39555. * Minimum allowed angle on the latitudinal axis.
  39556. * This can help limiting how the Camera is able to move in the scene.
  39557. */
  39558. lowerBetaLimit: number;
  39559. /**
  39560. * Maximum allowed angle on the latitudinal axis.
  39561. * This can help limiting how the Camera is able to move in the scene.
  39562. */
  39563. upperBetaLimit: number;
  39564. /**
  39565. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39566. * This can help limiting how the Camera is able to move in the scene.
  39567. */
  39568. lowerRadiusLimit: Nullable<number>;
  39569. /**
  39570. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39571. * This can help limiting how the Camera is able to move in the scene.
  39572. */
  39573. upperRadiusLimit: Nullable<number>;
  39574. /**
  39575. * Defines the current inertia value used during panning of the camera along the X axis.
  39576. */
  39577. inertialPanningX: number;
  39578. /**
  39579. * Defines the current inertia value used during panning of the camera along the Y axis.
  39580. */
  39581. inertialPanningY: number;
  39582. /**
  39583. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39584. * Basically if your fingers moves away from more than this distance you will be considered
  39585. * in pinch mode.
  39586. */
  39587. pinchToPanMaxDistance: number;
  39588. /**
  39589. * Defines the maximum distance the camera can pan.
  39590. * This could help keeping the cammera always in your scene.
  39591. */
  39592. panningDistanceLimit: Nullable<number>;
  39593. /**
  39594. * Defines the target of the camera before paning.
  39595. */
  39596. panningOriginTarget: Vector3;
  39597. /**
  39598. * Defines the value of the inertia used during panning.
  39599. * 0 would mean stop inertia and one would mean no decelleration at all.
  39600. */
  39601. panningInertia: number;
  39602. /**
  39603. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39604. */
  39605. get angularSensibilityX(): number;
  39606. set angularSensibilityX(value: number);
  39607. /**
  39608. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39609. */
  39610. get angularSensibilityY(): number;
  39611. set angularSensibilityY(value: number);
  39612. /**
  39613. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39614. */
  39615. get pinchPrecision(): number;
  39616. set pinchPrecision(value: number);
  39617. /**
  39618. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39619. * It will be used instead of pinchDeltaPrecision if different from 0.
  39620. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39621. */
  39622. get pinchDeltaPercentage(): number;
  39623. set pinchDeltaPercentage(value: number);
  39624. /**
  39625. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39626. */
  39627. get panningSensibility(): number;
  39628. set panningSensibility(value: number);
  39629. /**
  39630. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39631. */
  39632. get keysUp(): number[];
  39633. set keysUp(value: number[]);
  39634. /**
  39635. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39636. */
  39637. get keysDown(): number[];
  39638. set keysDown(value: number[]);
  39639. /**
  39640. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39641. */
  39642. get keysLeft(): number[];
  39643. set keysLeft(value: number[]);
  39644. /**
  39645. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39646. */
  39647. get keysRight(): number[];
  39648. set keysRight(value: number[]);
  39649. /**
  39650. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39651. */
  39652. get wheelPrecision(): number;
  39653. set wheelPrecision(value: number);
  39654. /**
  39655. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39656. * It will be used instead of pinchDeltaPrecision if different from 0.
  39657. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39658. */
  39659. get wheelDeltaPercentage(): number;
  39660. set wheelDeltaPercentage(value: number);
  39661. /**
  39662. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39663. */
  39664. zoomOnFactor: number;
  39665. /**
  39666. * Defines a screen offset for the camera position.
  39667. */
  39668. targetScreenOffset: Vector2;
  39669. /**
  39670. * Allows the camera to be completely reversed.
  39671. * If false the camera can not arrive upside down.
  39672. */
  39673. allowUpsideDown: boolean;
  39674. /**
  39675. * Define if double tap/click is used to restore the previously saved state of the camera.
  39676. */
  39677. useInputToRestoreState: boolean;
  39678. /** @hidden */
  39679. _viewMatrix: Matrix;
  39680. /** @hidden */
  39681. _useCtrlForPanning: boolean;
  39682. /** @hidden */
  39683. _panningMouseButton: number;
  39684. /**
  39685. * Defines the input associated to the camera.
  39686. */
  39687. inputs: ArcRotateCameraInputsManager;
  39688. /** @hidden */
  39689. _reset: () => void;
  39690. /**
  39691. * Defines the allowed panning axis.
  39692. */
  39693. panningAxis: Vector3;
  39694. protected _localDirection: Vector3;
  39695. protected _transformedDirection: Vector3;
  39696. private _bouncingBehavior;
  39697. /**
  39698. * Gets the bouncing behavior of the camera if it has been enabled.
  39699. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39700. */
  39701. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39702. /**
  39703. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39704. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39705. */
  39706. get useBouncingBehavior(): boolean;
  39707. set useBouncingBehavior(value: boolean);
  39708. private _framingBehavior;
  39709. /**
  39710. * Gets the framing behavior of the camera if it has been enabled.
  39711. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39712. */
  39713. get framingBehavior(): Nullable<FramingBehavior>;
  39714. /**
  39715. * Defines if the framing behavior of the camera is enabled on the camera.
  39716. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39717. */
  39718. get useFramingBehavior(): boolean;
  39719. set useFramingBehavior(value: boolean);
  39720. private _autoRotationBehavior;
  39721. /**
  39722. * Gets the auto rotation behavior of the camera if it has been enabled.
  39723. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39724. */
  39725. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39726. /**
  39727. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39728. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39729. */
  39730. get useAutoRotationBehavior(): boolean;
  39731. set useAutoRotationBehavior(value: boolean);
  39732. /**
  39733. * Observable triggered when the mesh target has been changed on the camera.
  39734. */
  39735. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39736. /**
  39737. * Event raised when the camera is colliding with a mesh.
  39738. */
  39739. onCollide: (collidedMesh: AbstractMesh) => void;
  39740. /**
  39741. * Defines whether the camera should check collision with the objects oh the scene.
  39742. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39743. */
  39744. checkCollisions: boolean;
  39745. /**
  39746. * Defines the collision radius of the camera.
  39747. * This simulates a sphere around the camera.
  39748. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39749. */
  39750. collisionRadius: Vector3;
  39751. protected _collider: Collider;
  39752. protected _previousPosition: Vector3;
  39753. protected _collisionVelocity: Vector3;
  39754. protected _newPosition: Vector3;
  39755. protected _previousAlpha: number;
  39756. protected _previousBeta: number;
  39757. protected _previousRadius: number;
  39758. protected _collisionTriggered: boolean;
  39759. protected _targetBoundingCenter: Nullable<Vector3>;
  39760. private _computationVector;
  39761. /**
  39762. * Instantiates a new ArcRotateCamera in a given scene
  39763. * @param name Defines the name of the camera
  39764. * @param alpha Defines the camera rotation along the logitudinal axis
  39765. * @param beta Defines the camera rotation along the latitudinal axis
  39766. * @param radius Defines the camera distance from its target
  39767. * @param target Defines the camera target
  39768. * @param scene Defines the scene the camera belongs to
  39769. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39770. */
  39771. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39772. /** @hidden */
  39773. _initCache(): void;
  39774. /** @hidden */
  39775. _updateCache(ignoreParentClass?: boolean): void;
  39776. protected _getTargetPosition(): Vector3;
  39777. private _storedAlpha;
  39778. private _storedBeta;
  39779. private _storedRadius;
  39780. private _storedTarget;
  39781. private _storedTargetScreenOffset;
  39782. /**
  39783. * Stores the current state of the camera (alpha, beta, radius and target)
  39784. * @returns the camera itself
  39785. */
  39786. storeState(): Camera;
  39787. /**
  39788. * @hidden
  39789. * Restored camera state. You must call storeState() first
  39790. */
  39791. _restoreStateValues(): boolean;
  39792. /** @hidden */
  39793. _isSynchronizedViewMatrix(): boolean;
  39794. /**
  39795. * Attached controls to the current camera.
  39796. * @param element Defines the element the controls should be listened from
  39797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39798. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39799. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39800. */
  39801. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39802. /**
  39803. * Detach the current controls from the camera.
  39804. * The camera will stop reacting to inputs.
  39805. * @param element Defines the element to stop listening the inputs from
  39806. */
  39807. detachControl(element: HTMLElement): void;
  39808. /** @hidden */
  39809. _checkInputs(): void;
  39810. protected _checkLimits(): void;
  39811. /**
  39812. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39813. */
  39814. rebuildAnglesAndRadius(): void;
  39815. /**
  39816. * Use a position to define the current camera related information like alpha, beta and radius
  39817. * @param position Defines the position to set the camera at
  39818. */
  39819. setPosition(position: Vector3): void;
  39820. /**
  39821. * Defines the target the camera should look at.
  39822. * This will automatically adapt alpha beta and radius to fit within the new target.
  39823. * @param target Defines the new target as a Vector or a mesh
  39824. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39825. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39826. */
  39827. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39828. /** @hidden */
  39829. _getViewMatrix(): Matrix;
  39830. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39831. /**
  39832. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39833. * @param meshes Defines the mesh to zoom on
  39834. * @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)
  39835. */
  39836. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39837. /**
  39838. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39839. * The target will be changed but the radius
  39840. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39841. * @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)
  39842. */
  39843. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39844. min: Vector3;
  39845. max: Vector3;
  39846. distance: number;
  39847. }, doNotUpdateMaxZ?: boolean): void;
  39848. /**
  39849. * @override
  39850. * Override Camera.createRigCamera
  39851. */
  39852. createRigCamera(name: string, cameraIndex: number): Camera;
  39853. /**
  39854. * @hidden
  39855. * @override
  39856. * Override Camera._updateRigCameras
  39857. */
  39858. _updateRigCameras(): void;
  39859. /**
  39860. * Destroy the camera and release the current resources hold by it.
  39861. */
  39862. dispose(): void;
  39863. /**
  39864. * Gets the current object class name.
  39865. * @return the class name
  39866. */
  39867. getClassName(): string;
  39868. }
  39869. }
  39870. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39871. import { Behavior } from "babylonjs/Behaviors/behavior";
  39872. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39873. /**
  39874. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39875. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39876. */
  39877. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39878. /**
  39879. * Gets the name of the behavior.
  39880. */
  39881. get name(): string;
  39882. private _zoomStopsAnimation;
  39883. private _idleRotationSpeed;
  39884. private _idleRotationWaitTime;
  39885. private _idleRotationSpinupTime;
  39886. /**
  39887. * Sets the flag that indicates if user zooming should stop animation.
  39888. */
  39889. set zoomStopsAnimation(flag: boolean);
  39890. /**
  39891. * Gets the flag that indicates if user zooming should stop animation.
  39892. */
  39893. get zoomStopsAnimation(): boolean;
  39894. /**
  39895. * Sets the default speed at which the camera rotates around the model.
  39896. */
  39897. set idleRotationSpeed(speed: number);
  39898. /**
  39899. * Gets the default speed at which the camera rotates around the model.
  39900. */
  39901. get idleRotationSpeed(): number;
  39902. /**
  39903. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39904. */
  39905. set idleRotationWaitTime(time: number);
  39906. /**
  39907. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39908. */
  39909. get idleRotationWaitTime(): number;
  39910. /**
  39911. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39912. */
  39913. set idleRotationSpinupTime(time: number);
  39914. /**
  39915. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39916. */
  39917. get idleRotationSpinupTime(): number;
  39918. /**
  39919. * Gets a value indicating if the camera is currently rotating because of this behavior
  39920. */
  39921. get rotationInProgress(): boolean;
  39922. private _onPrePointerObservableObserver;
  39923. private _onAfterCheckInputsObserver;
  39924. private _attachedCamera;
  39925. private _isPointerDown;
  39926. private _lastFrameTime;
  39927. private _lastInteractionTime;
  39928. private _cameraRotationSpeed;
  39929. /**
  39930. * Initializes the behavior.
  39931. */
  39932. init(): void;
  39933. /**
  39934. * Attaches the behavior to its arc rotate camera.
  39935. * @param camera Defines the camera to attach the behavior to
  39936. */
  39937. attach(camera: ArcRotateCamera): void;
  39938. /**
  39939. * Detaches the behavior from its current arc rotate camera.
  39940. */
  39941. detach(): void;
  39942. /**
  39943. * Returns true if user is scrolling.
  39944. * @return true if user is scrolling.
  39945. */
  39946. private _userIsZooming;
  39947. private _lastFrameRadius;
  39948. private _shouldAnimationStopForInteraction;
  39949. /**
  39950. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39951. */
  39952. private _applyUserInteraction;
  39953. private _userIsMoving;
  39954. }
  39955. }
  39956. declare module "babylonjs/Behaviors/Cameras/index" {
  39957. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39958. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39959. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39960. }
  39961. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39962. import { Mesh } from "babylonjs/Meshes/mesh";
  39963. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39964. import { Behavior } from "babylonjs/Behaviors/behavior";
  39965. /**
  39966. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39967. */
  39968. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39969. private ui;
  39970. /**
  39971. * The name of the behavior
  39972. */
  39973. name: string;
  39974. /**
  39975. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39976. */
  39977. distanceAwayFromFace: number;
  39978. /**
  39979. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39980. */
  39981. distanceAwayFromBottomOfFace: number;
  39982. private _faceVectors;
  39983. private _target;
  39984. private _scene;
  39985. private _onRenderObserver;
  39986. private _tmpMatrix;
  39987. private _tmpVector;
  39988. /**
  39989. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39990. * @param ui The transform node that should be attched to the mesh
  39991. */
  39992. constructor(ui: TransformNode);
  39993. /**
  39994. * Initializes the behavior
  39995. */
  39996. init(): void;
  39997. private _closestFace;
  39998. private _zeroVector;
  39999. private _lookAtTmpMatrix;
  40000. private _lookAtToRef;
  40001. /**
  40002. * Attaches the AttachToBoxBehavior to the passed in mesh
  40003. * @param target The mesh that the specified node will be attached to
  40004. */
  40005. attach(target: Mesh): void;
  40006. /**
  40007. * Detaches the behavior from the mesh
  40008. */
  40009. detach(): void;
  40010. }
  40011. }
  40012. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40013. import { Behavior } from "babylonjs/Behaviors/behavior";
  40014. import { Mesh } from "babylonjs/Meshes/mesh";
  40015. /**
  40016. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40017. */
  40018. export class FadeInOutBehavior implements Behavior<Mesh> {
  40019. /**
  40020. * Time in milliseconds to delay before fading in (Default: 0)
  40021. */
  40022. delay: number;
  40023. /**
  40024. * Time in milliseconds for the mesh to fade in (Default: 300)
  40025. */
  40026. fadeInTime: number;
  40027. private _millisecondsPerFrame;
  40028. private _hovered;
  40029. private _hoverValue;
  40030. private _ownerNode;
  40031. /**
  40032. * Instatiates the FadeInOutBehavior
  40033. */
  40034. constructor();
  40035. /**
  40036. * The name of the behavior
  40037. */
  40038. get name(): string;
  40039. /**
  40040. * Initializes the behavior
  40041. */
  40042. init(): void;
  40043. /**
  40044. * Attaches the fade behavior on the passed in mesh
  40045. * @param ownerNode The mesh that will be faded in/out once attached
  40046. */
  40047. attach(ownerNode: Mesh): void;
  40048. /**
  40049. * Detaches the behavior from the mesh
  40050. */
  40051. detach(): void;
  40052. /**
  40053. * Triggers the mesh to begin fading in or out
  40054. * @param value if the object should fade in or out (true to fade in)
  40055. */
  40056. fadeIn(value: boolean): void;
  40057. private _update;
  40058. private _setAllVisibility;
  40059. }
  40060. }
  40061. declare module "babylonjs/Misc/pivotTools" {
  40062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40063. /**
  40064. * Class containing a set of static utilities functions for managing Pivots
  40065. * @hidden
  40066. */
  40067. export class PivotTools {
  40068. private static _PivotCached;
  40069. private static _OldPivotPoint;
  40070. private static _PivotTranslation;
  40071. private static _PivotTmpVector;
  40072. /** @hidden */
  40073. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40074. /** @hidden */
  40075. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40076. }
  40077. }
  40078. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40079. import { Scene } from "babylonjs/scene";
  40080. import { Vector4 } from "babylonjs/Maths/math.vector";
  40081. import { Mesh } from "babylonjs/Meshes/mesh";
  40082. import { Nullable } from "babylonjs/types";
  40083. import { Plane } from "babylonjs/Maths/math.plane";
  40084. /**
  40085. * Class containing static functions to help procedurally build meshes
  40086. */
  40087. export class PlaneBuilder {
  40088. /**
  40089. * Creates a plane mesh
  40090. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40091. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40092. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40096. * @param name defines the name of the mesh
  40097. * @param options defines the options used to create the mesh
  40098. * @param scene defines the hosting scene
  40099. * @returns the plane mesh
  40100. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40101. */
  40102. static CreatePlane(name: string, options: {
  40103. size?: number;
  40104. width?: number;
  40105. height?: number;
  40106. sideOrientation?: number;
  40107. frontUVs?: Vector4;
  40108. backUVs?: Vector4;
  40109. updatable?: boolean;
  40110. sourcePlane?: Plane;
  40111. }, scene?: Nullable<Scene>): Mesh;
  40112. }
  40113. }
  40114. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40115. import { Behavior } from "babylonjs/Behaviors/behavior";
  40116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40117. import { Observable } from "babylonjs/Misc/observable";
  40118. import { Vector3 } from "babylonjs/Maths/math.vector";
  40119. import { Ray } from "babylonjs/Culling/ray";
  40120. import "babylonjs/Meshes/Builders/planeBuilder";
  40121. /**
  40122. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40123. */
  40124. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40125. private static _AnyMouseID;
  40126. /**
  40127. * Abstract mesh the behavior is set on
  40128. */
  40129. attachedNode: AbstractMesh;
  40130. private _dragPlane;
  40131. private _scene;
  40132. private _pointerObserver;
  40133. private _beforeRenderObserver;
  40134. private static _planeScene;
  40135. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40136. /**
  40137. * 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)
  40138. */
  40139. maxDragAngle: number;
  40140. /**
  40141. * @hidden
  40142. */
  40143. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40144. /**
  40145. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40146. */
  40147. currentDraggingPointerID: number;
  40148. /**
  40149. * The last position where the pointer hit the drag plane in world space
  40150. */
  40151. lastDragPosition: Vector3;
  40152. /**
  40153. * If the behavior is currently in a dragging state
  40154. */
  40155. dragging: boolean;
  40156. /**
  40157. * 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)
  40158. */
  40159. dragDeltaRatio: number;
  40160. /**
  40161. * If the drag plane orientation should be updated during the dragging (Default: true)
  40162. */
  40163. updateDragPlane: boolean;
  40164. private _debugMode;
  40165. private _moving;
  40166. /**
  40167. * Fires each time the attached mesh is dragged with the pointer
  40168. * * delta between last drag position and current drag position in world space
  40169. * * dragDistance along the drag axis
  40170. * * dragPlaneNormal normal of the current drag plane used during the drag
  40171. * * dragPlanePoint in world space where the drag intersects the drag plane
  40172. */
  40173. onDragObservable: Observable<{
  40174. delta: Vector3;
  40175. dragPlanePoint: Vector3;
  40176. dragPlaneNormal: Vector3;
  40177. dragDistance: number;
  40178. pointerId: number;
  40179. }>;
  40180. /**
  40181. * Fires each time a drag begins (eg. mouse down on mesh)
  40182. */
  40183. onDragStartObservable: Observable<{
  40184. dragPlanePoint: Vector3;
  40185. pointerId: number;
  40186. }>;
  40187. /**
  40188. * Fires each time a drag ends (eg. mouse release after drag)
  40189. */
  40190. onDragEndObservable: Observable<{
  40191. dragPlanePoint: Vector3;
  40192. pointerId: number;
  40193. }>;
  40194. /**
  40195. * If the attached mesh should be moved when dragged
  40196. */
  40197. moveAttached: boolean;
  40198. /**
  40199. * If the drag behavior will react to drag events (Default: true)
  40200. */
  40201. enabled: boolean;
  40202. /**
  40203. * If pointer events should start and release the drag (Default: true)
  40204. */
  40205. startAndReleaseDragOnPointerEvents: boolean;
  40206. /**
  40207. * If camera controls should be detached during the drag
  40208. */
  40209. detachCameraControls: boolean;
  40210. /**
  40211. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40212. */
  40213. useObjectOrientationForDragging: boolean;
  40214. private _options;
  40215. /**
  40216. * Gets the options used by the behavior
  40217. */
  40218. get options(): {
  40219. dragAxis?: Vector3;
  40220. dragPlaneNormal?: Vector3;
  40221. };
  40222. /**
  40223. * Sets the options used by the behavior
  40224. */
  40225. set options(options: {
  40226. dragAxis?: Vector3;
  40227. dragPlaneNormal?: Vector3;
  40228. });
  40229. /**
  40230. * Creates a pointer drag behavior that can be attached to a mesh
  40231. * @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)
  40232. */
  40233. constructor(options?: {
  40234. dragAxis?: Vector3;
  40235. dragPlaneNormal?: Vector3;
  40236. });
  40237. /**
  40238. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40239. */
  40240. validateDrag: (targetPosition: Vector3) => boolean;
  40241. /**
  40242. * The name of the behavior
  40243. */
  40244. get name(): string;
  40245. /**
  40246. * Initializes the behavior
  40247. */
  40248. init(): void;
  40249. private _tmpVector;
  40250. private _alternatePickedPoint;
  40251. private _worldDragAxis;
  40252. private _targetPosition;
  40253. private _attachedElement;
  40254. /**
  40255. * Attaches the drag behavior the passed in mesh
  40256. * @param ownerNode The mesh that will be dragged around once attached
  40257. * @param predicate Predicate to use for pick filtering
  40258. */
  40259. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40260. /**
  40261. * Force relase the drag action by code.
  40262. */
  40263. releaseDrag(): void;
  40264. private _startDragRay;
  40265. private _lastPointerRay;
  40266. /**
  40267. * Simulates the start of a pointer drag event on the behavior
  40268. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40269. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40270. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40271. */
  40272. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40273. private _startDrag;
  40274. private _dragDelta;
  40275. private _moveDrag;
  40276. private _pickWithRayOnDragPlane;
  40277. private _pointA;
  40278. private _pointB;
  40279. private _pointC;
  40280. private _lineA;
  40281. private _lineB;
  40282. private _localAxis;
  40283. private _lookAt;
  40284. private _updateDragPlanePosition;
  40285. /**
  40286. * Detaches the behavior from the mesh
  40287. */
  40288. detach(): void;
  40289. }
  40290. }
  40291. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40292. import { Mesh } from "babylonjs/Meshes/mesh";
  40293. import { Behavior } from "babylonjs/Behaviors/behavior";
  40294. /**
  40295. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40296. */
  40297. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40298. private _dragBehaviorA;
  40299. private _dragBehaviorB;
  40300. private _startDistance;
  40301. private _initialScale;
  40302. private _targetScale;
  40303. private _ownerNode;
  40304. private _sceneRenderObserver;
  40305. /**
  40306. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40307. */
  40308. constructor();
  40309. /**
  40310. * The name of the behavior
  40311. */
  40312. get name(): string;
  40313. /**
  40314. * Initializes the behavior
  40315. */
  40316. init(): void;
  40317. private _getCurrentDistance;
  40318. /**
  40319. * Attaches the scale behavior the passed in mesh
  40320. * @param ownerNode The mesh that will be scaled around once attached
  40321. */
  40322. attach(ownerNode: Mesh): void;
  40323. /**
  40324. * Detaches the behavior from the mesh
  40325. */
  40326. detach(): void;
  40327. }
  40328. }
  40329. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40330. import { Behavior } from "babylonjs/Behaviors/behavior";
  40331. import { Mesh } from "babylonjs/Meshes/mesh";
  40332. import { Observable } from "babylonjs/Misc/observable";
  40333. /**
  40334. * 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
  40335. */
  40336. export class SixDofDragBehavior implements Behavior<Mesh> {
  40337. private static _virtualScene;
  40338. private _ownerNode;
  40339. private _sceneRenderObserver;
  40340. private _scene;
  40341. private _targetPosition;
  40342. private _virtualOriginMesh;
  40343. private _virtualDragMesh;
  40344. private _pointerObserver;
  40345. private _moving;
  40346. private _startingOrientation;
  40347. /**
  40348. * 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)
  40349. */
  40350. private zDragFactor;
  40351. /**
  40352. * If the object should rotate to face the drag origin
  40353. */
  40354. rotateDraggedObject: boolean;
  40355. /**
  40356. * If the behavior is currently in a dragging state
  40357. */
  40358. dragging: boolean;
  40359. /**
  40360. * 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)
  40361. */
  40362. dragDeltaRatio: number;
  40363. /**
  40364. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40365. */
  40366. currentDraggingPointerID: number;
  40367. /**
  40368. * If camera controls should be detached during the drag
  40369. */
  40370. detachCameraControls: boolean;
  40371. /**
  40372. * Fires each time a drag starts
  40373. */
  40374. onDragStartObservable: Observable<{}>;
  40375. /**
  40376. * Fires each time a drag ends (eg. mouse release after drag)
  40377. */
  40378. onDragEndObservable: Observable<{}>;
  40379. /**
  40380. * 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
  40381. */
  40382. constructor();
  40383. /**
  40384. * The name of the behavior
  40385. */
  40386. get name(): string;
  40387. /**
  40388. * Initializes the behavior
  40389. */
  40390. init(): void;
  40391. /**
  40392. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40393. */
  40394. private get _pointerCamera();
  40395. /**
  40396. * Attaches the scale behavior the passed in mesh
  40397. * @param ownerNode The mesh that will be scaled around once attached
  40398. */
  40399. attach(ownerNode: Mesh): void;
  40400. /**
  40401. * Detaches the behavior from the mesh
  40402. */
  40403. detach(): void;
  40404. }
  40405. }
  40406. declare module "babylonjs/Behaviors/Meshes/index" {
  40407. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40408. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40409. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40410. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40411. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40412. }
  40413. declare module "babylonjs/Behaviors/index" {
  40414. export * from "babylonjs/Behaviors/behavior";
  40415. export * from "babylonjs/Behaviors/Cameras/index";
  40416. export * from "babylonjs/Behaviors/Meshes/index";
  40417. }
  40418. declare module "babylonjs/Bones/boneIKController" {
  40419. import { Bone } from "babylonjs/Bones/bone";
  40420. import { Vector3 } from "babylonjs/Maths/math.vector";
  40421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40422. import { Nullable } from "babylonjs/types";
  40423. /**
  40424. * Class used to apply inverse kinematics to bones
  40425. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40426. */
  40427. export class BoneIKController {
  40428. private static _tmpVecs;
  40429. private static _tmpQuat;
  40430. private static _tmpMats;
  40431. /**
  40432. * Gets or sets the target mesh
  40433. */
  40434. targetMesh: AbstractMesh;
  40435. /** Gets or sets the mesh used as pole */
  40436. poleTargetMesh: AbstractMesh;
  40437. /**
  40438. * Gets or sets the bone used as pole
  40439. */
  40440. poleTargetBone: Nullable<Bone>;
  40441. /**
  40442. * Gets or sets the target position
  40443. */
  40444. targetPosition: Vector3;
  40445. /**
  40446. * Gets or sets the pole target position
  40447. */
  40448. poleTargetPosition: Vector3;
  40449. /**
  40450. * Gets or sets the pole target local offset
  40451. */
  40452. poleTargetLocalOffset: Vector3;
  40453. /**
  40454. * Gets or sets the pole angle
  40455. */
  40456. poleAngle: number;
  40457. /**
  40458. * Gets or sets the mesh associated with the controller
  40459. */
  40460. mesh: AbstractMesh;
  40461. /**
  40462. * 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)
  40463. */
  40464. slerpAmount: number;
  40465. private _bone1Quat;
  40466. private _bone1Mat;
  40467. private _bone2Ang;
  40468. private _bone1;
  40469. private _bone2;
  40470. private _bone1Length;
  40471. private _bone2Length;
  40472. private _maxAngle;
  40473. private _maxReach;
  40474. private _rightHandedSystem;
  40475. private _bendAxis;
  40476. private _slerping;
  40477. private _adjustRoll;
  40478. /**
  40479. * Gets or sets maximum allowed angle
  40480. */
  40481. get maxAngle(): number;
  40482. set maxAngle(value: number);
  40483. /**
  40484. * Creates a new BoneIKController
  40485. * @param mesh defines the mesh to control
  40486. * @param bone defines the bone to control
  40487. * @param options defines options to set up the controller
  40488. */
  40489. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40490. targetMesh?: AbstractMesh;
  40491. poleTargetMesh?: AbstractMesh;
  40492. poleTargetBone?: Bone;
  40493. poleTargetLocalOffset?: Vector3;
  40494. poleAngle?: number;
  40495. bendAxis?: Vector3;
  40496. maxAngle?: number;
  40497. slerpAmount?: number;
  40498. });
  40499. private _setMaxAngle;
  40500. /**
  40501. * Force the controller to update the bones
  40502. */
  40503. update(): void;
  40504. }
  40505. }
  40506. declare module "babylonjs/Bones/boneLookController" {
  40507. import { Vector3 } from "babylonjs/Maths/math.vector";
  40508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40509. import { Bone } from "babylonjs/Bones/bone";
  40510. import { Space } from "babylonjs/Maths/math.axis";
  40511. /**
  40512. * Class used to make a bone look toward a point in space
  40513. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40514. */
  40515. export class BoneLookController {
  40516. private static _tmpVecs;
  40517. private static _tmpQuat;
  40518. private static _tmpMats;
  40519. /**
  40520. * The target Vector3 that the bone will look at
  40521. */
  40522. target: Vector3;
  40523. /**
  40524. * The mesh that the bone is attached to
  40525. */
  40526. mesh: AbstractMesh;
  40527. /**
  40528. * The bone that will be looking to the target
  40529. */
  40530. bone: Bone;
  40531. /**
  40532. * The up axis of the coordinate system that is used when the bone is rotated
  40533. */
  40534. upAxis: Vector3;
  40535. /**
  40536. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40537. */
  40538. upAxisSpace: Space;
  40539. /**
  40540. * Used to make an adjustment to the yaw of the bone
  40541. */
  40542. adjustYaw: number;
  40543. /**
  40544. * Used to make an adjustment to the pitch of the bone
  40545. */
  40546. adjustPitch: number;
  40547. /**
  40548. * Used to make an adjustment to the roll of the bone
  40549. */
  40550. adjustRoll: number;
  40551. /**
  40552. * 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)
  40553. */
  40554. slerpAmount: number;
  40555. private _minYaw;
  40556. private _maxYaw;
  40557. private _minPitch;
  40558. private _maxPitch;
  40559. private _minYawSin;
  40560. private _minYawCos;
  40561. private _maxYawSin;
  40562. private _maxYawCos;
  40563. private _midYawConstraint;
  40564. private _minPitchTan;
  40565. private _maxPitchTan;
  40566. private _boneQuat;
  40567. private _slerping;
  40568. private _transformYawPitch;
  40569. private _transformYawPitchInv;
  40570. private _firstFrameSkipped;
  40571. private _yawRange;
  40572. private _fowardAxis;
  40573. /**
  40574. * Gets or sets the minimum yaw angle that the bone can look to
  40575. */
  40576. get minYaw(): number;
  40577. set minYaw(value: number);
  40578. /**
  40579. * Gets or sets the maximum yaw angle that the bone can look to
  40580. */
  40581. get maxYaw(): number;
  40582. set maxYaw(value: number);
  40583. /**
  40584. * Gets or sets the minimum pitch angle that the bone can look to
  40585. */
  40586. get minPitch(): number;
  40587. set minPitch(value: number);
  40588. /**
  40589. * Gets or sets the maximum pitch angle that the bone can look to
  40590. */
  40591. get maxPitch(): number;
  40592. set maxPitch(value: number);
  40593. /**
  40594. * Create a BoneLookController
  40595. * @param mesh the mesh that the bone belongs to
  40596. * @param bone the bone that will be looking to the target
  40597. * @param target the target Vector3 to look at
  40598. * @param options optional settings:
  40599. * * maxYaw: the maximum angle the bone will yaw to
  40600. * * minYaw: the minimum angle the bone will yaw to
  40601. * * maxPitch: the maximum angle the bone will pitch to
  40602. * * minPitch: the minimum angle the bone will yaw to
  40603. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40604. * * upAxis: the up axis of the coordinate system
  40605. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40606. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40607. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40608. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40609. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40610. * * adjustRoll: used to make an adjustment to the roll of the bone
  40611. **/
  40612. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40613. maxYaw?: number;
  40614. minYaw?: number;
  40615. maxPitch?: number;
  40616. minPitch?: number;
  40617. slerpAmount?: number;
  40618. upAxis?: Vector3;
  40619. upAxisSpace?: Space;
  40620. yawAxis?: Vector3;
  40621. pitchAxis?: Vector3;
  40622. adjustYaw?: number;
  40623. adjustPitch?: number;
  40624. adjustRoll?: number;
  40625. });
  40626. /**
  40627. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40628. */
  40629. update(): void;
  40630. private _getAngleDiff;
  40631. private _getAngleBetween;
  40632. private _isAngleBetween;
  40633. }
  40634. }
  40635. declare module "babylonjs/Bones/index" {
  40636. export * from "babylonjs/Bones/bone";
  40637. export * from "babylonjs/Bones/boneIKController";
  40638. export * from "babylonjs/Bones/boneLookController";
  40639. export * from "babylonjs/Bones/skeleton";
  40640. }
  40641. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40642. import { Nullable } from "babylonjs/types";
  40643. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40644. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40645. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40646. /**
  40647. * Manage the gamepad inputs to control an arc rotate camera.
  40648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40649. */
  40650. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40651. /**
  40652. * Defines the camera the input is attached to.
  40653. */
  40654. camera: ArcRotateCamera;
  40655. /**
  40656. * Defines the gamepad the input is gathering event from.
  40657. */
  40658. gamepad: Nullable<Gamepad>;
  40659. /**
  40660. * Defines the gamepad rotation sensiblity.
  40661. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40662. */
  40663. gamepadRotationSensibility: number;
  40664. /**
  40665. * Defines the gamepad move sensiblity.
  40666. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40667. */
  40668. gamepadMoveSensibility: number;
  40669. private _yAxisScale;
  40670. /**
  40671. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40672. */
  40673. get invertYAxis(): boolean;
  40674. set invertYAxis(value: boolean);
  40675. private _onGamepadConnectedObserver;
  40676. private _onGamepadDisconnectedObserver;
  40677. /**
  40678. * Attach the input controls to a specific dom element to get the input from.
  40679. * @param element Defines the element the controls should be listened from
  40680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40681. */
  40682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40683. /**
  40684. * Detach the current controls from the specified dom element.
  40685. * @param element Defines the element to stop listening the inputs from
  40686. */
  40687. detachControl(element: Nullable<HTMLElement>): void;
  40688. /**
  40689. * Update the current camera state depending on the inputs that have been used this frame.
  40690. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40691. */
  40692. checkInputs(): void;
  40693. /**
  40694. * Gets the class name of the current intput.
  40695. * @returns the class name
  40696. */
  40697. getClassName(): string;
  40698. /**
  40699. * Get the friendly name associated with the input class.
  40700. * @returns the input friendly name
  40701. */
  40702. getSimpleName(): string;
  40703. }
  40704. }
  40705. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40706. import { Nullable } from "babylonjs/types";
  40707. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40708. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40709. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40710. interface ArcRotateCameraInputsManager {
  40711. /**
  40712. * Add orientation input support to the input manager.
  40713. * @returns the current input manager
  40714. */
  40715. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40716. }
  40717. }
  40718. /**
  40719. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40721. */
  40722. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40723. /**
  40724. * Defines the camera the input is attached to.
  40725. */
  40726. camera: ArcRotateCamera;
  40727. /**
  40728. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40729. */
  40730. alphaCorrection: number;
  40731. /**
  40732. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40733. */
  40734. gammaCorrection: number;
  40735. private _alpha;
  40736. private _gamma;
  40737. private _dirty;
  40738. private _deviceOrientationHandler;
  40739. /**
  40740. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40741. */
  40742. constructor();
  40743. /**
  40744. * Attach the input controls to a specific dom element to get the input from.
  40745. * @param element Defines the element the controls should be listened from
  40746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40747. */
  40748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40749. /** @hidden */
  40750. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40751. /**
  40752. * Update the current camera state depending on the inputs that have been used this frame.
  40753. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40754. */
  40755. checkInputs(): void;
  40756. /**
  40757. * Detach the current controls from the specified dom element.
  40758. * @param element Defines the element to stop listening the inputs from
  40759. */
  40760. detachControl(element: Nullable<HTMLElement>): void;
  40761. /**
  40762. * Gets the class name of the current intput.
  40763. * @returns the class name
  40764. */
  40765. getClassName(): string;
  40766. /**
  40767. * Get the friendly name associated with the input class.
  40768. * @returns the input friendly name
  40769. */
  40770. getSimpleName(): string;
  40771. }
  40772. }
  40773. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40774. import { Nullable } from "babylonjs/types";
  40775. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40776. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40777. /**
  40778. * Listen to mouse events to control the camera.
  40779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40780. */
  40781. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40782. /**
  40783. * Defines the camera the input is attached to.
  40784. */
  40785. camera: FlyCamera;
  40786. /**
  40787. * Defines if touch is enabled. (Default is true.)
  40788. */
  40789. touchEnabled: boolean;
  40790. /**
  40791. * Defines the buttons associated with the input to handle camera rotation.
  40792. */
  40793. buttons: number[];
  40794. /**
  40795. * Assign buttons for Yaw control.
  40796. */
  40797. buttonsYaw: number[];
  40798. /**
  40799. * Assign buttons for Pitch control.
  40800. */
  40801. buttonsPitch: number[];
  40802. /**
  40803. * Assign buttons for Roll control.
  40804. */
  40805. buttonsRoll: number[];
  40806. /**
  40807. * Detect if any button is being pressed while mouse is moved.
  40808. * -1 = Mouse locked.
  40809. * 0 = Left button.
  40810. * 1 = Middle Button.
  40811. * 2 = Right Button.
  40812. */
  40813. activeButton: number;
  40814. /**
  40815. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40816. * Higher values reduce its sensitivity.
  40817. */
  40818. angularSensibility: number;
  40819. private _mousemoveCallback;
  40820. private _observer;
  40821. private _rollObserver;
  40822. private previousPosition;
  40823. private noPreventDefault;
  40824. private element;
  40825. /**
  40826. * Listen to mouse events to control the camera.
  40827. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40829. */
  40830. constructor(touchEnabled?: boolean);
  40831. /**
  40832. * Attach the mouse control to the HTML DOM element.
  40833. * @param element Defines the element that listens to the input events.
  40834. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40835. */
  40836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40837. /**
  40838. * Detach the current controls from the specified dom element.
  40839. * @param element Defines the element to stop listening the inputs from
  40840. */
  40841. detachControl(element: Nullable<HTMLElement>): void;
  40842. /**
  40843. * Gets the class name of the current input.
  40844. * @returns the class name.
  40845. */
  40846. getClassName(): string;
  40847. /**
  40848. * Get the friendly name associated with the input class.
  40849. * @returns the input's friendly name.
  40850. */
  40851. getSimpleName(): string;
  40852. private _pointerInput;
  40853. private _onMouseMove;
  40854. /**
  40855. * Rotate camera by mouse offset.
  40856. */
  40857. private rotateCamera;
  40858. }
  40859. }
  40860. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40861. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40862. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40863. /**
  40864. * Default Inputs manager for the FlyCamera.
  40865. * It groups all the default supported inputs for ease of use.
  40866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40867. */
  40868. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40869. /**
  40870. * Instantiates a new FlyCameraInputsManager.
  40871. * @param camera Defines the camera the inputs belong to.
  40872. */
  40873. constructor(camera: FlyCamera);
  40874. /**
  40875. * Add keyboard input support to the input manager.
  40876. * @returns the new FlyCameraKeyboardMoveInput().
  40877. */
  40878. addKeyboard(): FlyCameraInputsManager;
  40879. /**
  40880. * Add mouse input support to the input manager.
  40881. * @param touchEnabled Enable touch screen support.
  40882. * @returns the new FlyCameraMouseInput().
  40883. */
  40884. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40885. }
  40886. }
  40887. declare module "babylonjs/Cameras/flyCamera" {
  40888. import { Scene } from "babylonjs/scene";
  40889. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40891. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40892. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40893. /**
  40894. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40895. * such as in a 3D Space Shooter or a Flight Simulator.
  40896. */
  40897. export class FlyCamera extends TargetCamera {
  40898. /**
  40899. * Define the collision ellipsoid of the camera.
  40900. * This is helpful for simulating a camera body, like a player's body.
  40901. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40902. */
  40903. ellipsoid: Vector3;
  40904. /**
  40905. * Define an offset for the position of the ellipsoid around the camera.
  40906. * This can be helpful if the camera is attached away from the player's body center,
  40907. * such as at its head.
  40908. */
  40909. ellipsoidOffset: Vector3;
  40910. /**
  40911. * Enable or disable collisions of the camera with the rest of the scene objects.
  40912. */
  40913. checkCollisions: boolean;
  40914. /**
  40915. * Enable or disable gravity on the camera.
  40916. */
  40917. applyGravity: boolean;
  40918. /**
  40919. * Define the current direction the camera is moving to.
  40920. */
  40921. cameraDirection: Vector3;
  40922. /**
  40923. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40924. * This overrides and empties cameraRotation.
  40925. */
  40926. rotationQuaternion: Quaternion;
  40927. /**
  40928. * Track Roll to maintain the wanted Rolling when looking around.
  40929. */
  40930. _trackRoll: number;
  40931. /**
  40932. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40933. */
  40934. rollCorrect: number;
  40935. /**
  40936. * Mimic a banked turn, Rolling the camera when Yawing.
  40937. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40938. */
  40939. bankedTurn: boolean;
  40940. /**
  40941. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40942. */
  40943. bankedTurnLimit: number;
  40944. /**
  40945. * Value of 0 disables the banked Roll.
  40946. * Value of 1 is equal to the Yaw angle in radians.
  40947. */
  40948. bankedTurnMultiplier: number;
  40949. /**
  40950. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40951. */
  40952. inputs: FlyCameraInputsManager;
  40953. /**
  40954. * Gets the input sensibility for mouse input.
  40955. * Higher values reduce sensitivity.
  40956. */
  40957. get angularSensibility(): number;
  40958. /**
  40959. * Sets the input sensibility for a mouse input.
  40960. * Higher values reduce sensitivity.
  40961. */
  40962. set angularSensibility(value: number);
  40963. /**
  40964. * Get the keys for camera movement forward.
  40965. */
  40966. get keysForward(): number[];
  40967. /**
  40968. * Set the keys for camera movement forward.
  40969. */
  40970. set keysForward(value: number[]);
  40971. /**
  40972. * Get the keys for camera movement backward.
  40973. */
  40974. get keysBackward(): number[];
  40975. set keysBackward(value: number[]);
  40976. /**
  40977. * Get the keys for camera movement up.
  40978. */
  40979. get keysUp(): number[];
  40980. /**
  40981. * Set the keys for camera movement up.
  40982. */
  40983. set keysUp(value: number[]);
  40984. /**
  40985. * Get the keys for camera movement down.
  40986. */
  40987. get keysDown(): number[];
  40988. /**
  40989. * Set the keys for camera movement down.
  40990. */
  40991. set keysDown(value: number[]);
  40992. /**
  40993. * Get the keys for camera movement left.
  40994. */
  40995. get keysLeft(): number[];
  40996. /**
  40997. * Set the keys for camera movement left.
  40998. */
  40999. set keysLeft(value: number[]);
  41000. /**
  41001. * Set the keys for camera movement right.
  41002. */
  41003. get keysRight(): number[];
  41004. /**
  41005. * Set the keys for camera movement right.
  41006. */
  41007. set keysRight(value: number[]);
  41008. /**
  41009. * Event raised when the camera collides with a mesh in the scene.
  41010. */
  41011. onCollide: (collidedMesh: AbstractMesh) => void;
  41012. private _collider;
  41013. private _needMoveForGravity;
  41014. private _oldPosition;
  41015. private _diffPosition;
  41016. private _newPosition;
  41017. /** @hidden */
  41018. _localDirection: Vector3;
  41019. /** @hidden */
  41020. _transformedDirection: Vector3;
  41021. /**
  41022. * Instantiates a FlyCamera.
  41023. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41024. * such as in a 3D Space Shooter or a Flight Simulator.
  41025. * @param name Define the name of the camera in the scene.
  41026. * @param position Define the starting position of the camera in the scene.
  41027. * @param scene Define the scene the camera belongs to.
  41028. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41029. */
  41030. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41031. /**
  41032. * Attach a control to the HTML DOM element.
  41033. * @param element Defines the element that listens to the input events.
  41034. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41035. */
  41036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41037. /**
  41038. * Detach a control from the HTML DOM element.
  41039. * The camera will stop reacting to that input.
  41040. * @param element Defines the element that listens to the input events.
  41041. */
  41042. detachControl(element: HTMLElement): void;
  41043. private _collisionMask;
  41044. /**
  41045. * Get the mask that the camera ignores in collision events.
  41046. */
  41047. get collisionMask(): number;
  41048. /**
  41049. * Set the mask that the camera ignores in collision events.
  41050. */
  41051. set collisionMask(mask: number);
  41052. /** @hidden */
  41053. _collideWithWorld(displacement: Vector3): void;
  41054. /** @hidden */
  41055. private _onCollisionPositionChange;
  41056. /** @hidden */
  41057. _checkInputs(): void;
  41058. /** @hidden */
  41059. _decideIfNeedsToMove(): boolean;
  41060. /** @hidden */
  41061. _updatePosition(): void;
  41062. /**
  41063. * Restore the Roll to its target value at the rate specified.
  41064. * @param rate - Higher means slower restoring.
  41065. * @hidden
  41066. */
  41067. restoreRoll(rate: number): void;
  41068. /**
  41069. * Destroy the camera and release the current resources held by it.
  41070. */
  41071. dispose(): void;
  41072. /**
  41073. * Get the current object class name.
  41074. * @returns the class name.
  41075. */
  41076. getClassName(): string;
  41077. }
  41078. }
  41079. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41080. import { Nullable } from "babylonjs/types";
  41081. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41082. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41083. /**
  41084. * Listen to keyboard events to control the camera.
  41085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41086. */
  41087. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41088. /**
  41089. * Defines the camera the input is attached to.
  41090. */
  41091. camera: FlyCamera;
  41092. /**
  41093. * The list of keyboard keys used to control the forward move of the camera.
  41094. */
  41095. keysForward: number[];
  41096. /**
  41097. * The list of keyboard keys used to control the backward move of the camera.
  41098. */
  41099. keysBackward: number[];
  41100. /**
  41101. * The list of keyboard keys used to control the forward move of the camera.
  41102. */
  41103. keysUp: number[];
  41104. /**
  41105. * The list of keyboard keys used to control the backward move of the camera.
  41106. */
  41107. keysDown: number[];
  41108. /**
  41109. * The list of keyboard keys used to control the right strafe move of the camera.
  41110. */
  41111. keysRight: number[];
  41112. /**
  41113. * The list of keyboard keys used to control the left strafe move of the camera.
  41114. */
  41115. keysLeft: number[];
  41116. private _keys;
  41117. private _onCanvasBlurObserver;
  41118. private _onKeyboardObserver;
  41119. private _engine;
  41120. private _scene;
  41121. /**
  41122. * Attach the input controls to a specific dom element to get the input from.
  41123. * @param element Defines the element the controls should be listened from
  41124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41125. */
  41126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41127. /**
  41128. * Detach the current controls from the specified dom element.
  41129. * @param element Defines the element to stop listening the inputs from
  41130. */
  41131. detachControl(element: Nullable<HTMLElement>): void;
  41132. /**
  41133. * Gets the class name of the current intput.
  41134. * @returns the class name
  41135. */
  41136. getClassName(): string;
  41137. /** @hidden */
  41138. _onLostFocus(e: FocusEvent): void;
  41139. /**
  41140. * Get the friendly name associated with the input class.
  41141. * @returns the input friendly name
  41142. */
  41143. getSimpleName(): string;
  41144. /**
  41145. * Update the current camera state depending on the inputs that have been used this frame.
  41146. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41147. */
  41148. checkInputs(): void;
  41149. }
  41150. }
  41151. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41152. import { Nullable } from "babylonjs/types";
  41153. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41154. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41155. /**
  41156. * Manage the mouse wheel inputs to control a follow camera.
  41157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41158. */
  41159. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41160. /**
  41161. * Defines the camera the input is attached to.
  41162. */
  41163. camera: FollowCamera;
  41164. /**
  41165. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41166. */
  41167. axisControlRadius: boolean;
  41168. /**
  41169. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41170. */
  41171. axisControlHeight: boolean;
  41172. /**
  41173. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41174. */
  41175. axisControlRotation: boolean;
  41176. /**
  41177. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41178. * relation to mouseWheel events.
  41179. */
  41180. wheelPrecision: number;
  41181. /**
  41182. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41183. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41184. */
  41185. wheelDeltaPercentage: number;
  41186. private _wheel;
  41187. private _observer;
  41188. /**
  41189. * Attach the input controls to a specific dom element to get the input from.
  41190. * @param element Defines the element the controls should be listened from
  41191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41192. */
  41193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41194. /**
  41195. * Detach the current controls from the specified dom element.
  41196. * @param element Defines the element to stop listening the inputs from
  41197. */
  41198. detachControl(element: Nullable<HTMLElement>): void;
  41199. /**
  41200. * Gets the class name of the current intput.
  41201. * @returns the class name
  41202. */
  41203. getClassName(): string;
  41204. /**
  41205. * Get the friendly name associated with the input class.
  41206. * @returns the input friendly name
  41207. */
  41208. getSimpleName(): string;
  41209. }
  41210. }
  41211. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41212. import { Nullable } from "babylonjs/types";
  41213. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41214. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41215. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41216. /**
  41217. * Manage the pointers inputs to control an follow camera.
  41218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41219. */
  41220. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41221. /**
  41222. * Defines the camera the input is attached to.
  41223. */
  41224. camera: FollowCamera;
  41225. /**
  41226. * Gets the class name of the current input.
  41227. * @returns the class name
  41228. */
  41229. getClassName(): string;
  41230. /**
  41231. * Defines the pointer angular sensibility along the X axis or how fast is
  41232. * the camera rotating.
  41233. * A negative number will reverse the axis direction.
  41234. */
  41235. angularSensibilityX: number;
  41236. /**
  41237. * Defines the pointer angular sensibility along the Y axis or how fast is
  41238. * the camera rotating.
  41239. * A negative number will reverse the axis direction.
  41240. */
  41241. angularSensibilityY: number;
  41242. /**
  41243. * Defines the pointer pinch precision or how fast is the camera zooming.
  41244. * A negative number will reverse the axis direction.
  41245. */
  41246. pinchPrecision: number;
  41247. /**
  41248. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41249. * from 0.
  41250. * It defines the percentage of current camera.radius to use as delta when
  41251. * pinch zoom is used.
  41252. */
  41253. pinchDeltaPercentage: number;
  41254. /**
  41255. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41256. */
  41257. axisXControlRadius: boolean;
  41258. /**
  41259. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41260. */
  41261. axisXControlHeight: boolean;
  41262. /**
  41263. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41264. */
  41265. axisXControlRotation: boolean;
  41266. /**
  41267. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41268. */
  41269. axisYControlRadius: boolean;
  41270. /**
  41271. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41272. */
  41273. axisYControlHeight: boolean;
  41274. /**
  41275. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41276. */
  41277. axisYControlRotation: boolean;
  41278. /**
  41279. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41280. */
  41281. axisPinchControlRadius: boolean;
  41282. /**
  41283. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41284. */
  41285. axisPinchControlHeight: boolean;
  41286. /**
  41287. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41288. */
  41289. axisPinchControlRotation: boolean;
  41290. /**
  41291. * Log error messages if basic misconfiguration has occurred.
  41292. */
  41293. warningEnable: boolean;
  41294. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41295. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41296. private _warningCounter;
  41297. private _warning;
  41298. }
  41299. }
  41300. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41301. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41302. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41303. /**
  41304. * Default Inputs manager for the FollowCamera.
  41305. * It groups all the default supported inputs for ease of use.
  41306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41307. */
  41308. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41309. /**
  41310. * Instantiates a new FollowCameraInputsManager.
  41311. * @param camera Defines the camera the inputs belong to
  41312. */
  41313. constructor(camera: FollowCamera);
  41314. /**
  41315. * Add keyboard input support to the input manager.
  41316. * @returns the current input manager
  41317. */
  41318. addKeyboard(): FollowCameraInputsManager;
  41319. /**
  41320. * Add mouse wheel input support to the input manager.
  41321. * @returns the current input manager
  41322. */
  41323. addMouseWheel(): FollowCameraInputsManager;
  41324. /**
  41325. * Add pointers input support to the input manager.
  41326. * @returns the current input manager
  41327. */
  41328. addPointers(): FollowCameraInputsManager;
  41329. /**
  41330. * Add orientation input support to the input manager.
  41331. * @returns the current input manager
  41332. */
  41333. addVRDeviceOrientation(): FollowCameraInputsManager;
  41334. }
  41335. }
  41336. declare module "babylonjs/Cameras/followCamera" {
  41337. import { Nullable } from "babylonjs/types";
  41338. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41339. import { Scene } from "babylonjs/scene";
  41340. import { Vector3 } from "babylonjs/Maths/math.vector";
  41341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41342. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41343. /**
  41344. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41345. * an arc rotate version arcFollowCamera are available.
  41346. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41347. */
  41348. export class FollowCamera extends TargetCamera {
  41349. /**
  41350. * Distance the follow camera should follow an object at
  41351. */
  41352. radius: number;
  41353. /**
  41354. * Minimum allowed distance of the camera to the axis of rotation
  41355. * (The camera can not get closer).
  41356. * This can help limiting how the Camera is able to move in the scene.
  41357. */
  41358. lowerRadiusLimit: Nullable<number>;
  41359. /**
  41360. * Maximum allowed distance of the camera to the axis of rotation
  41361. * (The camera can not get further).
  41362. * This can help limiting how the Camera is able to move in the scene.
  41363. */
  41364. upperRadiusLimit: Nullable<number>;
  41365. /**
  41366. * Define a rotation offset between the camera and the object it follows
  41367. */
  41368. rotationOffset: number;
  41369. /**
  41370. * Minimum allowed angle to camera position relative to target object.
  41371. * This can help limiting how the Camera is able to move in the scene.
  41372. */
  41373. lowerRotationOffsetLimit: Nullable<number>;
  41374. /**
  41375. * Maximum allowed angle to camera position relative to target object.
  41376. * This can help limiting how the Camera is able to move in the scene.
  41377. */
  41378. upperRotationOffsetLimit: Nullable<number>;
  41379. /**
  41380. * Define a height offset between the camera and the object it follows.
  41381. * It can help following an object from the top (like a car chaing a plane)
  41382. */
  41383. heightOffset: number;
  41384. /**
  41385. * Minimum allowed height of camera position relative to target object.
  41386. * This can help limiting how the Camera is able to move in the scene.
  41387. */
  41388. lowerHeightOffsetLimit: Nullable<number>;
  41389. /**
  41390. * Maximum allowed height of camera position relative to target object.
  41391. * This can help limiting how the Camera is able to move in the scene.
  41392. */
  41393. upperHeightOffsetLimit: Nullable<number>;
  41394. /**
  41395. * Define how fast the camera can accelerate to follow it s target.
  41396. */
  41397. cameraAcceleration: number;
  41398. /**
  41399. * Define the speed limit of the camera following an object.
  41400. */
  41401. maxCameraSpeed: number;
  41402. /**
  41403. * Define the target of the camera.
  41404. */
  41405. lockedTarget: Nullable<AbstractMesh>;
  41406. /**
  41407. * Defines the input associated with the camera.
  41408. */
  41409. inputs: FollowCameraInputsManager;
  41410. /**
  41411. * Instantiates the follow camera.
  41412. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41413. * @param name Define the name of the camera in the scene
  41414. * @param position Define the position of the camera
  41415. * @param scene Define the scene the camera belong to
  41416. * @param lockedTarget Define the target of the camera
  41417. */
  41418. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41419. private _follow;
  41420. /**
  41421. * Attached controls to the current camera.
  41422. * @param element Defines the element the controls should be listened from
  41423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41424. */
  41425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41426. /**
  41427. * Detach the current controls from the camera.
  41428. * The camera will stop reacting to inputs.
  41429. * @param element Defines the element to stop listening the inputs from
  41430. */
  41431. detachControl(element: HTMLElement): void;
  41432. /** @hidden */
  41433. _checkInputs(): void;
  41434. private _checkLimits;
  41435. /**
  41436. * Gets the camera class name.
  41437. * @returns the class name
  41438. */
  41439. getClassName(): string;
  41440. }
  41441. /**
  41442. * Arc Rotate version of the follow camera.
  41443. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41444. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41445. */
  41446. export class ArcFollowCamera extends TargetCamera {
  41447. /** The longitudinal angle of the camera */
  41448. alpha: number;
  41449. /** The latitudinal angle of the camera */
  41450. beta: number;
  41451. /** The radius of the camera from its target */
  41452. radius: number;
  41453. /** Define the camera target (the messh it should follow) */
  41454. target: Nullable<AbstractMesh>;
  41455. private _cartesianCoordinates;
  41456. /**
  41457. * Instantiates a new ArcFollowCamera
  41458. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41459. * @param name Define the name of the camera
  41460. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41461. * @param beta Define the rotation angle of the camera around the elevation axis
  41462. * @param radius Define the radius of the camera from its target point
  41463. * @param target Define the target of the camera
  41464. * @param scene Define the scene the camera belongs to
  41465. */
  41466. constructor(name: string,
  41467. /** The longitudinal angle of the camera */
  41468. alpha: number,
  41469. /** The latitudinal angle of the camera */
  41470. beta: number,
  41471. /** The radius of the camera from its target */
  41472. radius: number,
  41473. /** Define the camera target (the messh it should follow) */
  41474. target: Nullable<AbstractMesh>, scene: Scene);
  41475. private _follow;
  41476. /** @hidden */
  41477. _checkInputs(): void;
  41478. /**
  41479. * Returns the class name of the object.
  41480. * It is mostly used internally for serialization purposes.
  41481. */
  41482. getClassName(): string;
  41483. }
  41484. }
  41485. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41486. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41487. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41488. import { Nullable } from "babylonjs/types";
  41489. /**
  41490. * Manage the keyboard inputs to control the movement of a follow camera.
  41491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41492. */
  41493. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41494. /**
  41495. * Defines the camera the input is attached to.
  41496. */
  41497. camera: FollowCamera;
  41498. /**
  41499. * Defines the list of key codes associated with the up action (increase heightOffset)
  41500. */
  41501. keysHeightOffsetIncr: number[];
  41502. /**
  41503. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41504. */
  41505. keysHeightOffsetDecr: number[];
  41506. /**
  41507. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41508. */
  41509. keysHeightOffsetModifierAlt: boolean;
  41510. /**
  41511. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41512. */
  41513. keysHeightOffsetModifierCtrl: boolean;
  41514. /**
  41515. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41516. */
  41517. keysHeightOffsetModifierShift: boolean;
  41518. /**
  41519. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41520. */
  41521. keysRotationOffsetIncr: number[];
  41522. /**
  41523. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41524. */
  41525. keysRotationOffsetDecr: number[];
  41526. /**
  41527. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41528. */
  41529. keysRotationOffsetModifierAlt: boolean;
  41530. /**
  41531. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41532. */
  41533. keysRotationOffsetModifierCtrl: boolean;
  41534. /**
  41535. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41536. */
  41537. keysRotationOffsetModifierShift: boolean;
  41538. /**
  41539. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41540. */
  41541. keysRadiusIncr: number[];
  41542. /**
  41543. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41544. */
  41545. keysRadiusDecr: number[];
  41546. /**
  41547. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41548. */
  41549. keysRadiusModifierAlt: boolean;
  41550. /**
  41551. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41552. */
  41553. keysRadiusModifierCtrl: boolean;
  41554. /**
  41555. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41556. */
  41557. keysRadiusModifierShift: boolean;
  41558. /**
  41559. * Defines the rate of change of heightOffset.
  41560. */
  41561. heightSensibility: number;
  41562. /**
  41563. * Defines the rate of change of rotationOffset.
  41564. */
  41565. rotationSensibility: number;
  41566. /**
  41567. * Defines the rate of change of radius.
  41568. */
  41569. radiusSensibility: number;
  41570. private _keys;
  41571. private _ctrlPressed;
  41572. private _altPressed;
  41573. private _shiftPressed;
  41574. private _onCanvasBlurObserver;
  41575. private _onKeyboardObserver;
  41576. private _engine;
  41577. private _scene;
  41578. /**
  41579. * Attach the input controls to a specific dom element to get the input from.
  41580. * @param element Defines the element the controls should be listened from
  41581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41582. */
  41583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41584. /**
  41585. * Detach the current controls from the specified dom element.
  41586. * @param element Defines the element to stop listening the inputs from
  41587. */
  41588. detachControl(element: Nullable<HTMLElement>): void;
  41589. /**
  41590. * Update the current camera state depending on the inputs that have been used this frame.
  41591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41592. */
  41593. checkInputs(): void;
  41594. /**
  41595. * Gets the class name of the current input.
  41596. * @returns the class name
  41597. */
  41598. getClassName(): string;
  41599. /**
  41600. * Get the friendly name associated with the input class.
  41601. * @returns the input friendly name
  41602. */
  41603. getSimpleName(): string;
  41604. /**
  41605. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41606. * allow modification of the heightOffset value.
  41607. */
  41608. private _modifierHeightOffset;
  41609. /**
  41610. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41611. * allow modification of the rotationOffset value.
  41612. */
  41613. private _modifierRotationOffset;
  41614. /**
  41615. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41616. * allow modification of the radius value.
  41617. */
  41618. private _modifierRadius;
  41619. }
  41620. }
  41621. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41622. import { Nullable } from "babylonjs/types";
  41623. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41624. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41625. import { Observable } from "babylonjs/Misc/observable";
  41626. module "babylonjs/Cameras/freeCameraInputsManager" {
  41627. interface FreeCameraInputsManager {
  41628. /**
  41629. * @hidden
  41630. */
  41631. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41632. /**
  41633. * Add orientation input support to the input manager.
  41634. * @returns the current input manager
  41635. */
  41636. addDeviceOrientation(): FreeCameraInputsManager;
  41637. }
  41638. }
  41639. /**
  41640. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41641. * Screen rotation is taken into account.
  41642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41643. */
  41644. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41645. private _camera;
  41646. private _screenOrientationAngle;
  41647. private _constantTranform;
  41648. private _screenQuaternion;
  41649. private _alpha;
  41650. private _beta;
  41651. private _gamma;
  41652. /**
  41653. * Can be used to detect if a device orientation sensor is available on a device
  41654. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41655. * @returns a promise that will resolve on orientation change
  41656. */
  41657. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41658. /**
  41659. * @hidden
  41660. */
  41661. _onDeviceOrientationChangedObservable: Observable<void>;
  41662. /**
  41663. * Instantiates a new input
  41664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41665. */
  41666. constructor();
  41667. /**
  41668. * Define the camera controlled by the input.
  41669. */
  41670. get camera(): FreeCamera;
  41671. set camera(camera: FreeCamera);
  41672. /**
  41673. * Attach the input controls to a specific dom element to get the input from.
  41674. * @param element Defines the element the controls should be listened from
  41675. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41676. */
  41677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41678. private _orientationChanged;
  41679. private _deviceOrientation;
  41680. /**
  41681. * Detach the current controls from the specified dom element.
  41682. * @param element Defines the element to stop listening the inputs from
  41683. */
  41684. detachControl(element: Nullable<HTMLElement>): void;
  41685. /**
  41686. * Update the current camera state depending on the inputs that have been used this frame.
  41687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41688. */
  41689. checkInputs(): void;
  41690. /**
  41691. * Gets the class name of the current intput.
  41692. * @returns the class name
  41693. */
  41694. getClassName(): string;
  41695. /**
  41696. * Get the friendly name associated with the input class.
  41697. * @returns the input friendly name
  41698. */
  41699. getSimpleName(): string;
  41700. }
  41701. }
  41702. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41703. import { Nullable } from "babylonjs/types";
  41704. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41705. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41706. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41707. /**
  41708. * Manage the gamepad inputs to control a free camera.
  41709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41710. */
  41711. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41712. /**
  41713. * Define the camera the input is attached to.
  41714. */
  41715. camera: FreeCamera;
  41716. /**
  41717. * Define the Gamepad controlling the input
  41718. */
  41719. gamepad: Nullable<Gamepad>;
  41720. /**
  41721. * Defines the gamepad rotation sensiblity.
  41722. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41723. */
  41724. gamepadAngularSensibility: number;
  41725. /**
  41726. * Defines the gamepad move sensiblity.
  41727. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41728. */
  41729. gamepadMoveSensibility: number;
  41730. private _yAxisScale;
  41731. /**
  41732. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41733. */
  41734. get invertYAxis(): boolean;
  41735. set invertYAxis(value: boolean);
  41736. private _onGamepadConnectedObserver;
  41737. private _onGamepadDisconnectedObserver;
  41738. private _cameraTransform;
  41739. private _deltaTransform;
  41740. private _vector3;
  41741. private _vector2;
  41742. /**
  41743. * Attach the input controls to a specific dom element to get the input from.
  41744. * @param element Defines the element the controls should be listened from
  41745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41746. */
  41747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41748. /**
  41749. * Detach the current controls from the specified dom element.
  41750. * @param element Defines the element to stop listening the inputs from
  41751. */
  41752. detachControl(element: Nullable<HTMLElement>): void;
  41753. /**
  41754. * Update the current camera state depending on the inputs that have been used this frame.
  41755. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41756. */
  41757. checkInputs(): void;
  41758. /**
  41759. * Gets the class name of the current intput.
  41760. * @returns the class name
  41761. */
  41762. getClassName(): string;
  41763. /**
  41764. * Get the friendly name associated with the input class.
  41765. * @returns the input friendly name
  41766. */
  41767. getSimpleName(): string;
  41768. }
  41769. }
  41770. declare module "babylonjs/Misc/virtualJoystick" {
  41771. import { Nullable } from "babylonjs/types";
  41772. import { Vector3 } from "babylonjs/Maths/math.vector";
  41773. /**
  41774. * Defines the potential axis of a Joystick
  41775. */
  41776. export enum JoystickAxis {
  41777. /** X axis */
  41778. X = 0,
  41779. /** Y axis */
  41780. Y = 1,
  41781. /** Z axis */
  41782. Z = 2
  41783. }
  41784. /**
  41785. * Class used to define virtual joystick (used in touch mode)
  41786. */
  41787. export class VirtualJoystick {
  41788. /**
  41789. * Gets or sets a boolean indicating that left and right values must be inverted
  41790. */
  41791. reverseLeftRight: boolean;
  41792. /**
  41793. * Gets or sets a boolean indicating that up and down values must be inverted
  41794. */
  41795. reverseUpDown: boolean;
  41796. /**
  41797. * Gets the offset value for the position (ie. the change of the position value)
  41798. */
  41799. deltaPosition: Vector3;
  41800. /**
  41801. * Gets a boolean indicating if the virtual joystick was pressed
  41802. */
  41803. pressed: boolean;
  41804. /**
  41805. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41806. */
  41807. static Canvas: Nullable<HTMLCanvasElement>;
  41808. private static _globalJoystickIndex;
  41809. private static vjCanvasContext;
  41810. private static vjCanvasWidth;
  41811. private static vjCanvasHeight;
  41812. private static halfWidth;
  41813. private _action;
  41814. private _axisTargetedByLeftAndRight;
  41815. private _axisTargetedByUpAndDown;
  41816. private _joystickSensibility;
  41817. private _inversedSensibility;
  41818. private _joystickPointerID;
  41819. private _joystickColor;
  41820. private _joystickPointerPos;
  41821. private _joystickPreviousPointerPos;
  41822. private _joystickPointerStartPos;
  41823. private _deltaJoystickVector;
  41824. private _leftJoystick;
  41825. private _touches;
  41826. private _onPointerDownHandlerRef;
  41827. private _onPointerMoveHandlerRef;
  41828. private _onPointerUpHandlerRef;
  41829. private _onResize;
  41830. /**
  41831. * Creates a new virtual joystick
  41832. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41833. */
  41834. constructor(leftJoystick?: boolean);
  41835. /**
  41836. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41837. * @param newJoystickSensibility defines the new sensibility
  41838. */
  41839. setJoystickSensibility(newJoystickSensibility: number): void;
  41840. private _onPointerDown;
  41841. private _onPointerMove;
  41842. private _onPointerUp;
  41843. /**
  41844. * Change the color of the virtual joystick
  41845. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41846. */
  41847. setJoystickColor(newColor: string): void;
  41848. /**
  41849. * Defines a callback to call when the joystick is touched
  41850. * @param action defines the callback
  41851. */
  41852. setActionOnTouch(action: () => any): void;
  41853. /**
  41854. * Defines which axis you'd like to control for left & right
  41855. * @param axis defines the axis to use
  41856. */
  41857. setAxisForLeftRight(axis: JoystickAxis): void;
  41858. /**
  41859. * Defines which axis you'd like to control for up & down
  41860. * @param axis defines the axis to use
  41861. */
  41862. setAxisForUpDown(axis: JoystickAxis): void;
  41863. private _drawVirtualJoystick;
  41864. /**
  41865. * Release internal HTML canvas
  41866. */
  41867. releaseCanvas(): void;
  41868. }
  41869. }
  41870. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41871. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41872. import { Nullable } from "babylonjs/types";
  41873. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41874. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41875. module "babylonjs/Cameras/freeCameraInputsManager" {
  41876. interface FreeCameraInputsManager {
  41877. /**
  41878. * Add virtual joystick input support to the input manager.
  41879. * @returns the current input manager
  41880. */
  41881. addVirtualJoystick(): FreeCameraInputsManager;
  41882. }
  41883. }
  41884. /**
  41885. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41887. */
  41888. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41889. /**
  41890. * Defines the camera the input is attached to.
  41891. */
  41892. camera: FreeCamera;
  41893. private _leftjoystick;
  41894. private _rightjoystick;
  41895. /**
  41896. * Gets the left stick of the virtual joystick.
  41897. * @returns The virtual Joystick
  41898. */
  41899. getLeftJoystick(): VirtualJoystick;
  41900. /**
  41901. * Gets the right stick of the virtual joystick.
  41902. * @returns The virtual Joystick
  41903. */
  41904. getRightJoystick(): VirtualJoystick;
  41905. /**
  41906. * Update the current camera state depending on the inputs that have been used this frame.
  41907. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41908. */
  41909. checkInputs(): void;
  41910. /**
  41911. * Attach the input controls to a specific dom element to get the input from.
  41912. * @param element Defines the element the controls should be listened from
  41913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41914. */
  41915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41916. /**
  41917. * Detach the current controls from the specified dom element.
  41918. * @param element Defines the element to stop listening the inputs from
  41919. */
  41920. detachControl(element: Nullable<HTMLElement>): void;
  41921. /**
  41922. * Gets the class name of the current intput.
  41923. * @returns the class name
  41924. */
  41925. getClassName(): string;
  41926. /**
  41927. * Get the friendly name associated with the input class.
  41928. * @returns the input friendly name
  41929. */
  41930. getSimpleName(): string;
  41931. }
  41932. }
  41933. declare module "babylonjs/Cameras/Inputs/index" {
  41934. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41935. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41936. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41937. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41938. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41939. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41940. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41941. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41942. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41943. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41944. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41945. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41946. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41947. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41948. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41949. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41950. }
  41951. declare module "babylonjs/Cameras/touchCamera" {
  41952. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41953. import { Scene } from "babylonjs/scene";
  41954. import { Vector3 } from "babylonjs/Maths/math.vector";
  41955. /**
  41956. * This represents a FPS type of camera controlled by touch.
  41957. * This is like a universal camera minus the Gamepad controls.
  41958. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41959. */
  41960. export class TouchCamera extends FreeCamera {
  41961. /**
  41962. * Defines the touch sensibility for rotation.
  41963. * The higher the faster.
  41964. */
  41965. get touchAngularSensibility(): number;
  41966. set touchAngularSensibility(value: number);
  41967. /**
  41968. * Defines the touch sensibility for move.
  41969. * The higher the faster.
  41970. */
  41971. get touchMoveSensibility(): number;
  41972. set touchMoveSensibility(value: number);
  41973. /**
  41974. * Instantiates a new touch camera.
  41975. * This represents a FPS type of camera controlled by touch.
  41976. * This is like a universal camera minus the Gamepad controls.
  41977. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41978. * @param name Define the name of the camera in the scene
  41979. * @param position Define the start position of the camera in the scene
  41980. * @param scene Define the scene the camera belongs to
  41981. */
  41982. constructor(name: string, position: Vector3, scene: Scene);
  41983. /**
  41984. * Gets the current object class name.
  41985. * @return the class name
  41986. */
  41987. getClassName(): string;
  41988. /** @hidden */
  41989. _setupInputs(): void;
  41990. }
  41991. }
  41992. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41993. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41994. import { Scene } from "babylonjs/scene";
  41995. import { Vector3 } from "babylonjs/Maths/math.vector";
  41996. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41997. import { Axis } from "babylonjs/Maths/math.axis";
  41998. /**
  41999. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42000. * being tilted forward or back and left or right.
  42001. */
  42002. export class DeviceOrientationCamera extends FreeCamera {
  42003. private _initialQuaternion;
  42004. private _quaternionCache;
  42005. private _tmpDragQuaternion;
  42006. private _disablePointerInputWhenUsingDeviceOrientation;
  42007. /**
  42008. * Creates a new device orientation camera
  42009. * @param name The name of the camera
  42010. * @param position The start position camera
  42011. * @param scene The scene the camera belongs to
  42012. */
  42013. constructor(name: string, position: Vector3, scene: Scene);
  42014. /**
  42015. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42016. */
  42017. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42018. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42019. private _dragFactor;
  42020. /**
  42021. * Enabled turning on the y axis when the orientation sensor is active
  42022. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42023. */
  42024. enableHorizontalDragging(dragFactor?: number): void;
  42025. /**
  42026. * Gets the current instance class name ("DeviceOrientationCamera").
  42027. * This helps avoiding instanceof at run time.
  42028. * @returns the class name
  42029. */
  42030. getClassName(): string;
  42031. /**
  42032. * @hidden
  42033. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42034. */
  42035. _checkInputs(): void;
  42036. /**
  42037. * Reset the camera to its default orientation on the specified axis only.
  42038. * @param axis The axis to reset
  42039. */
  42040. resetToCurrentRotation(axis?: Axis): void;
  42041. }
  42042. }
  42043. declare module "babylonjs/Gamepads/xboxGamepad" {
  42044. import { Observable } from "babylonjs/Misc/observable";
  42045. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42046. /**
  42047. * Defines supported buttons for XBox360 compatible gamepads
  42048. */
  42049. export enum Xbox360Button {
  42050. /** A */
  42051. A = 0,
  42052. /** B */
  42053. B = 1,
  42054. /** X */
  42055. X = 2,
  42056. /** Y */
  42057. Y = 3,
  42058. /** Start */
  42059. Start = 4,
  42060. /** Back */
  42061. Back = 5,
  42062. /** Left button */
  42063. LB = 6,
  42064. /** Right button */
  42065. RB = 7,
  42066. /** Left stick */
  42067. LeftStick = 8,
  42068. /** Right stick */
  42069. RightStick = 9
  42070. }
  42071. /** Defines values for XBox360 DPad */
  42072. export enum Xbox360Dpad {
  42073. /** Up */
  42074. Up = 0,
  42075. /** Down */
  42076. Down = 1,
  42077. /** Left */
  42078. Left = 2,
  42079. /** Right */
  42080. Right = 3
  42081. }
  42082. /**
  42083. * Defines a XBox360 gamepad
  42084. */
  42085. export class Xbox360Pad extends Gamepad {
  42086. private _leftTrigger;
  42087. private _rightTrigger;
  42088. private _onlefttriggerchanged;
  42089. private _onrighttriggerchanged;
  42090. private _onbuttondown;
  42091. private _onbuttonup;
  42092. private _ondpaddown;
  42093. private _ondpadup;
  42094. /** Observable raised when a button is pressed */
  42095. onButtonDownObservable: Observable<Xbox360Button>;
  42096. /** Observable raised when a button is released */
  42097. onButtonUpObservable: Observable<Xbox360Button>;
  42098. /** Observable raised when a pad is pressed */
  42099. onPadDownObservable: Observable<Xbox360Dpad>;
  42100. /** Observable raised when a pad is released */
  42101. onPadUpObservable: Observable<Xbox360Dpad>;
  42102. private _buttonA;
  42103. private _buttonB;
  42104. private _buttonX;
  42105. private _buttonY;
  42106. private _buttonBack;
  42107. private _buttonStart;
  42108. private _buttonLB;
  42109. private _buttonRB;
  42110. private _buttonLeftStick;
  42111. private _buttonRightStick;
  42112. private _dPadUp;
  42113. private _dPadDown;
  42114. private _dPadLeft;
  42115. private _dPadRight;
  42116. private _isXboxOnePad;
  42117. /**
  42118. * Creates a new XBox360 gamepad object
  42119. * @param id defines the id of this gamepad
  42120. * @param index defines its index
  42121. * @param gamepad defines the internal HTML gamepad object
  42122. * @param xboxOne defines if it is a XBox One gamepad
  42123. */
  42124. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42125. /**
  42126. * Defines the callback to call when left trigger is pressed
  42127. * @param callback defines the callback to use
  42128. */
  42129. onlefttriggerchanged(callback: (value: number) => void): void;
  42130. /**
  42131. * Defines the callback to call when right trigger is pressed
  42132. * @param callback defines the callback to use
  42133. */
  42134. onrighttriggerchanged(callback: (value: number) => void): void;
  42135. /**
  42136. * Gets the left trigger value
  42137. */
  42138. get leftTrigger(): number;
  42139. /**
  42140. * Sets the left trigger value
  42141. */
  42142. set leftTrigger(newValue: number);
  42143. /**
  42144. * Gets the right trigger value
  42145. */
  42146. get rightTrigger(): number;
  42147. /**
  42148. * Sets the right trigger value
  42149. */
  42150. set rightTrigger(newValue: number);
  42151. /**
  42152. * Defines the callback to call when a button is pressed
  42153. * @param callback defines the callback to use
  42154. */
  42155. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42156. /**
  42157. * Defines the callback to call when a button is released
  42158. * @param callback defines the callback to use
  42159. */
  42160. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42161. /**
  42162. * Defines the callback to call when a pad is pressed
  42163. * @param callback defines the callback to use
  42164. */
  42165. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42166. /**
  42167. * Defines the callback to call when a pad is released
  42168. * @param callback defines the callback to use
  42169. */
  42170. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42171. private _setButtonValue;
  42172. private _setDPadValue;
  42173. /**
  42174. * Gets the value of the `A` button
  42175. */
  42176. get buttonA(): number;
  42177. /**
  42178. * Sets the value of the `A` button
  42179. */
  42180. set buttonA(value: number);
  42181. /**
  42182. * Gets the value of the `B` button
  42183. */
  42184. get buttonB(): number;
  42185. /**
  42186. * Sets the value of the `B` button
  42187. */
  42188. set buttonB(value: number);
  42189. /**
  42190. * Gets the value of the `X` button
  42191. */
  42192. get buttonX(): number;
  42193. /**
  42194. * Sets the value of the `X` button
  42195. */
  42196. set buttonX(value: number);
  42197. /**
  42198. * Gets the value of the `Y` button
  42199. */
  42200. get buttonY(): number;
  42201. /**
  42202. * Sets the value of the `Y` button
  42203. */
  42204. set buttonY(value: number);
  42205. /**
  42206. * Gets the value of the `Start` button
  42207. */
  42208. get buttonStart(): number;
  42209. /**
  42210. * Sets the value of the `Start` button
  42211. */
  42212. set buttonStart(value: number);
  42213. /**
  42214. * Gets the value of the `Back` button
  42215. */
  42216. get buttonBack(): number;
  42217. /**
  42218. * Sets the value of the `Back` button
  42219. */
  42220. set buttonBack(value: number);
  42221. /**
  42222. * Gets the value of the `Left` button
  42223. */
  42224. get buttonLB(): number;
  42225. /**
  42226. * Sets the value of the `Left` button
  42227. */
  42228. set buttonLB(value: number);
  42229. /**
  42230. * Gets the value of the `Right` button
  42231. */
  42232. get buttonRB(): number;
  42233. /**
  42234. * Sets the value of the `Right` button
  42235. */
  42236. set buttonRB(value: number);
  42237. /**
  42238. * Gets the value of the Left joystick
  42239. */
  42240. get buttonLeftStick(): number;
  42241. /**
  42242. * Sets the value of the Left joystick
  42243. */
  42244. set buttonLeftStick(value: number);
  42245. /**
  42246. * Gets the value of the Right joystick
  42247. */
  42248. get buttonRightStick(): number;
  42249. /**
  42250. * Sets the value of the Right joystick
  42251. */
  42252. set buttonRightStick(value: number);
  42253. /**
  42254. * Gets the value of D-pad up
  42255. */
  42256. get dPadUp(): number;
  42257. /**
  42258. * Sets the value of D-pad up
  42259. */
  42260. set dPadUp(value: number);
  42261. /**
  42262. * Gets the value of D-pad down
  42263. */
  42264. get dPadDown(): number;
  42265. /**
  42266. * Sets the value of D-pad down
  42267. */
  42268. set dPadDown(value: number);
  42269. /**
  42270. * Gets the value of D-pad left
  42271. */
  42272. get dPadLeft(): number;
  42273. /**
  42274. * Sets the value of D-pad left
  42275. */
  42276. set dPadLeft(value: number);
  42277. /**
  42278. * Gets the value of D-pad right
  42279. */
  42280. get dPadRight(): number;
  42281. /**
  42282. * Sets the value of D-pad right
  42283. */
  42284. set dPadRight(value: number);
  42285. /**
  42286. * Force the gamepad to synchronize with device values
  42287. */
  42288. update(): void;
  42289. /**
  42290. * Disposes the gamepad
  42291. */
  42292. dispose(): void;
  42293. }
  42294. }
  42295. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42296. import { Observable } from "babylonjs/Misc/observable";
  42297. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42298. /**
  42299. * Defines supported buttons for DualShock compatible gamepads
  42300. */
  42301. export enum DualShockButton {
  42302. /** Cross */
  42303. Cross = 0,
  42304. /** Circle */
  42305. Circle = 1,
  42306. /** Square */
  42307. Square = 2,
  42308. /** Triangle */
  42309. Triangle = 3,
  42310. /** Options */
  42311. Options = 4,
  42312. /** Share */
  42313. Share = 5,
  42314. /** L1 */
  42315. L1 = 6,
  42316. /** R1 */
  42317. R1 = 7,
  42318. /** Left stick */
  42319. LeftStick = 8,
  42320. /** Right stick */
  42321. RightStick = 9
  42322. }
  42323. /** Defines values for DualShock DPad */
  42324. export enum DualShockDpad {
  42325. /** Up */
  42326. Up = 0,
  42327. /** Down */
  42328. Down = 1,
  42329. /** Left */
  42330. Left = 2,
  42331. /** Right */
  42332. Right = 3
  42333. }
  42334. /**
  42335. * Defines a DualShock gamepad
  42336. */
  42337. export class DualShockPad extends Gamepad {
  42338. private _leftTrigger;
  42339. private _rightTrigger;
  42340. private _onlefttriggerchanged;
  42341. private _onrighttriggerchanged;
  42342. private _onbuttondown;
  42343. private _onbuttonup;
  42344. private _ondpaddown;
  42345. private _ondpadup;
  42346. /** Observable raised when a button is pressed */
  42347. onButtonDownObservable: Observable<DualShockButton>;
  42348. /** Observable raised when a button is released */
  42349. onButtonUpObservable: Observable<DualShockButton>;
  42350. /** Observable raised when a pad is pressed */
  42351. onPadDownObservable: Observable<DualShockDpad>;
  42352. /** Observable raised when a pad is released */
  42353. onPadUpObservable: Observable<DualShockDpad>;
  42354. private _buttonCross;
  42355. private _buttonCircle;
  42356. private _buttonSquare;
  42357. private _buttonTriangle;
  42358. private _buttonShare;
  42359. private _buttonOptions;
  42360. private _buttonL1;
  42361. private _buttonR1;
  42362. private _buttonLeftStick;
  42363. private _buttonRightStick;
  42364. private _dPadUp;
  42365. private _dPadDown;
  42366. private _dPadLeft;
  42367. private _dPadRight;
  42368. /**
  42369. * Creates a new DualShock gamepad object
  42370. * @param id defines the id of this gamepad
  42371. * @param index defines its index
  42372. * @param gamepad defines the internal HTML gamepad object
  42373. */
  42374. constructor(id: string, index: number, gamepad: any);
  42375. /**
  42376. * Defines the callback to call when left trigger is pressed
  42377. * @param callback defines the callback to use
  42378. */
  42379. onlefttriggerchanged(callback: (value: number) => void): void;
  42380. /**
  42381. * Defines the callback to call when right trigger is pressed
  42382. * @param callback defines the callback to use
  42383. */
  42384. onrighttriggerchanged(callback: (value: number) => void): void;
  42385. /**
  42386. * Gets the left trigger value
  42387. */
  42388. get leftTrigger(): number;
  42389. /**
  42390. * Sets the left trigger value
  42391. */
  42392. set leftTrigger(newValue: number);
  42393. /**
  42394. * Gets the right trigger value
  42395. */
  42396. get rightTrigger(): number;
  42397. /**
  42398. * Sets the right trigger value
  42399. */
  42400. set rightTrigger(newValue: number);
  42401. /**
  42402. * Defines the callback to call when a button is pressed
  42403. * @param callback defines the callback to use
  42404. */
  42405. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42406. /**
  42407. * Defines the callback to call when a button is released
  42408. * @param callback defines the callback to use
  42409. */
  42410. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42411. /**
  42412. * Defines the callback to call when a pad is pressed
  42413. * @param callback defines the callback to use
  42414. */
  42415. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42416. /**
  42417. * Defines the callback to call when a pad is released
  42418. * @param callback defines the callback to use
  42419. */
  42420. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42421. private _setButtonValue;
  42422. private _setDPadValue;
  42423. /**
  42424. * Gets the value of the `Cross` button
  42425. */
  42426. get buttonCross(): number;
  42427. /**
  42428. * Sets the value of the `Cross` button
  42429. */
  42430. set buttonCross(value: number);
  42431. /**
  42432. * Gets the value of the `Circle` button
  42433. */
  42434. get buttonCircle(): number;
  42435. /**
  42436. * Sets the value of the `Circle` button
  42437. */
  42438. set buttonCircle(value: number);
  42439. /**
  42440. * Gets the value of the `Square` button
  42441. */
  42442. get buttonSquare(): number;
  42443. /**
  42444. * Sets the value of the `Square` button
  42445. */
  42446. set buttonSquare(value: number);
  42447. /**
  42448. * Gets the value of the `Triangle` button
  42449. */
  42450. get buttonTriangle(): number;
  42451. /**
  42452. * Sets the value of the `Triangle` button
  42453. */
  42454. set buttonTriangle(value: number);
  42455. /**
  42456. * Gets the value of the `Options` button
  42457. */
  42458. get buttonOptions(): number;
  42459. /**
  42460. * Sets the value of the `Options` button
  42461. */
  42462. set buttonOptions(value: number);
  42463. /**
  42464. * Gets the value of the `Share` button
  42465. */
  42466. get buttonShare(): number;
  42467. /**
  42468. * Sets the value of the `Share` button
  42469. */
  42470. set buttonShare(value: number);
  42471. /**
  42472. * Gets the value of the `L1` button
  42473. */
  42474. get buttonL1(): number;
  42475. /**
  42476. * Sets the value of the `L1` button
  42477. */
  42478. set buttonL1(value: number);
  42479. /**
  42480. * Gets the value of the `R1` button
  42481. */
  42482. get buttonR1(): number;
  42483. /**
  42484. * Sets the value of the `R1` button
  42485. */
  42486. set buttonR1(value: number);
  42487. /**
  42488. * Gets the value of the Left joystick
  42489. */
  42490. get buttonLeftStick(): number;
  42491. /**
  42492. * Sets the value of the Left joystick
  42493. */
  42494. set buttonLeftStick(value: number);
  42495. /**
  42496. * Gets the value of the Right joystick
  42497. */
  42498. get buttonRightStick(): number;
  42499. /**
  42500. * Sets the value of the Right joystick
  42501. */
  42502. set buttonRightStick(value: number);
  42503. /**
  42504. * Gets the value of D-pad up
  42505. */
  42506. get dPadUp(): number;
  42507. /**
  42508. * Sets the value of D-pad up
  42509. */
  42510. set dPadUp(value: number);
  42511. /**
  42512. * Gets the value of D-pad down
  42513. */
  42514. get dPadDown(): number;
  42515. /**
  42516. * Sets the value of D-pad down
  42517. */
  42518. set dPadDown(value: number);
  42519. /**
  42520. * Gets the value of D-pad left
  42521. */
  42522. get dPadLeft(): number;
  42523. /**
  42524. * Sets the value of D-pad left
  42525. */
  42526. set dPadLeft(value: number);
  42527. /**
  42528. * Gets the value of D-pad right
  42529. */
  42530. get dPadRight(): number;
  42531. /**
  42532. * Sets the value of D-pad right
  42533. */
  42534. set dPadRight(value: number);
  42535. /**
  42536. * Force the gamepad to synchronize with device values
  42537. */
  42538. update(): void;
  42539. /**
  42540. * Disposes the gamepad
  42541. */
  42542. dispose(): void;
  42543. }
  42544. }
  42545. declare module "babylonjs/Gamepads/gamepadManager" {
  42546. import { Observable } from "babylonjs/Misc/observable";
  42547. import { Nullable } from "babylonjs/types";
  42548. import { Scene } from "babylonjs/scene";
  42549. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42550. /**
  42551. * Manager for handling gamepads
  42552. */
  42553. export class GamepadManager {
  42554. private _scene?;
  42555. private _babylonGamepads;
  42556. private _oneGamepadConnected;
  42557. /** @hidden */
  42558. _isMonitoring: boolean;
  42559. private _gamepadEventSupported;
  42560. private _gamepadSupport?;
  42561. /**
  42562. * observable to be triggered when the gamepad controller has been connected
  42563. */
  42564. onGamepadConnectedObservable: Observable<Gamepad>;
  42565. /**
  42566. * observable to be triggered when the gamepad controller has been disconnected
  42567. */
  42568. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42569. private _onGamepadConnectedEvent;
  42570. private _onGamepadDisconnectedEvent;
  42571. /**
  42572. * Initializes the gamepad manager
  42573. * @param _scene BabylonJS scene
  42574. */
  42575. constructor(_scene?: Scene | undefined);
  42576. /**
  42577. * The gamepads in the game pad manager
  42578. */
  42579. get gamepads(): Gamepad[];
  42580. /**
  42581. * Get the gamepad controllers based on type
  42582. * @param type The type of gamepad controller
  42583. * @returns Nullable gamepad
  42584. */
  42585. getGamepadByType(type?: number): Nullable<Gamepad>;
  42586. /**
  42587. * Disposes the gamepad manager
  42588. */
  42589. dispose(): void;
  42590. private _addNewGamepad;
  42591. private _startMonitoringGamepads;
  42592. private _stopMonitoringGamepads;
  42593. /** @hidden */
  42594. _checkGamepadsStatus(): void;
  42595. private _updateGamepadObjects;
  42596. }
  42597. }
  42598. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42599. import { Nullable } from "babylonjs/types";
  42600. import { Scene } from "babylonjs/scene";
  42601. import { ISceneComponent } from "babylonjs/sceneComponent";
  42602. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42603. module "babylonjs/scene" {
  42604. interface Scene {
  42605. /** @hidden */
  42606. _gamepadManager: Nullable<GamepadManager>;
  42607. /**
  42608. * Gets the gamepad manager associated with the scene
  42609. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42610. */
  42611. gamepadManager: GamepadManager;
  42612. }
  42613. }
  42614. module "babylonjs/Cameras/freeCameraInputsManager" {
  42615. /**
  42616. * Interface representing a free camera inputs manager
  42617. */
  42618. interface FreeCameraInputsManager {
  42619. /**
  42620. * Adds gamepad input support to the FreeCameraInputsManager.
  42621. * @returns the FreeCameraInputsManager
  42622. */
  42623. addGamepad(): FreeCameraInputsManager;
  42624. }
  42625. }
  42626. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42627. /**
  42628. * Interface representing an arc rotate camera inputs manager
  42629. */
  42630. interface ArcRotateCameraInputsManager {
  42631. /**
  42632. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42633. * @returns the camera inputs manager
  42634. */
  42635. addGamepad(): ArcRotateCameraInputsManager;
  42636. }
  42637. }
  42638. /**
  42639. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42640. */
  42641. export class GamepadSystemSceneComponent implements ISceneComponent {
  42642. /**
  42643. * The component name helpfull to identify the component in the list of scene components.
  42644. */
  42645. readonly name: string;
  42646. /**
  42647. * The scene the component belongs to.
  42648. */
  42649. scene: Scene;
  42650. /**
  42651. * Creates a new instance of the component for the given scene
  42652. * @param scene Defines the scene to register the component in
  42653. */
  42654. constructor(scene: Scene);
  42655. /**
  42656. * Registers the component in a given scene
  42657. */
  42658. register(): void;
  42659. /**
  42660. * Rebuilds the elements related to this component in case of
  42661. * context lost for instance.
  42662. */
  42663. rebuild(): void;
  42664. /**
  42665. * Disposes the component and the associated ressources
  42666. */
  42667. dispose(): void;
  42668. private _beforeCameraUpdate;
  42669. }
  42670. }
  42671. declare module "babylonjs/Cameras/universalCamera" {
  42672. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42673. import { Scene } from "babylonjs/scene";
  42674. import { Vector3 } from "babylonjs/Maths/math.vector";
  42675. import "babylonjs/Gamepads/gamepadSceneComponent";
  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. */
  42681. export class UniversalCamera extends TouchCamera {
  42682. /**
  42683. * Defines the gamepad rotation sensiblity.
  42684. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42685. */
  42686. get gamepadAngularSensibility(): number;
  42687. set gamepadAngularSensibility(value: number);
  42688. /**
  42689. * Defines the gamepad move sensiblity.
  42690. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42691. */
  42692. get gamepadMoveSensibility(): number;
  42693. set gamepadMoveSensibility(value: number);
  42694. /**
  42695. * 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,
  42696. * which still works and will still be found in many Playgrounds.
  42697. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42698. * @param name Define the name of the camera in the scene
  42699. * @param position Define the start position of the camera in the scene
  42700. * @param scene Define the scene the camera belongs to
  42701. */
  42702. constructor(name: string, position: Vector3, scene: Scene);
  42703. /**
  42704. * Gets the current object class name.
  42705. * @return the class name
  42706. */
  42707. getClassName(): string;
  42708. }
  42709. }
  42710. declare module "babylonjs/Cameras/gamepadCamera" {
  42711. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42712. import { Scene } from "babylonjs/scene";
  42713. import { Vector3 } from "babylonjs/Maths/math.vector";
  42714. /**
  42715. * This represents a FPS type of camera. This is only here for back compat purpose.
  42716. * Please use the UniversalCamera instead as both are identical.
  42717. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42718. */
  42719. export class GamepadCamera extends UniversalCamera {
  42720. /**
  42721. * Instantiates a new Gamepad Camera
  42722. * This represents a FPS type of camera. This is only here for back compat purpose.
  42723. * Please use the UniversalCamera instead as both are identical.
  42724. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42725. * @param name Define the name of the camera in the scene
  42726. * @param position Define the start position of the camera in the scene
  42727. * @param scene Define the scene the camera belongs to
  42728. */
  42729. constructor(name: string, position: Vector3, scene: Scene);
  42730. /**
  42731. * Gets the current object class name.
  42732. * @return the class name
  42733. */
  42734. getClassName(): string;
  42735. }
  42736. }
  42737. declare module "babylonjs/Shaders/pass.fragment" {
  42738. /** @hidden */
  42739. export var passPixelShader: {
  42740. name: string;
  42741. shader: string;
  42742. };
  42743. }
  42744. declare module "babylonjs/Shaders/passCube.fragment" {
  42745. /** @hidden */
  42746. export var passCubePixelShader: {
  42747. name: string;
  42748. shader: string;
  42749. };
  42750. }
  42751. declare module "babylonjs/PostProcesses/passPostProcess" {
  42752. import { Nullable } from "babylonjs/types";
  42753. import { Camera } from "babylonjs/Cameras/camera";
  42754. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42755. import { Engine } from "babylonjs/Engines/engine";
  42756. import "babylonjs/Shaders/pass.fragment";
  42757. import "babylonjs/Shaders/passCube.fragment";
  42758. /**
  42759. * PassPostProcess which produces an output the same as it's input
  42760. */
  42761. export class PassPostProcess extends PostProcess {
  42762. /**
  42763. * Creates the PassPostProcess
  42764. * @param name The name of the effect.
  42765. * @param options The required width/height ratio to downsize to before computing the render pass.
  42766. * @param camera The camera to apply the render pass to.
  42767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42768. * @param engine The engine which the post process will be applied. (default: current engine)
  42769. * @param reusable If the post process can be reused on the same frame. (default: false)
  42770. * @param textureType The type of texture to be used when performing the post processing.
  42771. * @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)
  42772. */
  42773. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42774. }
  42775. /**
  42776. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42777. */
  42778. export class PassCubePostProcess extends PostProcess {
  42779. private _face;
  42780. /**
  42781. * Gets or sets the cube face to display.
  42782. * * 0 is +X
  42783. * * 1 is -X
  42784. * * 2 is +Y
  42785. * * 3 is -Y
  42786. * * 4 is +Z
  42787. * * 5 is -Z
  42788. */
  42789. get face(): number;
  42790. set face(value: number);
  42791. /**
  42792. * Creates the PassCubePostProcess
  42793. * @param name The name of the effect.
  42794. * @param options The required width/height ratio to downsize to before computing the render pass.
  42795. * @param camera The camera to apply the render pass to.
  42796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42797. * @param engine The engine which the post process will be applied. (default: current engine)
  42798. * @param reusable If the post process can be reused on the same frame. (default: false)
  42799. * @param textureType The type of texture to be used when performing the post processing.
  42800. * @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)
  42801. */
  42802. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42803. }
  42804. }
  42805. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42806. /** @hidden */
  42807. export var anaglyphPixelShader: {
  42808. name: string;
  42809. shader: string;
  42810. };
  42811. }
  42812. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42813. import { Engine } from "babylonjs/Engines/engine";
  42814. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42815. import { Camera } from "babylonjs/Cameras/camera";
  42816. import "babylonjs/Shaders/anaglyph.fragment";
  42817. /**
  42818. * Postprocess used to generate anaglyphic rendering
  42819. */
  42820. export class AnaglyphPostProcess extends PostProcess {
  42821. private _passedProcess;
  42822. /**
  42823. * Creates a new AnaglyphPostProcess
  42824. * @param name defines postprocess name
  42825. * @param options defines creation options or target ratio scale
  42826. * @param rigCameras defines cameras using this postprocess
  42827. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42828. * @param engine defines hosting engine
  42829. * @param reusable defines if the postprocess will be reused multiple times per frame
  42830. */
  42831. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42832. }
  42833. }
  42834. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42835. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42836. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42837. import { Scene } from "babylonjs/scene";
  42838. import { Vector3 } from "babylonjs/Maths/math.vector";
  42839. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42840. /**
  42841. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42842. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42843. */
  42844. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42845. /**
  42846. * Creates a new AnaglyphArcRotateCamera
  42847. * @param name defines camera name
  42848. * @param alpha defines alpha angle (in radians)
  42849. * @param beta defines beta angle (in radians)
  42850. * @param radius defines radius
  42851. * @param target defines camera target
  42852. * @param interaxialDistance defines distance between each color axis
  42853. * @param scene defines the hosting scene
  42854. */
  42855. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42856. /**
  42857. * Gets camera class name
  42858. * @returns AnaglyphArcRotateCamera
  42859. */
  42860. getClassName(): string;
  42861. }
  42862. }
  42863. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42864. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42865. import { Scene } from "babylonjs/scene";
  42866. import { Vector3 } from "babylonjs/Maths/math.vector";
  42867. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42868. /**
  42869. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42870. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42871. */
  42872. export class AnaglyphFreeCamera extends FreeCamera {
  42873. /**
  42874. * Creates a new AnaglyphFreeCamera
  42875. * @param name defines camera name
  42876. * @param position defines initial position
  42877. * @param interaxialDistance defines distance between each color axis
  42878. * @param scene defines the hosting scene
  42879. */
  42880. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42881. /**
  42882. * Gets camera class name
  42883. * @returns AnaglyphFreeCamera
  42884. */
  42885. getClassName(): string;
  42886. }
  42887. }
  42888. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42889. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42890. import { Scene } from "babylonjs/scene";
  42891. import { Vector3 } from "babylonjs/Maths/math.vector";
  42892. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42893. /**
  42894. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42895. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42896. */
  42897. export class AnaglyphGamepadCamera extends GamepadCamera {
  42898. /**
  42899. * Creates a new AnaglyphGamepadCamera
  42900. * @param name defines camera name
  42901. * @param position defines initial position
  42902. * @param interaxialDistance defines distance between each color axis
  42903. * @param scene defines the hosting scene
  42904. */
  42905. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42906. /**
  42907. * Gets camera class name
  42908. * @returns AnaglyphGamepadCamera
  42909. */
  42910. getClassName(): string;
  42911. }
  42912. }
  42913. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42914. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42915. import { Scene } from "babylonjs/scene";
  42916. import { Vector3 } from "babylonjs/Maths/math.vector";
  42917. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42918. /**
  42919. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42920. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42921. */
  42922. export class AnaglyphUniversalCamera extends UniversalCamera {
  42923. /**
  42924. * Creates a new AnaglyphUniversalCamera
  42925. * @param name defines camera name
  42926. * @param position defines initial position
  42927. * @param interaxialDistance defines distance between each color axis
  42928. * @param scene defines the hosting scene
  42929. */
  42930. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42931. /**
  42932. * Gets camera class name
  42933. * @returns AnaglyphUniversalCamera
  42934. */
  42935. getClassName(): string;
  42936. }
  42937. }
  42938. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42939. /** @hidden */
  42940. export var stereoscopicInterlacePixelShader: {
  42941. name: string;
  42942. shader: string;
  42943. };
  42944. }
  42945. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42946. import { Camera } from "babylonjs/Cameras/camera";
  42947. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42948. import { Engine } from "babylonjs/Engines/engine";
  42949. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42950. /**
  42951. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42952. */
  42953. export class StereoscopicInterlacePostProcess extends PostProcess {
  42954. private _stepSize;
  42955. private _passedProcess;
  42956. /**
  42957. * Initializes a StereoscopicInterlacePostProcess
  42958. * @param name The name of the effect.
  42959. * @param rigCameras The rig cameras to be appled to the post process
  42960. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42962. * @param engine The engine which the post process will be applied. (default: current engine)
  42963. * @param reusable If the post process can be reused on the same frame. (default: false)
  42964. */
  42965. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42966. }
  42967. }
  42968. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42969. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42970. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42971. import { Scene } from "babylonjs/scene";
  42972. import { Vector3 } from "babylonjs/Maths/math.vector";
  42973. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42974. /**
  42975. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42976. * @see http://doc.babylonjs.com/features/cameras
  42977. */
  42978. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42979. /**
  42980. * Creates a new StereoscopicArcRotateCamera
  42981. * @param name defines camera name
  42982. * @param alpha defines alpha angle (in radians)
  42983. * @param beta defines beta angle (in radians)
  42984. * @param radius defines radius
  42985. * @param target defines camera target
  42986. * @param interaxialDistance defines distance between each color axis
  42987. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42988. * @param scene defines the hosting scene
  42989. */
  42990. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42991. /**
  42992. * Gets camera class name
  42993. * @returns StereoscopicArcRotateCamera
  42994. */
  42995. getClassName(): string;
  42996. }
  42997. }
  42998. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42999. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43000. import { Scene } from "babylonjs/scene";
  43001. import { Vector3 } from "babylonjs/Maths/math.vector";
  43002. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43003. /**
  43004. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43005. * @see http://doc.babylonjs.com/features/cameras
  43006. */
  43007. export class StereoscopicFreeCamera extends FreeCamera {
  43008. /**
  43009. * Creates a new StereoscopicFreeCamera
  43010. * @param name defines camera name
  43011. * @param position defines initial position
  43012. * @param interaxialDistance defines distance between each color axis
  43013. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43014. * @param scene defines the hosting scene
  43015. */
  43016. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43017. /**
  43018. * Gets camera class name
  43019. * @returns StereoscopicFreeCamera
  43020. */
  43021. getClassName(): string;
  43022. }
  43023. }
  43024. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43025. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43026. import { Scene } from "babylonjs/scene";
  43027. import { Vector3 } from "babylonjs/Maths/math.vector";
  43028. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43029. /**
  43030. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43031. * @see http://doc.babylonjs.com/features/cameras
  43032. */
  43033. export class StereoscopicGamepadCamera extends GamepadCamera {
  43034. /**
  43035. * Creates a new StereoscopicGamepadCamera
  43036. * @param name defines camera name
  43037. * @param position defines initial position
  43038. * @param interaxialDistance defines distance between each color axis
  43039. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43040. * @param scene defines the hosting scene
  43041. */
  43042. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43043. /**
  43044. * Gets camera class name
  43045. * @returns StereoscopicGamepadCamera
  43046. */
  43047. getClassName(): string;
  43048. }
  43049. }
  43050. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43051. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43052. import { Scene } from "babylonjs/scene";
  43053. import { Vector3 } from "babylonjs/Maths/math.vector";
  43054. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43055. /**
  43056. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43057. * @see http://doc.babylonjs.com/features/cameras
  43058. */
  43059. export class StereoscopicUniversalCamera extends UniversalCamera {
  43060. /**
  43061. * Creates a new StereoscopicUniversalCamera
  43062. * @param name defines camera name
  43063. * @param position defines initial position
  43064. * @param interaxialDistance defines distance between each color axis
  43065. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43066. * @param scene defines the hosting scene
  43067. */
  43068. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43069. /**
  43070. * Gets camera class name
  43071. * @returns StereoscopicUniversalCamera
  43072. */
  43073. getClassName(): string;
  43074. }
  43075. }
  43076. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43077. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43078. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43079. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43080. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43081. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43082. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43083. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43084. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43085. }
  43086. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43087. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43088. import { Scene } from "babylonjs/scene";
  43089. import { Vector3 } from "babylonjs/Maths/math.vector";
  43090. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43091. /**
  43092. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43093. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43094. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43095. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43096. */
  43097. export class VirtualJoysticksCamera extends FreeCamera {
  43098. /**
  43099. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43100. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43101. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43102. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43103. * @param name Define the name of the camera in the scene
  43104. * @param position Define the start position of the camera in the scene
  43105. * @param scene Define the scene the camera belongs to
  43106. */
  43107. constructor(name: string, position: Vector3, scene: Scene);
  43108. /**
  43109. * Gets the current object class name.
  43110. * @return the class name
  43111. */
  43112. getClassName(): string;
  43113. }
  43114. }
  43115. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43116. import { Matrix } from "babylonjs/Maths/math.vector";
  43117. /**
  43118. * This represents all the required metrics to create a VR camera.
  43119. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43120. */
  43121. export class VRCameraMetrics {
  43122. /**
  43123. * Define the horizontal resolution off the screen.
  43124. */
  43125. hResolution: number;
  43126. /**
  43127. * Define the vertical resolution off the screen.
  43128. */
  43129. vResolution: number;
  43130. /**
  43131. * Define the horizontal screen size.
  43132. */
  43133. hScreenSize: number;
  43134. /**
  43135. * Define the vertical screen size.
  43136. */
  43137. vScreenSize: number;
  43138. /**
  43139. * Define the vertical screen center position.
  43140. */
  43141. vScreenCenter: number;
  43142. /**
  43143. * Define the distance of the eyes to the screen.
  43144. */
  43145. eyeToScreenDistance: number;
  43146. /**
  43147. * Define the distance between both lenses
  43148. */
  43149. lensSeparationDistance: number;
  43150. /**
  43151. * Define the distance between both viewer's eyes.
  43152. */
  43153. interpupillaryDistance: number;
  43154. /**
  43155. * Define the distortion factor of the VR postprocess.
  43156. * Please, touch with care.
  43157. */
  43158. distortionK: number[];
  43159. /**
  43160. * Define the chromatic aberration correction factors for the VR post process.
  43161. */
  43162. chromaAbCorrection: number[];
  43163. /**
  43164. * Define the scale factor of the post process.
  43165. * The smaller the better but the slower.
  43166. */
  43167. postProcessScaleFactor: number;
  43168. /**
  43169. * Define an offset for the lens center.
  43170. */
  43171. lensCenterOffset: number;
  43172. /**
  43173. * Define if the current vr camera should compensate the distortion of the lense or not.
  43174. */
  43175. compensateDistortion: boolean;
  43176. /**
  43177. * Defines if multiview should be enabled when rendering (Default: false)
  43178. */
  43179. multiviewEnabled: boolean;
  43180. /**
  43181. * Gets the rendering aspect ratio based on the provided resolutions.
  43182. */
  43183. get aspectRatio(): number;
  43184. /**
  43185. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43186. */
  43187. get aspectRatioFov(): number;
  43188. /**
  43189. * @hidden
  43190. */
  43191. get leftHMatrix(): Matrix;
  43192. /**
  43193. * @hidden
  43194. */
  43195. get rightHMatrix(): Matrix;
  43196. /**
  43197. * @hidden
  43198. */
  43199. get leftPreViewMatrix(): Matrix;
  43200. /**
  43201. * @hidden
  43202. */
  43203. get rightPreViewMatrix(): Matrix;
  43204. /**
  43205. * Get the default VRMetrics based on the most generic setup.
  43206. * @returns the default vr metrics
  43207. */
  43208. static GetDefault(): VRCameraMetrics;
  43209. }
  43210. }
  43211. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43212. /** @hidden */
  43213. export var vrDistortionCorrectionPixelShader: {
  43214. name: string;
  43215. shader: string;
  43216. };
  43217. }
  43218. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43219. import { Camera } from "babylonjs/Cameras/camera";
  43220. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43221. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43222. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43223. /**
  43224. * VRDistortionCorrectionPostProcess used for mobile VR
  43225. */
  43226. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43227. private _isRightEye;
  43228. private _distortionFactors;
  43229. private _postProcessScaleFactor;
  43230. private _lensCenterOffset;
  43231. private _scaleIn;
  43232. private _scaleFactor;
  43233. private _lensCenter;
  43234. /**
  43235. * Initializes the VRDistortionCorrectionPostProcess
  43236. * @param name The name of the effect.
  43237. * @param camera The camera to apply the render pass to.
  43238. * @param isRightEye If this is for the right eye distortion
  43239. * @param vrMetrics All the required metrics for the VR camera
  43240. */
  43241. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43242. }
  43243. }
  43244. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43245. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43246. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43247. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43248. import { Scene } from "babylonjs/scene";
  43249. import { Vector3 } from "babylonjs/Maths/math.vector";
  43250. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43251. import "babylonjs/Cameras/RigModes/vrRigMode";
  43252. /**
  43253. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43254. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43255. */
  43256. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43257. /**
  43258. * Creates a new VRDeviceOrientationArcRotateCamera
  43259. * @param name defines camera name
  43260. * @param alpha defines the camera rotation along the logitudinal axis
  43261. * @param beta defines the camera rotation along the latitudinal axis
  43262. * @param radius defines the camera distance from its target
  43263. * @param target defines the camera target
  43264. * @param scene defines the scene the camera belongs to
  43265. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43266. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43267. */
  43268. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43269. /**
  43270. * Gets camera class name
  43271. * @returns VRDeviceOrientationArcRotateCamera
  43272. */
  43273. getClassName(): string;
  43274. }
  43275. }
  43276. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43277. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43278. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43279. import { Scene } from "babylonjs/scene";
  43280. import { Vector3 } from "babylonjs/Maths/math.vector";
  43281. import "babylonjs/Cameras/RigModes/vrRigMode";
  43282. /**
  43283. * Camera used to simulate VR rendering (based on FreeCamera)
  43284. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43285. */
  43286. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43287. /**
  43288. * Creates a new VRDeviceOrientationFreeCamera
  43289. * @param name defines camera name
  43290. * @param position defines the start position of the camera
  43291. * @param scene defines the scene the camera belongs to
  43292. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43293. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43294. */
  43295. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43296. /**
  43297. * Gets camera class name
  43298. * @returns VRDeviceOrientationFreeCamera
  43299. */
  43300. getClassName(): string;
  43301. }
  43302. }
  43303. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43304. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43305. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43306. import { Scene } from "babylonjs/scene";
  43307. import { Vector3 } from "babylonjs/Maths/math.vector";
  43308. import "babylonjs/Gamepads/gamepadSceneComponent";
  43309. /**
  43310. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43311. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43312. */
  43313. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43314. /**
  43315. * Creates a new VRDeviceOrientationGamepadCamera
  43316. * @param name defines camera name
  43317. * @param position defines the start position of the camera
  43318. * @param scene defines the scene the camera belongs to
  43319. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43320. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43321. */
  43322. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43323. /**
  43324. * Gets camera class name
  43325. * @returns VRDeviceOrientationGamepadCamera
  43326. */
  43327. getClassName(): string;
  43328. }
  43329. }
  43330. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43331. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43333. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43334. /** @hidden */
  43335. export var imageProcessingPixelShader: {
  43336. name: string;
  43337. shader: string;
  43338. };
  43339. }
  43340. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43341. import { Nullable } from "babylonjs/types";
  43342. import { Color4 } from "babylonjs/Maths/math.color";
  43343. import { Camera } from "babylonjs/Cameras/camera";
  43344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43345. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43346. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43347. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43348. import { Engine } from "babylonjs/Engines/engine";
  43349. import "babylonjs/Shaders/imageProcessing.fragment";
  43350. import "babylonjs/Shaders/postprocess.vertex";
  43351. /**
  43352. * ImageProcessingPostProcess
  43353. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43354. */
  43355. export class ImageProcessingPostProcess extends PostProcess {
  43356. /**
  43357. * Default configuration related to image processing available in the PBR Material.
  43358. */
  43359. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43360. /**
  43361. * Gets the image processing configuration used either in this material.
  43362. */
  43363. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43364. /**
  43365. * Sets the Default image processing configuration used either in the this material.
  43366. *
  43367. * If sets to null, the scene one is in use.
  43368. */
  43369. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43370. /**
  43371. * Keep track of the image processing observer to allow dispose and replace.
  43372. */
  43373. private _imageProcessingObserver;
  43374. /**
  43375. * Attaches a new image processing configuration to the PBR Material.
  43376. * @param configuration
  43377. */
  43378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43379. /**
  43380. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43381. */
  43382. get colorCurves(): Nullable<ColorCurves>;
  43383. /**
  43384. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43385. */
  43386. set colorCurves(value: Nullable<ColorCurves>);
  43387. /**
  43388. * Gets wether the color curves effect is enabled.
  43389. */
  43390. get colorCurvesEnabled(): boolean;
  43391. /**
  43392. * Sets wether the color curves effect is enabled.
  43393. */
  43394. set colorCurvesEnabled(value: boolean);
  43395. /**
  43396. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43397. */
  43398. get colorGradingTexture(): Nullable<BaseTexture>;
  43399. /**
  43400. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43401. */
  43402. set colorGradingTexture(value: Nullable<BaseTexture>);
  43403. /**
  43404. * Gets wether the color grading effect is enabled.
  43405. */
  43406. get colorGradingEnabled(): boolean;
  43407. /**
  43408. * Gets wether the color grading effect is enabled.
  43409. */
  43410. set colorGradingEnabled(value: boolean);
  43411. /**
  43412. * Gets exposure used in the effect.
  43413. */
  43414. get exposure(): number;
  43415. /**
  43416. * Sets exposure used in the effect.
  43417. */
  43418. set exposure(value: number);
  43419. /**
  43420. * Gets wether tonemapping is enabled or not.
  43421. */
  43422. get toneMappingEnabled(): boolean;
  43423. /**
  43424. * Sets wether tonemapping is enabled or not
  43425. */
  43426. set toneMappingEnabled(value: boolean);
  43427. /**
  43428. * Gets the type of tone mapping effect.
  43429. */
  43430. get toneMappingType(): number;
  43431. /**
  43432. * Sets the type of tone mapping effect.
  43433. */
  43434. set toneMappingType(value: number);
  43435. /**
  43436. * Gets contrast used in the effect.
  43437. */
  43438. get contrast(): number;
  43439. /**
  43440. * Sets contrast used in the effect.
  43441. */
  43442. set contrast(value: number);
  43443. /**
  43444. * Gets Vignette stretch size.
  43445. */
  43446. get vignetteStretch(): number;
  43447. /**
  43448. * Sets Vignette stretch size.
  43449. */
  43450. set vignetteStretch(value: number);
  43451. /**
  43452. * Gets Vignette centre X Offset.
  43453. */
  43454. get vignetteCentreX(): number;
  43455. /**
  43456. * Sets Vignette centre X Offset.
  43457. */
  43458. set vignetteCentreX(value: number);
  43459. /**
  43460. * Gets Vignette centre Y Offset.
  43461. */
  43462. get vignetteCentreY(): number;
  43463. /**
  43464. * Sets Vignette centre Y Offset.
  43465. */
  43466. set vignetteCentreY(value: number);
  43467. /**
  43468. * Gets Vignette weight or intensity of the vignette effect.
  43469. */
  43470. get vignetteWeight(): number;
  43471. /**
  43472. * Sets Vignette weight or intensity of the vignette effect.
  43473. */
  43474. set vignetteWeight(value: number);
  43475. /**
  43476. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43477. * if vignetteEnabled is set to true.
  43478. */
  43479. get vignetteColor(): Color4;
  43480. /**
  43481. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43482. * if vignetteEnabled is set to true.
  43483. */
  43484. set vignetteColor(value: Color4);
  43485. /**
  43486. * Gets Camera field of view used by the Vignette effect.
  43487. */
  43488. get vignetteCameraFov(): number;
  43489. /**
  43490. * Sets Camera field of view used by the Vignette effect.
  43491. */
  43492. set vignetteCameraFov(value: number);
  43493. /**
  43494. * Gets the vignette blend mode allowing different kind of effect.
  43495. */
  43496. get vignetteBlendMode(): number;
  43497. /**
  43498. * Sets the vignette blend mode allowing different kind of effect.
  43499. */
  43500. set vignetteBlendMode(value: number);
  43501. /**
  43502. * Gets wether the vignette effect is enabled.
  43503. */
  43504. get vignetteEnabled(): boolean;
  43505. /**
  43506. * Sets wether the vignette effect is enabled.
  43507. */
  43508. set vignetteEnabled(value: boolean);
  43509. private _fromLinearSpace;
  43510. /**
  43511. * Gets wether the input of the processing is in Gamma or Linear Space.
  43512. */
  43513. get fromLinearSpace(): boolean;
  43514. /**
  43515. * Sets wether the input of the processing is in Gamma or Linear Space.
  43516. */
  43517. set fromLinearSpace(value: boolean);
  43518. /**
  43519. * Defines cache preventing GC.
  43520. */
  43521. private _defines;
  43522. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43523. /**
  43524. * "ImageProcessingPostProcess"
  43525. * @returns "ImageProcessingPostProcess"
  43526. */
  43527. getClassName(): string;
  43528. protected _updateParameters(): void;
  43529. dispose(camera?: Camera): void;
  43530. }
  43531. }
  43532. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43533. import { Scene } from "babylonjs/scene";
  43534. import { Color3 } from "babylonjs/Maths/math.color";
  43535. import { Mesh } from "babylonjs/Meshes/mesh";
  43536. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43537. import { Nullable } from "babylonjs/types";
  43538. /**
  43539. * Class containing static functions to help procedurally build meshes
  43540. */
  43541. export class GroundBuilder {
  43542. /**
  43543. * Creates a ground mesh
  43544. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43545. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43547. * @param name defines the name of the mesh
  43548. * @param options defines the options used to create the mesh
  43549. * @param scene defines the hosting scene
  43550. * @returns the ground mesh
  43551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43552. */
  43553. static CreateGround(name: string, options: {
  43554. width?: number;
  43555. height?: number;
  43556. subdivisions?: number;
  43557. subdivisionsX?: number;
  43558. subdivisionsY?: number;
  43559. updatable?: boolean;
  43560. }, scene: any): Mesh;
  43561. /**
  43562. * Creates a tiled ground mesh
  43563. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43564. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43565. * * 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
  43566. * * 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
  43567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43568. * @param name defines the name of the mesh
  43569. * @param options defines the options used to create the mesh
  43570. * @param scene defines the hosting scene
  43571. * @returns the tiled ground mesh
  43572. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43573. */
  43574. static CreateTiledGround(name: string, options: {
  43575. xmin: number;
  43576. zmin: number;
  43577. xmax: number;
  43578. zmax: number;
  43579. subdivisions?: {
  43580. w: number;
  43581. h: number;
  43582. };
  43583. precision?: {
  43584. w: number;
  43585. h: number;
  43586. };
  43587. updatable?: boolean;
  43588. }, scene?: Nullable<Scene>): Mesh;
  43589. /**
  43590. * Creates a ground mesh from a height map
  43591. * * The parameter `url` sets the URL of the height map image resource.
  43592. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43593. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43594. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43595. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43596. * * 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.
  43597. * * 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).
  43598. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43600. * @param name defines the name of the mesh
  43601. * @param url defines the url to the height map
  43602. * @param options defines the options used to create the mesh
  43603. * @param scene defines the hosting scene
  43604. * @returns the ground mesh
  43605. * @see https://doc.babylonjs.com/babylon101/height_map
  43606. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43607. */
  43608. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43609. width?: number;
  43610. height?: number;
  43611. subdivisions?: number;
  43612. minHeight?: number;
  43613. maxHeight?: number;
  43614. colorFilter?: Color3;
  43615. alphaFilter?: number;
  43616. updatable?: boolean;
  43617. onReady?: (mesh: GroundMesh) => void;
  43618. }, scene?: Nullable<Scene>): GroundMesh;
  43619. }
  43620. }
  43621. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43622. import { Vector4 } from "babylonjs/Maths/math.vector";
  43623. import { Mesh } from "babylonjs/Meshes/mesh";
  43624. /**
  43625. * Class containing static functions to help procedurally build meshes
  43626. */
  43627. export class TorusBuilder {
  43628. /**
  43629. * Creates a torus mesh
  43630. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43631. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43632. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43634. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43636. * @param name defines the name of the mesh
  43637. * @param options defines the options used to create the mesh
  43638. * @param scene defines the hosting scene
  43639. * @returns the torus mesh
  43640. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43641. */
  43642. static CreateTorus(name: string, options: {
  43643. diameter?: number;
  43644. thickness?: number;
  43645. tessellation?: number;
  43646. updatable?: boolean;
  43647. sideOrientation?: number;
  43648. frontUVs?: Vector4;
  43649. backUVs?: Vector4;
  43650. }, scene: any): Mesh;
  43651. }
  43652. }
  43653. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43654. import { Vector4 } from "babylonjs/Maths/math.vector";
  43655. import { Color4 } from "babylonjs/Maths/math.color";
  43656. import { Mesh } from "babylonjs/Meshes/mesh";
  43657. /**
  43658. * Class containing static functions to help procedurally build meshes
  43659. */
  43660. export class CylinderBuilder {
  43661. /**
  43662. * Creates a cylinder or a cone mesh
  43663. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43664. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43665. * * 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.
  43666. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43667. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43668. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43669. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43670. * * 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).
  43671. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43672. * * 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).
  43673. * * 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
  43674. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43675. * * 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
  43676. * * 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.
  43677. * * If `enclose` is false, a ring surface is one element.
  43678. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43679. * * 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
  43680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43683. * @param name defines the name of the mesh
  43684. * @param options defines the options used to create the mesh
  43685. * @param scene defines the hosting scene
  43686. * @returns the cylinder mesh
  43687. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43688. */
  43689. static CreateCylinder(name: string, options: {
  43690. height?: number;
  43691. diameterTop?: number;
  43692. diameterBottom?: number;
  43693. diameter?: number;
  43694. tessellation?: number;
  43695. subdivisions?: number;
  43696. arc?: number;
  43697. faceColors?: Color4[];
  43698. faceUV?: Vector4[];
  43699. updatable?: boolean;
  43700. hasRings?: boolean;
  43701. enclose?: boolean;
  43702. cap?: number;
  43703. sideOrientation?: number;
  43704. frontUVs?: Vector4;
  43705. backUVs?: Vector4;
  43706. }, scene: any): Mesh;
  43707. }
  43708. }
  43709. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43710. import { Nullable } from "babylonjs/types";
  43711. import { IDisposable } from "babylonjs/scene";
  43712. /**
  43713. * States of the webXR experience
  43714. */
  43715. export enum WebXRState {
  43716. /**
  43717. * Transitioning to being in XR mode
  43718. */
  43719. ENTERING_XR = 0,
  43720. /**
  43721. * Transitioning to non XR mode
  43722. */
  43723. EXITING_XR = 1,
  43724. /**
  43725. * In XR mode and presenting
  43726. */
  43727. IN_XR = 2,
  43728. /**
  43729. * Not entered XR mode
  43730. */
  43731. NOT_IN_XR = 3
  43732. }
  43733. /**
  43734. * Abstraction of the XR render target
  43735. */
  43736. export interface WebXRRenderTarget extends IDisposable {
  43737. /**
  43738. * xrpresent context of the canvas which can be used to display/mirror xr content
  43739. */
  43740. canvasContext: WebGLRenderingContext;
  43741. /**
  43742. * xr layer for the canvas
  43743. */
  43744. xrLayer: Nullable<XRWebGLLayer>;
  43745. /**
  43746. * Initializes the xr layer for the session
  43747. * @param xrSession xr session
  43748. * @returns a promise that will resolve once the XR Layer has been created
  43749. */
  43750. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43751. }
  43752. }
  43753. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43754. import { Nullable } from "babylonjs/types";
  43755. import { Observable } from "babylonjs/Misc/observable";
  43756. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43757. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43758. /**
  43759. * COnfiguration object for WebXR output canvas
  43760. */
  43761. export class WebXRManagedOutputCanvasOptions {
  43762. /**
  43763. * Options for this XR Layer output
  43764. */
  43765. canvasOptions: XRWebGLLayerOptions;
  43766. /**
  43767. * CSS styling for a newly created canvas (if not provided)
  43768. */
  43769. newCanvasCssStyle?: string;
  43770. /**
  43771. * Get the default values of the configuration object
  43772. * @returns default values of this configuration object
  43773. */
  43774. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43775. }
  43776. /**
  43777. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43778. */
  43779. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43780. private configuration;
  43781. private _engine;
  43782. private _canvas;
  43783. /**
  43784. * xrpresent context of the canvas which can be used to display/mirror xr content
  43785. */
  43786. canvasContext: WebGLRenderingContext;
  43787. /**
  43788. * xr layer for the canvas
  43789. */
  43790. xrLayer: Nullable<XRWebGLLayer>;
  43791. /**
  43792. * Initializes the xr layer for the session
  43793. * @param xrSession xr session
  43794. * @returns a promise that will resolve once the XR Layer has been created
  43795. */
  43796. initializeXRLayerAsync(xrSession: any): any;
  43797. /**
  43798. * Initializes the canvas to be added/removed upon entering/exiting xr
  43799. * @param engine the Babylon engine
  43800. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43801. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43802. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43803. */
  43804. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43805. /**
  43806. * Disposes of the object
  43807. */
  43808. dispose(): void;
  43809. private _setManagedOutputCanvas;
  43810. private _addCanvas;
  43811. private _removeCanvas;
  43812. }
  43813. }
  43814. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43815. import { Observable } from "babylonjs/Misc/observable";
  43816. import { Nullable } from "babylonjs/types";
  43817. import { IDisposable, Scene } from "babylonjs/scene";
  43818. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43819. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43820. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43821. /**
  43822. * Manages an XRSession to work with Babylon's engine
  43823. * @see https://doc.babylonjs.com/how_to/webxr
  43824. */
  43825. export class WebXRSessionManager implements IDisposable {
  43826. /** The scene which the session should be created for */
  43827. scene: Scene;
  43828. /**
  43829. * Fires every time a new xrFrame arrives which can be used to update the camera
  43830. */
  43831. onXRFrameObservable: Observable<XRFrame>;
  43832. /**
  43833. * Fires when the xr session is ended either by the device or manually done
  43834. */
  43835. onXRSessionEnded: Observable<any>;
  43836. /**
  43837. * Fires when the xr session is ended either by the device or manually done
  43838. */
  43839. onXRSessionInit: Observable<XRSession>;
  43840. /**
  43841. * Underlying xr session
  43842. */
  43843. session: XRSession;
  43844. /**
  43845. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43846. * or get the offset the player is currently at.
  43847. */
  43848. viewerReferenceSpace: XRReferenceSpace;
  43849. /**
  43850. * The current reference space used in this session. This reference space can constantly change!
  43851. * It is mainly used to offset the camera's position.
  43852. */
  43853. referenceSpace: XRReferenceSpace;
  43854. /**
  43855. * The base reference space from which the session started. good if you want to reset your
  43856. * reference space
  43857. */
  43858. baseReferenceSpace: XRReferenceSpace;
  43859. /**
  43860. * Used just in case of a failure to initialize an immersive session.
  43861. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43862. */
  43863. defaultHeightCompensation: number;
  43864. /**
  43865. * Current XR frame
  43866. */
  43867. currentFrame: Nullable<XRFrame>;
  43868. /** WebXR timestamp updated every frame */
  43869. currentTimestamp: number;
  43870. private _xrNavigator;
  43871. private baseLayer;
  43872. private _rttProvider;
  43873. private _sessionEnded;
  43874. /**
  43875. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43876. * @param scene The scene which the session should be created for
  43877. */
  43878. constructor(
  43879. /** The scene which the session should be created for */
  43880. scene: Scene);
  43881. /**
  43882. * Initializes the manager
  43883. * After initialization enterXR can be called to start an XR session
  43884. * @returns Promise which resolves after it is initialized
  43885. */
  43886. initializeAsync(): Promise<void>;
  43887. /**
  43888. * Initializes an xr session
  43889. * @param xrSessionMode mode to initialize
  43890. * @param optionalFeatures defines optional values to pass to the session builder
  43891. * @returns a promise which will resolve once the session has been initialized
  43892. */
  43893. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43894. /**
  43895. * Sets the reference space on the xr session
  43896. * @param referenceSpace space to set
  43897. * @returns a promise that will resolve once the reference space has been set
  43898. */
  43899. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43900. /**
  43901. * Updates the render state of the session
  43902. * @param state state to set
  43903. * @returns a promise that resolves once the render state has been updated
  43904. */
  43905. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43906. /**
  43907. * Starts rendering to the xr layer
  43908. * @returns a promise that will resolve once rendering has started
  43909. */
  43910. startRenderingToXRAsync(): Promise<void>;
  43911. /**
  43912. * Gets the correct render target texture to be rendered this frame for this eye
  43913. * @param eye the eye for which to get the render target
  43914. * @returns the render target for the specified eye
  43915. */
  43916. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43917. /**
  43918. * Stops the xrSession and restores the renderloop
  43919. * @returns Promise which resolves after it exits XR
  43920. */
  43921. exitXRAsync(): Promise<void>;
  43922. /**
  43923. * Checks if a session would be supported for the creation options specified
  43924. * @param sessionMode session mode to check if supported eg. immersive-vr
  43925. * @returns true if supported
  43926. */
  43927. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43928. /**
  43929. * Creates a WebXRRenderTarget object for the XR session
  43930. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43931. * @param options optional options to provide when creating a new render target
  43932. * @returns a WebXR render target to which the session can render
  43933. */
  43934. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43935. /**
  43936. * @hidden
  43937. * Converts the render layer of xrSession to a render target
  43938. * @param session session to create render target for
  43939. * @param scene scene the new render target should be created for
  43940. * @param baseLayer the webgl layer to create the render target for
  43941. */
  43942. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43943. /**
  43944. * Disposes of the session manager
  43945. */
  43946. dispose(): void;
  43947. /**
  43948. * Gets a promise returning true when fullfiled if the given session mode is supported
  43949. * @param sessionMode defines the session to test
  43950. * @returns a promise
  43951. */
  43952. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43953. }
  43954. }
  43955. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43956. import { Scene } from "babylonjs/scene";
  43957. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43958. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43959. /**
  43960. * WebXR Camera which holds the views for the xrSession
  43961. * @see https://doc.babylonjs.com/how_to/webxr
  43962. */
  43963. export class WebXRCamera extends FreeCamera {
  43964. private _xrSessionManager;
  43965. /**
  43966. * Is the camera in debug mode. Used when using an emulator
  43967. */
  43968. debugMode: boolean;
  43969. private _firstFrame;
  43970. private _referencedPosition;
  43971. private _referenceQuaternion;
  43972. private _xrInvPositionCache;
  43973. private _xrInvQuaternionCache;
  43974. /**
  43975. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43976. * @param name the name of the camera
  43977. * @param scene the scene to add the camera to
  43978. */
  43979. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43980. private _updateNumberOfRigCameras;
  43981. /** @hidden */
  43982. _updateForDualEyeDebugging(): void;
  43983. private _updateReferenceSpace;
  43984. private _updateReferenceSpaceOffset;
  43985. private _updateFromXRSession;
  43986. }
  43987. }
  43988. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  43989. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43990. import { IDisposable } from "babylonjs/scene";
  43991. /**
  43992. * Defining the interface required for a (webxr) feature
  43993. */
  43994. export interface IWebXRFeature extends IDisposable {
  43995. /**
  43996. * Attach the feature to the session
  43997. * Will usually be called by the features manager
  43998. *
  43999. * @returns true if successful.
  44000. */
  44001. attach(): boolean;
  44002. /**
  44003. * Detach the feature from the session
  44004. * Will usually be called by the features manager
  44005. *
  44006. * @returns true if successful.
  44007. */
  44008. detach(): boolean;
  44009. }
  44010. /**
  44011. * Defining the constructor of a feature. Used to register the modules.
  44012. */
  44013. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44014. /**
  44015. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44016. * It is mainly used in AR sessions.
  44017. *
  44018. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44019. */
  44020. export class WebXRFeaturesManager implements IDisposable {
  44021. private _xrSessionManager;
  44022. private static readonly _AvailableFeatures;
  44023. /**
  44024. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44025. * Mainly used internally.
  44026. *
  44027. * @param featureName the name of the feature to register
  44028. * @param constructorFunction the function used to construct the module
  44029. * @param version the (babylon) version of the module
  44030. * @param stable is that a stable version of this module
  44031. */
  44032. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44033. /**
  44034. * Returns a constructor of a specific feature.
  44035. *
  44036. * @param featureName the name of the feature to construct
  44037. * @param version the version of the feature to load
  44038. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44039. * @param options optional options provided to the module.
  44040. * @returns a function that, when called, will return a new instance of this feature
  44041. */
  44042. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44043. /**
  44044. * Return the latest unstable version of this feature
  44045. * @param featureName the name of the feature to search
  44046. * @returns the version number. if not found will return -1
  44047. */
  44048. static GetLatestVersionOfFeature(featureName: string): number;
  44049. /**
  44050. * Return the latest stable version of this feature
  44051. * @param featureName the name of the feature to search
  44052. * @returns the version number. if not found will return -1
  44053. */
  44054. static GetStableVersionOfFeature(featureName: string): number;
  44055. /**
  44056. * Can be used to return the list of features currently registered
  44057. *
  44058. * @returns an Array of available features
  44059. */
  44060. static GetAvailableFeatures(): string[];
  44061. /**
  44062. * Gets the versions available for a specific feature
  44063. * @param featureName the name of the feature
  44064. * @returns an array with the available versions
  44065. */
  44066. static GetAvailableVersions(featureName: string): string[];
  44067. private _features;
  44068. /**
  44069. * constructs a new features manages.
  44070. *
  44071. * @param _xrSessionManager an instance of WebXRSessionManager
  44072. */
  44073. constructor(_xrSessionManager: WebXRSessionManager);
  44074. /**
  44075. * 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.
  44076. *
  44077. * @param featureName the name of the feature to load or the class of the feature
  44078. * @param version optional version to load. if not provided the latest version will be enabled
  44079. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44080. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44081. * @returns a new constructed feature or throws an error if feature not found.
  44082. */
  44083. enableFeature(featureName: string | {
  44084. Name: string;
  44085. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44086. /**
  44087. * Used to disable an already-enabled feature
  44088. * @param featureName the feature to disable
  44089. * @returns true if disable was successful
  44090. */
  44091. disableFeature(featureName: string | {
  44092. Name: string;
  44093. }): boolean;
  44094. /**
  44095. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44096. * Can be used during a session to start a feature
  44097. * @param featureName the name of feature to attach
  44098. */
  44099. attachFeature(featureName: string): void;
  44100. /**
  44101. * Can be used inside a session or when the session ends to detach a specific feature
  44102. * @param featureName the name of the feature to detach
  44103. */
  44104. detachFeature(featureName: string): void;
  44105. /**
  44106. * Get the list of enabled features
  44107. * @returns an array of enabled features
  44108. */
  44109. getEnabledFeatures(): string[];
  44110. /**
  44111. * get the implementation of an enabled feature.
  44112. * @param featureName the name of the feature to load
  44113. * @returns the feature class, if found
  44114. */
  44115. getEnabledFeature(featureName: string): IWebXRFeature;
  44116. /**
  44117. * dispose this features manager
  44118. */
  44119. dispose(): void;
  44120. }
  44121. }
  44122. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44123. import { Observable } from "babylonjs/Misc/observable";
  44124. import { IDisposable, Scene } from "babylonjs/scene";
  44125. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44126. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44127. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44128. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44129. /**
  44130. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44131. * @see https://doc.babylonjs.com/how_to/webxr
  44132. */
  44133. export class WebXRExperienceHelper implements IDisposable {
  44134. private scene;
  44135. /**
  44136. * Camera used to render xr content
  44137. */
  44138. camera: WebXRCamera;
  44139. /**
  44140. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44141. */
  44142. state: WebXRState;
  44143. private _setState;
  44144. /**
  44145. * Fires when the state of the experience helper has changed
  44146. */
  44147. onStateChangedObservable: Observable<WebXRState>;
  44148. /**
  44149. * Observers registered here will be triggered after the camera's initial transformation is set
  44150. * This can be used to set a different ground level or an extra rotation.
  44151. *
  44152. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44153. * to the position set after this observable is done executing.
  44154. */
  44155. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44156. /** Session manager used to keep track of xr session */
  44157. sessionManager: WebXRSessionManager;
  44158. /** A features manager for this xr session */
  44159. featuresManager: WebXRFeaturesManager;
  44160. private _nonVRCamera;
  44161. private _originalSceneAutoClear;
  44162. private _supported;
  44163. /**
  44164. * Creates the experience helper
  44165. * @param scene the scene to attach the experience helper to
  44166. * @returns a promise for the experience helper
  44167. */
  44168. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44169. /**
  44170. * Creates a WebXRExperienceHelper
  44171. * @param scene The scene the helper should be created in
  44172. */
  44173. private constructor();
  44174. /**
  44175. * Exits XR mode and returns the scene to its original state
  44176. * @returns promise that resolves after xr mode has exited
  44177. */
  44178. exitXRAsync(): Promise<void>;
  44179. /**
  44180. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44181. * @param sessionMode options for the XR session
  44182. * @param referenceSpaceType frame of reference of the XR session
  44183. * @param renderTarget the output canvas that will be used to enter XR mode
  44184. * @returns promise that resolves after xr mode has entered
  44185. */
  44186. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44187. /**
  44188. * Disposes of the experience helper
  44189. */
  44190. dispose(): void;
  44191. private _nonXRToXRCamera;
  44192. }
  44193. }
  44194. declare module "babylonjs/Cameras/XR/motionController/webXRControllerComponent" {
  44195. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  44196. import { Observable } from "babylonjs/Misc/observable";
  44197. import { IDisposable } from "babylonjs/scene";
  44198. /**
  44199. * X-Y values for axes in WebXR
  44200. */
  44201. export interface IWebXRMotionControllerAxesValue {
  44202. /**
  44203. * The value of the x axis
  44204. */
  44205. x: number;
  44206. /**
  44207. * The value of the y-axis
  44208. */
  44209. y: number;
  44210. }
  44211. /**
  44212. * changed / previous values for the values of this component
  44213. */
  44214. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44215. /**
  44216. * current (this frame) value
  44217. */
  44218. current: T;
  44219. /**
  44220. * previous (last change) value
  44221. */
  44222. previous: T;
  44223. }
  44224. /**
  44225. * Represents changes in the component between current frame and last values recorded
  44226. */
  44227. export interface IWebXRMotionControllerComponentChanges {
  44228. /**
  44229. * will be populated with previous and current values if touched changed
  44230. */
  44231. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44232. /**
  44233. * will be populated with previous and current values if pressed changed
  44234. */
  44235. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44236. /**
  44237. * will be populated with previous and current values if value changed
  44238. */
  44239. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44240. /**
  44241. * will be populated with previous and current values if axes changed
  44242. */
  44243. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44244. }
  44245. /**
  44246. * This class represents a single component (for example button or thumbstick) of a motion controller
  44247. */
  44248. export class WebXRControllerComponent implements IDisposable {
  44249. /**
  44250. * the id of this component
  44251. */
  44252. id: string;
  44253. /**
  44254. * the type of the component
  44255. */
  44256. type: MotionControllerComponentType;
  44257. private _buttonIndex;
  44258. private _axesIndices;
  44259. /**
  44260. * Observers registered here will be triggered when the state of a button changes
  44261. * State change is either pressed / touched / value
  44262. */
  44263. onButtonStateChanged: Observable<WebXRControllerComponent>;
  44264. /**
  44265. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44266. * the axes data changes
  44267. */
  44268. onAxisValueChanged: Observable<{
  44269. x: number;
  44270. y: number;
  44271. }>;
  44272. private _currentValue;
  44273. private _touched;
  44274. private _pressed;
  44275. private _axes;
  44276. private _changes;
  44277. /**
  44278. * Creates a new component for a motion controller.
  44279. * It is created by the motion controller itself
  44280. *
  44281. * @param id the id of this component
  44282. * @param type the type of the component
  44283. * @param _buttonIndex index in the buttons array of the gamepad
  44284. * @param _axesIndices indices of the values in the axes array of the gamepad
  44285. */
  44286. constructor(
  44287. /**
  44288. * the id of this component
  44289. */
  44290. id: string,
  44291. /**
  44292. * the type of the component
  44293. */
  44294. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44295. /**
  44296. * Get the current value of this component
  44297. */
  44298. get value(): number;
  44299. /**
  44300. * is the button currently pressed
  44301. */
  44302. get pressed(): boolean;
  44303. /**
  44304. * is the button currently touched
  44305. */
  44306. get touched(): boolean;
  44307. /**
  44308. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44309. */
  44310. get axes(): IWebXRMotionControllerAxesValue;
  44311. /**
  44312. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44313. */
  44314. get changes(): IWebXRMotionControllerComponentChanges;
  44315. /**
  44316. * Is this component a button (hence - pressable)
  44317. * @returns true if can be pressed
  44318. */
  44319. isButton(): boolean;
  44320. /**
  44321. * Are there axes correlating to this component
  44322. * @return true is axes data is available
  44323. */
  44324. isAxes(): boolean;
  44325. /**
  44326. * update this component using the gamepad object it is in. Called on every frame
  44327. * @param nativeController the native gamepad controller object
  44328. */
  44329. update(nativeController: IMinimalMotionControllerObject): void;
  44330. /**
  44331. * Dispose this component
  44332. */
  44333. dispose(): void;
  44334. }
  44335. }
  44336. declare module "babylonjs/Loading/sceneLoader" {
  44337. import { Observable } from "babylonjs/Misc/observable";
  44338. import { Nullable } from "babylonjs/types";
  44339. import { Scene } from "babylonjs/scene";
  44340. import { Engine } from "babylonjs/Engines/engine";
  44341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44342. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44343. import { AssetContainer } from "babylonjs/assetContainer";
  44344. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44345. import { Skeleton } from "babylonjs/Bones/skeleton";
  44346. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44347. import { WebRequest } from "babylonjs/Misc/webRequest";
  44348. /**
  44349. * Class used to represent data loading progression
  44350. */
  44351. export class SceneLoaderProgressEvent {
  44352. /** defines if data length to load can be evaluated */
  44353. readonly lengthComputable: boolean;
  44354. /** defines the loaded data length */
  44355. readonly loaded: number;
  44356. /** defines the data length to load */
  44357. readonly total: number;
  44358. /**
  44359. * Create a new progress event
  44360. * @param lengthComputable defines if data length to load can be evaluated
  44361. * @param loaded defines the loaded data length
  44362. * @param total defines the data length to load
  44363. */
  44364. constructor(
  44365. /** defines if data length to load can be evaluated */
  44366. lengthComputable: boolean,
  44367. /** defines the loaded data length */
  44368. loaded: number,
  44369. /** defines the data length to load */
  44370. total: number);
  44371. /**
  44372. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44373. * @param event defines the source event
  44374. * @returns a new SceneLoaderProgressEvent
  44375. */
  44376. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44377. }
  44378. /**
  44379. * Interface used by SceneLoader plugins to define supported file extensions
  44380. */
  44381. export interface ISceneLoaderPluginExtensions {
  44382. /**
  44383. * Defines the list of supported extensions
  44384. */
  44385. [extension: string]: {
  44386. isBinary: boolean;
  44387. };
  44388. }
  44389. /**
  44390. * Interface used by SceneLoader plugin factory
  44391. */
  44392. export interface ISceneLoaderPluginFactory {
  44393. /**
  44394. * Defines the name of the factory
  44395. */
  44396. name: string;
  44397. /**
  44398. * Function called to create a new plugin
  44399. * @return the new plugin
  44400. */
  44401. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44402. /**
  44403. * The callback that returns true if the data can be directly loaded.
  44404. * @param data string containing the file data
  44405. * @returns if the data can be loaded directly
  44406. */
  44407. canDirectLoad?(data: string): boolean;
  44408. }
  44409. /**
  44410. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44411. */
  44412. export interface ISceneLoaderPluginBase {
  44413. /**
  44414. * The friendly name of this plugin.
  44415. */
  44416. name: string;
  44417. /**
  44418. * The file extensions supported by this plugin.
  44419. */
  44420. extensions: string | ISceneLoaderPluginExtensions;
  44421. /**
  44422. * The callback called when loading from a url.
  44423. * @param scene scene loading this url
  44424. * @param url url to load
  44425. * @param onSuccess callback called when the file successfully loads
  44426. * @param onProgress callback called while file is loading (if the server supports this mode)
  44427. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44428. * @param onError callback called when the file fails to load
  44429. * @returns a file request object
  44430. */
  44431. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44432. /**
  44433. * The callback called when loading from a file object.
  44434. * @param scene scene loading this file
  44435. * @param file defines the file to load
  44436. * @param onSuccess defines the callback to call when data is loaded
  44437. * @param onProgress defines the callback to call during loading process
  44438. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44439. * @param onError defines the callback to call when an error occurs
  44440. * @returns a file request object
  44441. */
  44442. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44443. /**
  44444. * The callback that returns true if the data can be directly loaded.
  44445. * @param data string containing the file data
  44446. * @returns if the data can be loaded directly
  44447. */
  44448. canDirectLoad?(data: string): boolean;
  44449. /**
  44450. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44451. * @param scene scene loading this data
  44452. * @param data string containing the data
  44453. * @returns data to pass to the plugin
  44454. */
  44455. directLoad?(scene: Scene, data: string): any;
  44456. /**
  44457. * The callback that allows custom handling of the root url based on the response url.
  44458. * @param rootUrl the original root url
  44459. * @param responseURL the response url if available
  44460. * @returns the new root url
  44461. */
  44462. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44463. }
  44464. /**
  44465. * Interface used to define a SceneLoader plugin
  44466. */
  44467. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44468. /**
  44469. * Import meshes into a scene.
  44470. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44471. * @param scene The scene to import into
  44472. * @param data The data to import
  44473. * @param rootUrl The root url for scene and resources
  44474. * @param meshes The meshes array to import into
  44475. * @param particleSystems The particle systems array to import into
  44476. * @param skeletons The skeletons array to import into
  44477. * @param onError The callback when import fails
  44478. * @returns True if successful or false otherwise
  44479. */
  44480. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44481. /**
  44482. * Load into a scene.
  44483. * @param scene The scene to load into
  44484. * @param data The data to import
  44485. * @param rootUrl The root url for scene and resources
  44486. * @param onError The callback when import fails
  44487. * @returns True if successful or false otherwise
  44488. */
  44489. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44490. /**
  44491. * Load into an asset container.
  44492. * @param scene The scene to load into
  44493. * @param data The data to import
  44494. * @param rootUrl The root url for scene and resources
  44495. * @param onError The callback when import fails
  44496. * @returns The loaded asset container
  44497. */
  44498. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44499. }
  44500. /**
  44501. * Interface used to define an async SceneLoader plugin
  44502. */
  44503. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44504. /**
  44505. * Import meshes into a scene.
  44506. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44507. * @param scene The scene to import into
  44508. * @param data The data to import
  44509. * @param rootUrl The root url for scene and resources
  44510. * @param onProgress The callback when the load progresses
  44511. * @param fileName Defines the name of the file to load
  44512. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44513. */
  44514. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44515. meshes: AbstractMesh[];
  44516. particleSystems: IParticleSystem[];
  44517. skeletons: Skeleton[];
  44518. animationGroups: AnimationGroup[];
  44519. }>;
  44520. /**
  44521. * Load into a scene.
  44522. * @param scene The scene to load into
  44523. * @param data The data to import
  44524. * @param rootUrl The root url for scene and resources
  44525. * @param onProgress The callback when the load progresses
  44526. * @param fileName Defines the name of the file to load
  44527. * @returns Nothing
  44528. */
  44529. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44530. /**
  44531. * Load into an asset container.
  44532. * @param scene The scene to load into
  44533. * @param data The data to import
  44534. * @param rootUrl The root url for scene and resources
  44535. * @param onProgress The callback when the load progresses
  44536. * @param fileName Defines the name of the file to load
  44537. * @returns The loaded asset container
  44538. */
  44539. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44540. }
  44541. /**
  44542. * Mode that determines how to handle old animation groups before loading new ones.
  44543. */
  44544. export enum SceneLoaderAnimationGroupLoadingMode {
  44545. /**
  44546. * Reset all old animations to initial state then dispose them.
  44547. */
  44548. Clean = 0,
  44549. /**
  44550. * Stop all old animations.
  44551. */
  44552. Stop = 1,
  44553. /**
  44554. * Restart old animations from first frame.
  44555. */
  44556. Sync = 2,
  44557. /**
  44558. * Old animations remains untouched.
  44559. */
  44560. NoSync = 3
  44561. }
  44562. /**
  44563. * Class used to load scene from various file formats using registered plugins
  44564. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44565. */
  44566. export class SceneLoader {
  44567. /**
  44568. * No logging while loading
  44569. */
  44570. static readonly NO_LOGGING: number;
  44571. /**
  44572. * Minimal logging while loading
  44573. */
  44574. static readonly MINIMAL_LOGGING: number;
  44575. /**
  44576. * Summary logging while loading
  44577. */
  44578. static readonly SUMMARY_LOGGING: number;
  44579. /**
  44580. * Detailled logging while loading
  44581. */
  44582. static readonly DETAILED_LOGGING: number;
  44583. /**
  44584. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44585. */
  44586. static get ForceFullSceneLoadingForIncremental(): boolean;
  44587. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44588. /**
  44589. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44590. */
  44591. static get ShowLoadingScreen(): boolean;
  44592. static set ShowLoadingScreen(value: boolean);
  44593. /**
  44594. * Defines the current logging level (while loading the scene)
  44595. * @ignorenaming
  44596. */
  44597. static get loggingLevel(): number;
  44598. static set loggingLevel(value: number);
  44599. /**
  44600. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44601. */
  44602. static get CleanBoneMatrixWeights(): boolean;
  44603. static set CleanBoneMatrixWeights(value: boolean);
  44604. /**
  44605. * Event raised when a plugin is used to load a scene
  44606. */
  44607. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44608. private static _registeredPlugins;
  44609. private static _getDefaultPlugin;
  44610. private static _getPluginForExtension;
  44611. private static _getPluginForDirectLoad;
  44612. private static _getPluginForFilename;
  44613. private static _getDirectLoad;
  44614. private static _loadData;
  44615. private static _getFileInfo;
  44616. /**
  44617. * Gets a plugin that can load the given extension
  44618. * @param extension defines the extension to load
  44619. * @returns a plugin or null if none works
  44620. */
  44621. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44622. /**
  44623. * Gets a boolean indicating that the given extension can be loaded
  44624. * @param extension defines the extension to load
  44625. * @returns true if the extension is supported
  44626. */
  44627. static IsPluginForExtensionAvailable(extension: string): boolean;
  44628. /**
  44629. * Adds a new plugin to the list of registered plugins
  44630. * @param plugin defines the plugin to add
  44631. */
  44632. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44633. /**
  44634. * Import meshes into a scene
  44635. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44636. * @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)
  44637. * @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)
  44638. * @param scene the instance of BABYLON.Scene to append to
  44639. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44640. * @param onProgress a callback with a progress event for each file being loaded
  44641. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44642. * @param pluginExtension the extension used to determine the plugin
  44643. * @returns The loaded plugin
  44644. */
  44645. 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>;
  44646. /**
  44647. * Import meshes into a scene
  44648. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44649. * @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)
  44650. * @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)
  44651. * @param scene the instance of BABYLON.Scene to append to
  44652. * @param onProgress a callback with a progress event for each file being loaded
  44653. * @param pluginExtension the extension used to determine the plugin
  44654. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44655. */
  44656. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44657. meshes: AbstractMesh[];
  44658. particleSystems: IParticleSystem[];
  44659. skeletons: Skeleton[];
  44660. animationGroups: AnimationGroup[];
  44661. }>;
  44662. /**
  44663. * Load a scene
  44664. * @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)
  44665. * @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)
  44666. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44667. * @param onSuccess a callback with the scene when import succeeds
  44668. * @param onProgress a callback with a progress event for each file being loaded
  44669. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44670. * @param pluginExtension the extension used to determine the plugin
  44671. * @returns The loaded plugin
  44672. */
  44673. 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>;
  44674. /**
  44675. * Load a scene
  44676. * @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)
  44677. * @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)
  44678. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44679. * @param onProgress a callback with a progress event for each file being loaded
  44680. * @param pluginExtension the extension used to determine the plugin
  44681. * @returns The loaded scene
  44682. */
  44683. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44684. /**
  44685. * Append a scene
  44686. * @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)
  44687. * @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)
  44688. * @param scene is the instance of BABYLON.Scene to append to
  44689. * @param onSuccess a callback with the scene when import succeeds
  44690. * @param onProgress a callback with a progress event for each file being loaded
  44691. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44692. * @param pluginExtension the extension used to determine the plugin
  44693. * @returns The loaded plugin
  44694. */
  44695. 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>;
  44696. /**
  44697. * Append a scene
  44698. * @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)
  44699. * @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)
  44700. * @param scene is the instance of BABYLON.Scene to append to
  44701. * @param onProgress a callback with a progress event for each file being loaded
  44702. * @param pluginExtension the extension used to determine the plugin
  44703. * @returns The given scene
  44704. */
  44705. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44706. /**
  44707. * Load a scene into an asset container
  44708. * @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)
  44709. * @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)
  44710. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44711. * @param onSuccess a callback with the scene when import succeeds
  44712. * @param onProgress a callback with a progress event for each file being loaded
  44713. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44714. * @param pluginExtension the extension used to determine the plugin
  44715. * @returns The loaded plugin
  44716. */
  44717. 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>;
  44718. /**
  44719. * Load a scene into an asset container
  44720. * @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)
  44721. * @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)
  44722. * @param scene is the instance of Scene to append to
  44723. * @param onProgress a callback with a progress event for each file being loaded
  44724. * @param pluginExtension the extension used to determine the plugin
  44725. * @returns The loaded asset container
  44726. */
  44727. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44728. /**
  44729. * Import animations from a file into a scene
  44730. * @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)
  44731. * @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)
  44732. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44733. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44734. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44735. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44736. * @param onSuccess a callback with the scene when import succeeds
  44737. * @param onProgress a callback with a progress event for each file being loaded
  44738. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44739. */
  44740. 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;
  44741. /**
  44742. * Import animations from a file into a scene
  44743. * @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)
  44744. * @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)
  44745. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44746. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44747. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44748. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44749. * @param onSuccess a callback with the scene when import succeeds
  44750. * @param onProgress a callback with a progress event for each file being loaded
  44751. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44752. * @returns the updated scene with imported animations
  44753. */
  44754. 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>;
  44755. }
  44756. }
  44757. declare module "babylonjs/Cameras/XR/motionController/webXRAbstractController" {
  44758. import { IDisposable, Scene } from "babylonjs/scene";
  44759. import { WebXRControllerComponent } from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  44760. import { Observable } from "babylonjs/Misc/observable";
  44761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44762. import { Nullable } from "babylonjs/types";
  44763. /**
  44764. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44765. */
  44766. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  44767. /**
  44768. * The type of components available in motion controllers.
  44769. * This is not the name of the component.
  44770. */
  44771. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44772. /**
  44773. * The schema of motion controller layout.
  44774. * No object will be initialized using this interface
  44775. * This is used just to define the profile.
  44776. */
  44777. export interface IMotionControllerLayout {
  44778. /**
  44779. * Defines the main button component id
  44780. */
  44781. selectComponentId: string;
  44782. /**
  44783. * Available components (unsorted)
  44784. */
  44785. components: {
  44786. /**
  44787. * A map of component Ids
  44788. */
  44789. [componentId: string]: {
  44790. /**
  44791. * The type of input the component outputs
  44792. */
  44793. type: MotionControllerComponentType;
  44794. };
  44795. };
  44796. /**
  44797. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  44798. */
  44799. gamepad?: {
  44800. /**
  44801. * Is the mapping based on the xr-standard defined here:
  44802. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  44803. */
  44804. mapping: "" | "xr-standard";
  44805. /**
  44806. * The buttons available in this input in the right order
  44807. * index of this button will be the index in the gamepadObject.buttons array
  44808. * correlates to the componentId in components
  44809. */
  44810. buttons: Array<string | null>;
  44811. /**
  44812. * Definition of the axes of the gamepad input, sorted
  44813. * Correlates to componentIds in the components map
  44814. */
  44815. axes: Array<{
  44816. /**
  44817. * The component id that the axis correlates to
  44818. */
  44819. componentId: string;
  44820. /**
  44821. * X or Y Axis
  44822. */
  44823. axis: "x-axis" | "y-axis";
  44824. } | null>;
  44825. };
  44826. }
  44827. /**
  44828. * A definition for the layout map in the input profile
  44829. */
  44830. export interface IMotionControllerLayoutMap {
  44831. /**
  44832. * Layouts with handness type as a key
  44833. */
  44834. [handness: string]: IMotionControllerLayout;
  44835. }
  44836. /**
  44837. * The XR Input profile schema
  44838. * Profiles can be found here:
  44839. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44840. */
  44841. export interface IMotionControllerProfile {
  44842. /**
  44843. * The id of this profile
  44844. * correlates to the profile(s) in the xrInput.profiles array
  44845. */
  44846. profileId: string;
  44847. /**
  44848. * fallback profiles for this profileId
  44849. */
  44850. fallbackProfileIds: string[];
  44851. /**
  44852. * The layout map, with handness as key
  44853. */
  44854. layouts: IMotionControllerLayoutMap;
  44855. }
  44856. /**
  44857. * A helper-interface for the 3 meshes needed for controller button animation
  44858. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44859. */
  44860. export interface IMotionControllerButtonMeshMap {
  44861. /**
  44862. * The mesh that will be changed when value changes
  44863. */
  44864. valueMesh: AbstractMesh;
  44865. /**
  44866. * the mesh that defines the pressed value mesh position.
  44867. * This is used to find the max-position of this button
  44868. */
  44869. pressedMesh: AbstractMesh;
  44870. /**
  44871. * the mesh that defines the unpressed value mesh position.
  44872. * This is used to find the min (or initial) position of this button
  44873. */
  44874. unpressedMesh: AbstractMesh;
  44875. }
  44876. /**
  44877. * A helper-interface for the 3 meshes needed for controller axis animation.
  44878. * This will be expanded when touchpad animations are fully supported
  44879. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44880. */
  44881. export interface IMotionControllerAxisMeshMap {
  44882. /**
  44883. * The mesh that will be changed when axis value changes
  44884. */
  44885. valueMesh: AbstractMesh;
  44886. /**
  44887. * the mesh that defines the minimum value mesh position.
  44888. */
  44889. minMesh: AbstractMesh;
  44890. /**
  44891. * the mesh that defines the maximum value mesh position.
  44892. */
  44893. maxMesh: AbstractMesh;
  44894. }
  44895. /**
  44896. * The elements needed for change-detection of the gamepad objects in motion controllers
  44897. */
  44898. export interface IMinimalMotionControllerObject {
  44899. /**
  44900. * An array of available buttons
  44901. */
  44902. buttons: Array<{
  44903. /**
  44904. * Value of the button/trigger
  44905. */
  44906. value: number;
  44907. /**
  44908. * If the button/trigger is currently touched
  44909. */
  44910. touched: boolean;
  44911. /**
  44912. * If the button/trigger is currently pressed
  44913. */
  44914. pressed: boolean;
  44915. }>;
  44916. /**
  44917. * Available axes of this controller
  44918. */
  44919. axes: number[];
  44920. }
  44921. /**
  44922. * An Abstract Motion controller
  44923. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44924. * Each component has an observable to check for changes in value and state
  44925. */
  44926. export abstract class WebXRAbstractMotionController implements IDisposable {
  44927. protected scene: Scene;
  44928. protected layout: IMotionControllerLayout;
  44929. /**
  44930. * The gamepad object correlating to this controller
  44931. */
  44932. gamepadObject: IMinimalMotionControllerObject;
  44933. /**
  44934. * handness (left/right/none) of this controller
  44935. */
  44936. handness: MotionControllerHandness;
  44937. /**
  44938. * Component type map
  44939. */
  44940. static ComponentType: {
  44941. TRIGGER: string;
  44942. SQUEEZE: string;
  44943. TOUCHPAD: string;
  44944. THUMBSTICK: string;
  44945. BUTTON: string;
  44946. };
  44947. /**
  44948. * The profile id of this motion controller
  44949. */
  44950. abstract profileId: string;
  44951. /**
  44952. * A map of components (WebXRControllerComponent) in this motion controller
  44953. * Components have a ComponentType and can also have both button and axis definitions
  44954. */
  44955. readonly components: {
  44956. [id: string]: WebXRControllerComponent;
  44957. };
  44958. /**
  44959. * Observers registered here will be triggered when the model of this controller is done loading
  44960. */
  44961. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44962. /**
  44963. * The root mesh of the model. It is null if the model was not yet initialized
  44964. */
  44965. rootMesh: Nullable<AbstractMesh>;
  44966. private _modelReady;
  44967. /**
  44968. * constructs a new abstract motion controller
  44969. * @param scene the scene to which the model of the controller will be added
  44970. * @param layout The profile layout to load
  44971. * @param gamepadObject The gamepad object correlating to this controller
  44972. * @param handness handness (left/right/none) of this controller
  44973. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44974. */
  44975. constructor(scene: Scene, layout: IMotionControllerLayout,
  44976. /**
  44977. * The gamepad object correlating to this controller
  44978. */
  44979. gamepadObject: IMinimalMotionControllerObject,
  44980. /**
  44981. * handness (left/right/none) of this controller
  44982. */
  44983. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44984. private _initComponent;
  44985. /**
  44986. * Update this model using the current XRFrame
  44987. * @param xrFrame the current xr frame to use and update the model
  44988. */
  44989. updateFromXRFrame(xrFrame: XRFrame): void;
  44990. /**
  44991. * Get the list of components available in this motion controller
  44992. * @returns an array of strings correlating to available components
  44993. */
  44994. getComponentTypes(): string[];
  44995. /**
  44996. * Get the main (Select) component of this controller as defined in the layout
  44997. * @returns the main component of this controller
  44998. */
  44999. getMainComponent(): WebXRControllerComponent;
  45000. /**
  45001. * get a component based an its component id as defined in layout.components
  45002. * @param id the id of the component
  45003. * @returns the component correlates to the id or undefined if not found
  45004. */
  45005. getComponent(id: string): WebXRControllerComponent;
  45006. /**
  45007. * Loads the model correlating to this controller
  45008. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45009. * @returns A promise fulfilled with the result of the model loading
  45010. */
  45011. loadModel(): Promise<boolean>;
  45012. /**
  45013. * Update the model itself with the current frame data
  45014. * @param xrFrame the frame to use for updating the model mesh
  45015. */
  45016. protected updateModel(xrFrame: XRFrame): void;
  45017. /**
  45018. * Moves the axis on the controller mesh based on its current state
  45019. * @param axis the index of the axis
  45020. * @param axisValue the value of the axis which determines the meshes new position
  45021. * @hidden
  45022. */
  45023. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  45024. /**
  45025. * Moves the buttons on the controller mesh based on their current state
  45026. * @param buttonName the name of the button to move
  45027. * @param buttonValue the value of the button which determines the buttons new position
  45028. */
  45029. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  45030. private _getGenericFilenameAndPath;
  45031. private _getGenericParentMesh;
  45032. /**
  45033. * Get the filename and path for this controller's model
  45034. * @returns a map of filename and path
  45035. */
  45036. protected abstract _getFilenameAndPath(): {
  45037. filename: string;
  45038. path: string;
  45039. };
  45040. /**
  45041. * This function will be called after the model was successfully loaded and can be used
  45042. * for mesh transformations before it is available for the user
  45043. * @param meshes the loaded meshes
  45044. */
  45045. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45046. /**
  45047. * Set the root mesh for this controller. Important for the WebXR controller class
  45048. * @param meshes the loaded meshes
  45049. */
  45050. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45051. /**
  45052. * A function executed each frame that updates the mesh (if needed)
  45053. * @param xrFrame the current xrFrame
  45054. */
  45055. protected abstract _updateModel(xrFrame: XRFrame): void;
  45056. /**
  45057. * This function is called before the mesh is loaded. It checks for loading constraints.
  45058. * For example, this function can check if the GLB loader is available
  45059. * If this function returns false, the generic controller will be loaded instead
  45060. * @returns Is the client ready to load the mesh
  45061. */
  45062. protected abstract _getModelLoadingConstraints(): boolean;
  45063. /**
  45064. * Dispose this controller, the model mesh and all its components
  45065. */
  45066. dispose(): void;
  45067. }
  45068. }
  45069. declare module "babylonjs/Cameras/XR/motionController/webXRGenericMotionController" {
  45070. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45072. import { Scene } from "babylonjs/scene";
  45073. /**
  45074. * A generic trigger-only motion controller for WebXR
  45075. */
  45076. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45077. /**
  45078. * Static version of the profile id of this controller
  45079. */
  45080. static ProfileId: string;
  45081. profileId: string;
  45082. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45083. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45084. protected _updateModel(): void;
  45085. protected _getFilenameAndPath(): {
  45086. filename: string;
  45087. path: string;
  45088. };
  45089. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45090. protected _getModelLoadingConstraints(): boolean;
  45091. }
  45092. }
  45093. declare module "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager" {
  45094. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45095. import { Scene } from "babylonjs/scene";
  45096. /**
  45097. * A construction function type to create a new controller based on an xrInput object
  45098. */
  45099. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45100. /**
  45101. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45102. *
  45103. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45104. * it should be replaced with auto-loaded controllers.
  45105. *
  45106. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45107. */
  45108. export class WebXRMotionControllerManager {
  45109. private static _AvailableControllers;
  45110. private static _Fallbacks;
  45111. /**
  45112. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45113. *
  45114. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45115. *
  45116. * @param type the profile type to register
  45117. * @param constructFunction the function to be called when loading this profile
  45118. */
  45119. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45120. /**
  45121. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45122. * The order of search:
  45123. *
  45124. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45125. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45126. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45127. * 4) return the generic trigger controller if none were found
  45128. *
  45129. * @param xrInput the xrInput to which a new controller is initialized
  45130. * @param scene the scene to which the model will be added
  45131. * @param forceProfile force a certain profile for this controller
  45132. * @return the motion controller class for this profile id or the generic standard class if none was found
  45133. */
  45134. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  45135. /**
  45136. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45137. * @param profileId the profile to which a fallback needs to be found
  45138. * @return an array with corresponding fallback profiles
  45139. */
  45140. static FindFallbackWithProfileId(profileId: string): string[];
  45141. /**
  45142. * Register a fallback to a specific profile.
  45143. * @param profileId the profileId that will receive the fallbacks
  45144. * @param fallbacks A list of fallback profiles
  45145. */
  45146. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45147. /**
  45148. * Register the default fallbacks.
  45149. * This function is called automatically when this file is imported.
  45150. */
  45151. static DefaultFallbacks(): void;
  45152. }
  45153. }
  45154. declare module "babylonjs/Cameras/XR/webXRController" {
  45155. import { Observable } from "babylonjs/Misc/observable";
  45156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45157. import { Ray } from "babylonjs/Culling/ray";
  45158. import { Scene } from "babylonjs/scene";
  45159. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45160. /**
  45161. * Represents an XR input
  45162. */
  45163. export class WebXRController {
  45164. private scene;
  45165. /** The underlying input source for the controller */
  45166. inputSource: XRInputSource;
  45167. /**
  45168. * 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
  45169. */
  45170. grip?: AbstractMesh;
  45171. /**
  45172. * Pointer which can be used to select objects or attach a visible laser to
  45173. */
  45174. pointer: AbstractMesh;
  45175. private _gamepadMode;
  45176. /**
  45177. * If available, this is the gamepad object related to this controller.
  45178. * Using this object it is possible to get click events and trackpad changes of the
  45179. * webxr controller that is currently being used.
  45180. */
  45181. gamepadController?: WebXRAbstractMotionController;
  45182. /**
  45183. * Event that fires when the controller is removed/disposed
  45184. */
  45185. onDisposeObservable: Observable<{}>;
  45186. private _tmpQuaternion;
  45187. private _tmpVector;
  45188. /**
  45189. * Creates the controller
  45190. * @see https://doc.babylonjs.com/how_to/webxr
  45191. * @param scene the scene which the controller should be associated to
  45192. * @param inputSource the underlying input source for the controller
  45193. * @param controllerProfile An optional controller profile for this input. This will override the xrInput profile.
  45194. */
  45195. constructor(scene: Scene,
  45196. /** The underlying input source for the controller */
  45197. inputSource: XRInputSource, controllerProfile?: string);
  45198. /**
  45199. * Updates the controller pose based on the given XRFrame
  45200. * @param xrFrame xr frame to update the pose with
  45201. * @param referenceSpace reference space to use
  45202. */
  45203. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45204. /**
  45205. * Gets a world space ray coming from the controller
  45206. * @param result the resulting ray
  45207. */
  45208. getWorldPointerRayToRef(result: Ray): void;
  45209. /**
  45210. * Get the scene associated with this controller
  45211. * @returns the scene object
  45212. */
  45213. getScene(): Scene;
  45214. /**
  45215. * Disposes of the object
  45216. */
  45217. dispose(): void;
  45218. }
  45219. }
  45220. declare module "babylonjs/Cameras/XR/webXRInput" {
  45221. import { Observable } from "babylonjs/Misc/observable";
  45222. import { IDisposable } from "babylonjs/scene";
  45223. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45224. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45225. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  45226. /**
  45227. * The schema for initialization options of the XR Input class
  45228. */
  45229. export interface IWebXRInputOptions {
  45230. /**
  45231. * If set to true no model will be automatically loaded
  45232. */
  45233. doNotLoadControllerMeshes?: boolean;
  45234. /**
  45235. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45236. * If not found, the xr input profile data will be used.
  45237. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45238. */
  45239. forceInputProfile?: string;
  45240. }
  45241. /**
  45242. * XR input used to track XR inputs such as controllers/rays
  45243. */
  45244. export class WebXRInput implements IDisposable {
  45245. /**
  45246. * the xr session manager for this session
  45247. */
  45248. xrSessionManager: WebXRSessionManager;
  45249. /**
  45250. * the WebXR camera for this session. Mainly used for teleportation
  45251. */
  45252. xrCamera: WebXRCamera;
  45253. private readonly options;
  45254. /**
  45255. * XR controllers being tracked
  45256. */
  45257. controllers: Array<WebXRController>;
  45258. private _frameObserver;
  45259. private _sessionEndedObserver;
  45260. private _sessionInitObserver;
  45261. /**
  45262. * Event when a controller has been connected/added
  45263. */
  45264. onControllerAddedObservable: Observable<WebXRController>;
  45265. /**
  45266. * Event when a controller has been removed/disconnected
  45267. */
  45268. onControllerRemovedObservable: Observable<WebXRController>;
  45269. /**
  45270. * Initializes the WebXRInput
  45271. * @param xrSessionManager the xr session manager for this session
  45272. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45273. * @param options = initialization options for this xr input
  45274. */
  45275. constructor(
  45276. /**
  45277. * the xr session manager for this session
  45278. */
  45279. xrSessionManager: WebXRSessionManager,
  45280. /**
  45281. * the WebXR camera for this session. Mainly used for teleportation
  45282. */
  45283. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45284. private _onInputSourcesChange;
  45285. private _addAndRemoveControllers;
  45286. /**
  45287. * Disposes of the object
  45288. */
  45289. dispose(): void;
  45290. }
  45291. }
  45292. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  45293. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45294. /**
  45295. * Handles pointer input automatically for the pointer of XR controllers
  45296. */
  45297. export class WebXRControllerPointerSelection {
  45298. private static _idCounter;
  45299. private _tmpRay;
  45300. /**
  45301. * Creates a WebXRControllerPointerSelection
  45302. * @param input input manager to setup pointer selection
  45303. */
  45304. constructor(input: WebXRInput);
  45305. private _convertNormalToDirectionOfRay;
  45306. private _updatePointerDistance;
  45307. }
  45308. }
  45309. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  45310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45311. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45312. /**
  45313. * Enables teleportation
  45314. */
  45315. export class WebXRControllerTeleportation {
  45316. private _teleportationFillColor;
  45317. private _teleportationBorderColor;
  45318. private _tmpRay;
  45319. private _tmpVector;
  45320. /**
  45321. * when set to true (default) teleportation will wait for thumbstick changes.
  45322. * When set to false teleportation will be disabled.
  45323. *
  45324. * If set to false while teleporting results can be unexpected.
  45325. */
  45326. enabled: boolean;
  45327. /**
  45328. * Creates a WebXRControllerTeleportation
  45329. * @param input input manager to add teleportation to
  45330. * @param floorMeshes floormeshes which can be teleported to
  45331. */
  45332. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  45333. }
  45334. }
  45335. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45336. import { Nullable } from "babylonjs/types";
  45337. import { Observable } from "babylonjs/Misc/observable";
  45338. import { IDisposable, Scene } from "babylonjs/scene";
  45339. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45340. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45341. /**
  45342. * Button which can be used to enter a different mode of XR
  45343. */
  45344. export class WebXREnterExitUIButton {
  45345. /** button element */
  45346. element: HTMLElement;
  45347. /** XR initialization options for the button */
  45348. sessionMode: XRSessionMode;
  45349. /** Reference space type */
  45350. referenceSpaceType: XRReferenceSpaceType;
  45351. /**
  45352. * Creates a WebXREnterExitUIButton
  45353. * @param element button element
  45354. * @param sessionMode XR initialization session mode
  45355. * @param referenceSpaceType the type of reference space to be used
  45356. */
  45357. constructor(
  45358. /** button element */
  45359. element: HTMLElement,
  45360. /** XR initialization options for the button */
  45361. sessionMode: XRSessionMode,
  45362. /** Reference space type */
  45363. referenceSpaceType: XRReferenceSpaceType);
  45364. /**
  45365. * Overwritable function which can be used to update the button's visuals when the state changes
  45366. * @param activeButton the current active button in the UI
  45367. */
  45368. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45369. }
  45370. /**
  45371. * Options to create the webXR UI
  45372. */
  45373. export class WebXREnterExitUIOptions {
  45374. /**
  45375. * Context to enter xr with
  45376. */
  45377. renderTarget?: Nullable<WebXRRenderTarget>;
  45378. /**
  45379. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45380. */
  45381. customButtons?: Array<WebXREnterExitUIButton>;
  45382. /**
  45383. * A session mode to use when creating the default button.
  45384. * Default is immersive-vr
  45385. */
  45386. sessionMode?: XRSessionMode;
  45387. /**
  45388. * A reference space type to use when creating the default button.
  45389. * Default is local-floor
  45390. */
  45391. referenceSpaceType?: XRReferenceSpaceType;
  45392. }
  45393. /**
  45394. * UI to allow the user to enter/exit XR mode
  45395. */
  45396. export class WebXREnterExitUI implements IDisposable {
  45397. private scene;
  45398. /** version of the options passed to this UI */
  45399. options: WebXREnterExitUIOptions;
  45400. private _overlay;
  45401. private _buttons;
  45402. private _activeButton;
  45403. /**
  45404. * Fired every time the active button is changed.
  45405. *
  45406. * When xr is entered via a button that launches xr that button will be the callback parameter
  45407. *
  45408. * When exiting xr the callback parameter will be null)
  45409. */
  45410. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45411. /**
  45412. * Creates UI to allow the user to enter/exit XR mode
  45413. * @param scene the scene to add the ui to
  45414. * @param helper the xr experience helper to enter/exit xr with
  45415. * @param options options to configure the UI
  45416. * @returns the created ui
  45417. */
  45418. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45419. /**
  45420. *
  45421. * @param scene babylon scene object to use
  45422. * @param options (read-only) version of the options passed to this UI
  45423. */
  45424. private constructor();
  45425. private _updateButtons;
  45426. /**
  45427. * Disposes of the object
  45428. */
  45429. dispose(): void;
  45430. }
  45431. }
  45432. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45433. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45434. import { Scene } from "babylonjs/scene";
  45435. import { WebXRInput, IWebXRInputOptions } from "babylonjs/Cameras/XR/webXRInput";
  45436. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45437. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45438. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45439. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45441. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45442. /**
  45443. * Options for the default xr helper
  45444. */
  45445. export class WebXRDefaultExperienceOptions {
  45446. /**
  45447. * Floor meshes that should be used for teleporting
  45448. */
  45449. floorMeshes?: Array<AbstractMesh>;
  45450. /**
  45451. * Enable or disable default UI to enter XR
  45452. */
  45453. disableDefaultUI?: boolean;
  45454. /**
  45455. * optional configuration for the output canvas
  45456. */
  45457. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45458. /**
  45459. * optional UI options. This can be used among other to change session mode and reference space type
  45460. */
  45461. uiOptions?: WebXREnterExitUIOptions;
  45462. /**
  45463. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45464. */
  45465. inputOptions?: IWebXRInputOptions;
  45466. }
  45467. /**
  45468. * Default experience which provides a similar setup to the previous webVRExperience
  45469. */
  45470. export class WebXRDefaultExperience {
  45471. /**
  45472. * Base experience
  45473. */
  45474. baseExperience: WebXRExperienceHelper;
  45475. /**
  45476. * Input experience extension
  45477. */
  45478. input: WebXRInput;
  45479. /**
  45480. * Enables laser pointer and selection
  45481. */
  45482. pointerSelection: WebXRControllerPointerSelection;
  45483. /**
  45484. * Enables teleportation
  45485. */
  45486. teleportation: WebXRControllerTeleportation;
  45487. /**
  45488. * Enables ui for entering/exiting xr
  45489. */
  45490. enterExitUI: WebXREnterExitUI;
  45491. /**
  45492. * Default target xr should render to
  45493. */
  45494. renderTarget: WebXRRenderTarget;
  45495. /**
  45496. * Creates the default xr experience
  45497. * @param scene scene
  45498. * @param options options for basic configuration
  45499. * @returns resulting WebXRDefaultExperience
  45500. */
  45501. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45502. private constructor();
  45503. /**
  45504. * DIsposes of the experience helper
  45505. */
  45506. dispose(): void;
  45507. }
  45508. }
  45509. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  45510. import { Observable } from "babylonjs/Misc/observable";
  45511. import { Nullable } from "babylonjs/types";
  45512. import { Camera } from "babylonjs/Cameras/camera";
  45513. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  45514. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45515. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  45516. import { Scene } from "babylonjs/scene";
  45517. import { Vector3 } from "babylonjs/Maths/math.vector";
  45518. import { Color3 } from "babylonjs/Maths/math.color";
  45519. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45521. import { Mesh } from "babylonjs/Meshes/mesh";
  45522. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45523. import { EasingFunction } from "babylonjs/Animations/easing";
  45524. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  45525. import "babylonjs/Meshes/Builders/groundBuilder";
  45526. import "babylonjs/Meshes/Builders/torusBuilder";
  45527. import "babylonjs/Meshes/Builders/cylinderBuilder";
  45528. import "babylonjs/Gamepads/gamepadSceneComponent";
  45529. import "babylonjs/Animations/animatable";
  45530. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45531. /**
  45532. * Options to modify the vr teleportation behavior.
  45533. */
  45534. export interface VRTeleportationOptions {
  45535. /**
  45536. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45537. */
  45538. floorMeshName?: string;
  45539. /**
  45540. * A list of meshes to be used as the teleportation floor. (default: empty)
  45541. */
  45542. floorMeshes?: Mesh[];
  45543. /**
  45544. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45545. */
  45546. teleportationMode?: number;
  45547. /**
  45548. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45549. */
  45550. teleportationTime?: number;
  45551. /**
  45552. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45553. */
  45554. teleportationSpeed?: number;
  45555. /**
  45556. * The easing function used in the animation or null for Linear. (default CircleEase)
  45557. */
  45558. easingFunction?: EasingFunction;
  45559. }
  45560. /**
  45561. * Options to modify the vr experience helper's behavior.
  45562. */
  45563. export interface VRExperienceHelperOptions extends WebVROptions {
  45564. /**
  45565. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45566. */
  45567. createDeviceOrientationCamera?: boolean;
  45568. /**
  45569. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45570. */
  45571. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45572. /**
  45573. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45574. */
  45575. laserToggle?: boolean;
  45576. /**
  45577. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45578. */
  45579. floorMeshes?: Mesh[];
  45580. /**
  45581. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45582. */
  45583. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45584. /**
  45585. * Defines if WebXR should be used instead of WebVR (if available)
  45586. */
  45587. useXR?: boolean;
  45588. }
  45589. /**
  45590. * Event containing information after VR has been entered
  45591. */
  45592. export class OnAfterEnteringVRObservableEvent {
  45593. /**
  45594. * If entering vr was successful
  45595. */
  45596. success: boolean;
  45597. }
  45598. /**
  45599. * Helps to quickly add VR support to an existing scene.
  45600. * See http://doc.babylonjs.com/how_to/webvr_helper
  45601. */
  45602. export class VRExperienceHelper {
  45603. /** Options to modify the vr experience helper's behavior. */
  45604. webVROptions: VRExperienceHelperOptions;
  45605. private _scene;
  45606. private _position;
  45607. private _btnVR;
  45608. private _btnVRDisplayed;
  45609. private _webVRsupported;
  45610. private _webVRready;
  45611. private _webVRrequesting;
  45612. private _webVRpresenting;
  45613. private _hasEnteredVR;
  45614. private _fullscreenVRpresenting;
  45615. private _inputElement;
  45616. private _webVRCamera;
  45617. private _vrDeviceOrientationCamera;
  45618. private _deviceOrientationCamera;
  45619. private _existingCamera;
  45620. private _onKeyDown;
  45621. private _onVrDisplayPresentChange;
  45622. private _onVRDisplayChanged;
  45623. private _onVRRequestPresentStart;
  45624. private _onVRRequestPresentComplete;
  45625. /**
  45626. * 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)
  45627. */
  45628. enableGazeEvenWhenNoPointerLock: boolean;
  45629. /**
  45630. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45631. */
  45632. exitVROnDoubleTap: boolean;
  45633. /**
  45634. * Observable raised right before entering VR.
  45635. */
  45636. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45637. /**
  45638. * Observable raised when entering VR has completed.
  45639. */
  45640. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45641. /**
  45642. * Observable raised when exiting VR.
  45643. */
  45644. onExitingVRObservable: Observable<VRExperienceHelper>;
  45645. /**
  45646. * Observable raised when controller mesh is loaded.
  45647. */
  45648. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45649. /** Return this.onEnteringVRObservable
  45650. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45651. */
  45652. get onEnteringVR(): Observable<VRExperienceHelper>;
  45653. /** Return this.onExitingVRObservable
  45654. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45655. */
  45656. get onExitingVR(): Observable<VRExperienceHelper>;
  45657. /** Return this.onControllerMeshLoadedObservable
  45658. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45659. */
  45660. get onControllerMeshLoaded(): Observable<WebVRController>;
  45661. private _rayLength;
  45662. private _useCustomVRButton;
  45663. private _teleportationRequested;
  45664. private _teleportActive;
  45665. private _floorMeshName;
  45666. private _floorMeshesCollection;
  45667. private _teleportationMode;
  45668. private _teleportationTime;
  45669. private _teleportationSpeed;
  45670. private _teleportationEasing;
  45671. private _rotationAllowed;
  45672. private _teleportBackwardsVector;
  45673. private _teleportationTarget;
  45674. private _isDefaultTeleportationTarget;
  45675. private _postProcessMove;
  45676. private _teleportationFillColor;
  45677. private _teleportationBorderColor;
  45678. private _rotationAngle;
  45679. private _haloCenter;
  45680. private _cameraGazer;
  45681. private _padSensibilityUp;
  45682. private _padSensibilityDown;
  45683. private _leftController;
  45684. private _rightController;
  45685. private _gazeColor;
  45686. private _laserColor;
  45687. private _pickedLaserColor;
  45688. private _pickedGazeColor;
  45689. /**
  45690. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45691. */
  45692. onNewMeshSelected: Observable<AbstractMesh>;
  45693. /**
  45694. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45695. * This observable will provide the mesh and the controller used to select the mesh
  45696. */
  45697. onMeshSelectedWithController: Observable<{
  45698. mesh: AbstractMesh;
  45699. controller: WebVRController;
  45700. }>;
  45701. /**
  45702. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45703. */
  45704. onNewMeshPicked: Observable<PickingInfo>;
  45705. private _circleEase;
  45706. /**
  45707. * Observable raised before camera teleportation
  45708. */
  45709. onBeforeCameraTeleport: Observable<Vector3>;
  45710. /**
  45711. * Observable raised after camera teleportation
  45712. */
  45713. onAfterCameraTeleport: Observable<Vector3>;
  45714. /**
  45715. * Observable raised when current selected mesh gets unselected
  45716. */
  45717. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45718. private _raySelectionPredicate;
  45719. /**
  45720. * To be optionaly changed by user to define custom ray selection
  45721. */
  45722. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45723. /**
  45724. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45725. */
  45726. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45727. /**
  45728. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45729. */
  45730. teleportationEnabled: boolean;
  45731. private _defaultHeight;
  45732. private _teleportationInitialized;
  45733. private _interactionsEnabled;
  45734. private _interactionsRequested;
  45735. private _displayGaze;
  45736. private _displayLaserPointer;
  45737. /**
  45738. * The mesh used to display where the user is going to teleport.
  45739. */
  45740. get teleportationTarget(): Mesh;
  45741. /**
  45742. * Sets the mesh to be used to display where the user is going to teleport.
  45743. */
  45744. set teleportationTarget(value: Mesh);
  45745. /**
  45746. * 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
  45747. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45748. * See http://doc.babylonjs.com/resources/baking_transformations
  45749. */
  45750. get gazeTrackerMesh(): Mesh;
  45751. set gazeTrackerMesh(value: Mesh);
  45752. /**
  45753. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45754. */
  45755. updateGazeTrackerScale: boolean;
  45756. /**
  45757. * If the gaze trackers color should be updated when selecting meshes
  45758. */
  45759. updateGazeTrackerColor: boolean;
  45760. /**
  45761. * If the controller laser color should be updated when selecting meshes
  45762. */
  45763. updateControllerLaserColor: boolean;
  45764. /**
  45765. * The gaze tracking mesh corresponding to the left controller
  45766. */
  45767. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45768. /**
  45769. * The gaze tracking mesh corresponding to the right controller
  45770. */
  45771. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45772. /**
  45773. * If the ray of the gaze should be displayed.
  45774. */
  45775. get displayGaze(): boolean;
  45776. /**
  45777. * Sets if the ray of the gaze should be displayed.
  45778. */
  45779. set displayGaze(value: boolean);
  45780. /**
  45781. * If the ray of the LaserPointer should be displayed.
  45782. */
  45783. get displayLaserPointer(): boolean;
  45784. /**
  45785. * Sets if the ray of the LaserPointer should be displayed.
  45786. */
  45787. set displayLaserPointer(value: boolean);
  45788. /**
  45789. * The deviceOrientationCamera used as the camera when not in VR.
  45790. */
  45791. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45792. /**
  45793. * Based on the current WebVR support, returns the current VR camera used.
  45794. */
  45795. get currentVRCamera(): Nullable<Camera>;
  45796. /**
  45797. * The webVRCamera which is used when in VR.
  45798. */
  45799. get webVRCamera(): WebVRFreeCamera;
  45800. /**
  45801. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45802. */
  45803. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45804. /**
  45805. * The html button that is used to trigger entering into VR.
  45806. */
  45807. get vrButton(): Nullable<HTMLButtonElement>;
  45808. private get _teleportationRequestInitiated();
  45809. /**
  45810. * Defines wether or not Pointer lock should be requested when switching to
  45811. * full screen.
  45812. */
  45813. requestPointerLockOnFullScreen: boolean;
  45814. /**
  45815. * If asking to force XR, this will be populated with the default xr experience
  45816. */
  45817. xr: WebXRDefaultExperience;
  45818. /**
  45819. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45820. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45821. */
  45822. xrTestDone: boolean;
  45823. /**
  45824. * Instantiates a VRExperienceHelper.
  45825. * Helps to quickly add VR support to an existing scene.
  45826. * @param scene The scene the VRExperienceHelper belongs to.
  45827. * @param webVROptions Options to modify the vr experience helper's behavior.
  45828. */
  45829. constructor(scene: Scene,
  45830. /** Options to modify the vr experience helper's behavior. */
  45831. webVROptions?: VRExperienceHelperOptions);
  45832. private completeVRInit;
  45833. private _onDefaultMeshLoaded;
  45834. private _onResize;
  45835. private _onFullscreenChange;
  45836. /**
  45837. * Gets a value indicating if we are currently in VR mode.
  45838. */
  45839. get isInVRMode(): boolean;
  45840. private onVrDisplayPresentChange;
  45841. private onVRDisplayChanged;
  45842. private moveButtonToBottomRight;
  45843. private displayVRButton;
  45844. private updateButtonVisibility;
  45845. private _cachedAngularSensibility;
  45846. /**
  45847. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45848. * Otherwise, will use the fullscreen API.
  45849. */
  45850. enterVR(): void;
  45851. /**
  45852. * Attempt to exit VR, or fullscreen.
  45853. */
  45854. exitVR(): void;
  45855. /**
  45856. * The position of the vr experience helper.
  45857. */
  45858. get position(): Vector3;
  45859. /**
  45860. * Sets the position of the vr experience helper.
  45861. */
  45862. set position(value: Vector3);
  45863. /**
  45864. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45865. */
  45866. enableInteractions(): void;
  45867. private get _noControllerIsActive();
  45868. private beforeRender;
  45869. private _isTeleportationFloor;
  45870. /**
  45871. * Adds a floor mesh to be used for teleportation.
  45872. * @param floorMesh the mesh to be used for teleportation.
  45873. */
  45874. addFloorMesh(floorMesh: Mesh): void;
  45875. /**
  45876. * Removes a floor mesh from being used for teleportation.
  45877. * @param floorMesh the mesh to be removed.
  45878. */
  45879. removeFloorMesh(floorMesh: Mesh): void;
  45880. /**
  45881. * Enables interactions and teleportation using the VR controllers and gaze.
  45882. * @param vrTeleportationOptions options to modify teleportation behavior.
  45883. */
  45884. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45885. private _onNewGamepadConnected;
  45886. private _tryEnableInteractionOnController;
  45887. private _onNewGamepadDisconnected;
  45888. private _enableInteractionOnController;
  45889. private _checkTeleportWithRay;
  45890. private _checkRotate;
  45891. private _checkTeleportBackwards;
  45892. private _enableTeleportationOnController;
  45893. private _createTeleportationCircles;
  45894. private _displayTeleportationTarget;
  45895. private _hideTeleportationTarget;
  45896. private _rotateCamera;
  45897. private _moveTeleportationSelectorTo;
  45898. private _workingVector;
  45899. private _workingQuaternion;
  45900. private _workingMatrix;
  45901. /**
  45902. * Time Constant Teleportation Mode
  45903. */
  45904. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45905. /**
  45906. * Speed Constant Teleportation Mode
  45907. */
  45908. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45909. /**
  45910. * Teleports the users feet to the desired location
  45911. * @param location The location where the user's feet should be placed
  45912. */
  45913. teleportCamera(location: Vector3): void;
  45914. private _convertNormalToDirectionOfRay;
  45915. private _castRayAndSelectObject;
  45916. private _notifySelectedMeshUnselected;
  45917. /**
  45918. * Permanently set new colors for the laser pointer
  45919. * @param color the new laser color
  45920. * @param pickedColor the new laser color when picked mesh detected
  45921. */
  45922. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45923. /**
  45924. * Permanently set new colors for the gaze pointer
  45925. * @param color the new gaze color
  45926. * @param pickedColor the new gaze color when picked mesh detected
  45927. */
  45928. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45929. /**
  45930. * Sets the color of the laser ray from the vr controllers.
  45931. * @param color new color for the ray.
  45932. */
  45933. changeLaserColor(color: Color3): void;
  45934. /**
  45935. * Sets the color of the ray from the vr headsets gaze.
  45936. * @param color new color for the ray.
  45937. */
  45938. changeGazeColor(color: Color3): void;
  45939. /**
  45940. * Exits VR and disposes of the vr experience helper
  45941. */
  45942. dispose(): void;
  45943. /**
  45944. * Gets the name of the VRExperienceHelper class
  45945. * @returns "VRExperienceHelper"
  45946. */
  45947. getClassName(): string;
  45948. }
  45949. }
  45950. declare module "babylonjs/Cameras/VR/index" {
  45951. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45952. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45953. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45954. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45955. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45956. export * from "babylonjs/Cameras/VR/webVRCamera";
  45957. }
  45958. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  45959. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45960. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45961. import { Observable } from "babylonjs/Misc/observable";
  45962. import { Matrix } from "babylonjs/Maths/math.vector";
  45963. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45964. /**
  45965. * Options used for hit testing
  45966. */
  45967. export interface IWebXRHitTestOptions {
  45968. /**
  45969. * Only test when user interacted with the scene. Default - hit test every frame
  45970. */
  45971. testOnPointerDownOnly?: boolean;
  45972. /**
  45973. * The node to use to transform the local results to world coordinates
  45974. */
  45975. worldParentNode?: TransformNode;
  45976. }
  45977. /**
  45978. * Interface defining the babylon result of raycasting/hit-test
  45979. */
  45980. export interface IWebXRHitResult {
  45981. /**
  45982. * The native hit test result
  45983. */
  45984. xrHitResult: XRHitResult;
  45985. /**
  45986. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45987. */
  45988. transformationMatrix: Matrix;
  45989. }
  45990. /**
  45991. * The currently-working hit-test module.
  45992. * Hit test (or raycasting) is used to interact with the real world.
  45993. * For further information read here - https://github.com/immersive-web/hit-test
  45994. */
  45995. export class WebXRHitTestLegacy implements IWebXRFeature {
  45996. private _xrSessionManager;
  45997. /**
  45998. * options to use when constructing this feature
  45999. */
  46000. readonly options: IWebXRHitTestOptions;
  46001. /**
  46002. * The module's name
  46003. */
  46004. static readonly Name: string;
  46005. /**
  46006. * The (Babylon) version of this module.
  46007. * This is an integer representing the implementation version.
  46008. * This number does not correspond to the webxr specs version
  46009. */
  46010. static readonly Version: number;
  46011. /**
  46012. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  46013. * @param event the (select) event to use to select with
  46014. * @param referenceSpace the reference space to use for this hit test
  46015. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  46016. */
  46017. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  46018. /**
  46019. * execute a hit test with an XR Ray
  46020. *
  46021. * @param xrSession a native xrSession that will execute this hit test
  46022. * @param xrRay the ray (position and direction) to use for raycasting
  46023. * @param referenceSpace native XR reference space to use for the hit-test
  46024. * @param filter filter function that will filter the results
  46025. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  46026. */
  46027. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  46028. /**
  46029. * Triggered when new babylon (transformed) hit test results are available
  46030. */
  46031. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  46032. /**
  46033. * Creates a new instance of the (legacy version) hit test feature
  46034. * @param _xrSessionManager an instance of WebXRSessionManager
  46035. * @param options options to use when constructing this feature
  46036. */
  46037. constructor(_xrSessionManager: WebXRSessionManager,
  46038. /**
  46039. * options to use when constructing this feature
  46040. */
  46041. options?: IWebXRHitTestOptions);
  46042. private _onSelectEnabled;
  46043. private _xrFrameObserver;
  46044. private _attached;
  46045. /**
  46046. * Populated with the last native XR Hit Results
  46047. */
  46048. lastNativeXRHitResults: XRHitResult[];
  46049. /**
  46050. * attach this feature
  46051. * Will usually be called by the features manager
  46052. *
  46053. * @returns true if successful.
  46054. */
  46055. attach(): boolean;
  46056. /**
  46057. * detach this feature.
  46058. * Will usually be called by the features manager
  46059. *
  46060. * @returns true if successful.
  46061. */
  46062. detach(): boolean;
  46063. private _onHitTestResults;
  46064. private _onSelect;
  46065. /**
  46066. * Dispose this feature and all of the resources attached
  46067. */
  46068. dispose(): void;
  46069. }
  46070. }
  46071. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  46072. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46074. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46075. import { Observable } from "babylonjs/Misc/observable";
  46076. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  46077. /**
  46078. * Options used in the plane detector module
  46079. */
  46080. export interface IWebXRPlaneDetectorOptions {
  46081. /**
  46082. * The node to use to transform the local results to world coordinates
  46083. */
  46084. worldParentNode?: TransformNode;
  46085. }
  46086. /**
  46087. * A babylon interface for a webxr plane.
  46088. * A Plane is actually a polygon, built from N points in space
  46089. */
  46090. export interface IWebXRPlane {
  46091. /**
  46092. * a babylon-assigned ID for this polygon
  46093. */
  46094. id: number;
  46095. /**
  46096. * the native xr-plane object
  46097. */
  46098. xrPlane: XRPlane;
  46099. /**
  46100. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  46101. */
  46102. polygonDefinition: Array<Vector3>;
  46103. /**
  46104. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  46105. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  46106. */
  46107. transformationMatrix: Matrix;
  46108. }
  46109. /**
  46110. * The plane detector is used to detect planes in the real world when in AR
  46111. * For more information see https://github.com/immersive-web/real-world-geometry/
  46112. */
  46113. export class WebXRPlaneDetector implements IWebXRFeature {
  46114. private _xrSessionManager;
  46115. private _options;
  46116. /**
  46117. * The module's name
  46118. */
  46119. static readonly Name: string;
  46120. /**
  46121. * The (Babylon) version of this module.
  46122. * This is an integer representing the implementation version.
  46123. * This number does not correspond to the webxr specs version
  46124. */
  46125. static readonly Version: number;
  46126. /**
  46127. * Observers registered here will be executed when a new plane was added to the session
  46128. */
  46129. onPlaneAddedObservable: Observable<IWebXRPlane>;
  46130. /**
  46131. * Observers registered here will be executed when a plane is no longer detected in the session
  46132. */
  46133. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  46134. /**
  46135. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  46136. * This can execute N times every frame
  46137. */
  46138. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  46139. private _enabled;
  46140. private _attached;
  46141. private _detectedPlanes;
  46142. private _lastFrameDetected;
  46143. private _observerTracked;
  46144. /**
  46145. * construct a new Plane Detector
  46146. * @param _xrSessionManager an instance of xr Session manager
  46147. * @param _options configuration to use when constructing this feature
  46148. */
  46149. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  46150. /**
  46151. * attach this feature
  46152. * Will usually be called by the features manager
  46153. *
  46154. * @returns true if successful.
  46155. */
  46156. attach(): boolean;
  46157. /**
  46158. * detach this feature.
  46159. * Will usually be called by the features manager
  46160. *
  46161. * @returns true if successful.
  46162. */
  46163. detach(): boolean;
  46164. /**
  46165. * Dispose this feature and all of the resources attached
  46166. */
  46167. dispose(): void;
  46168. private _updatePlaneWithXRPlane;
  46169. /**
  46170. * avoiding using Array.find for global support.
  46171. * @param xrPlane the plane to find in the array
  46172. */
  46173. private findIndexInPlaneArray;
  46174. }
  46175. }
  46176. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  46177. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46178. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46179. import { Observable } from "babylonjs/Misc/observable";
  46180. import { Matrix } from "babylonjs/Maths/math.vector";
  46181. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46182. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46183. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46184. /**
  46185. * Configuration options of the anchor system
  46186. */
  46187. export interface IWebXRAnchorSystemOptions {
  46188. /**
  46189. * a node that will be used to convert local to world coordinates
  46190. */
  46191. worldParentNode?: TransformNode;
  46192. /**
  46193. * should the anchor system use plane detection.
  46194. * If set to true, the plane-detection feature should be set using setPlaneDetector
  46195. */
  46196. usePlaneDetection?: boolean;
  46197. /**
  46198. * Should a new anchor be added every time a select event is triggered
  46199. */
  46200. addAnchorOnSelect?: boolean;
  46201. }
  46202. /**
  46203. * A babylon container for an XR Anchor
  46204. */
  46205. export interface IWebXRAnchor {
  46206. /**
  46207. * A babylon-assigned ID for this anchor
  46208. */
  46209. id: number;
  46210. /**
  46211. * The native anchor object
  46212. */
  46213. xrAnchor: XRAnchor;
  46214. /**
  46215. * Transformation matrix to apply to an object attached to this anchor
  46216. */
  46217. transformationMatrix: Matrix;
  46218. }
  46219. /**
  46220. * An implementation of the anchor system of WebXR.
  46221. * Note that the current documented implementation is not available in any browser. Future implementations
  46222. * will use the frame to create an anchor and not the session or a detected plane
  46223. * For further information see https://github.com/immersive-web/anchors/
  46224. */
  46225. export class WebXRAnchorSystem implements IWebXRFeature {
  46226. private _xrSessionManager;
  46227. private _options;
  46228. /**
  46229. * The module's name
  46230. */
  46231. static readonly Name: string;
  46232. /**
  46233. * The (Babylon) version of this module.
  46234. * This is an integer representing the implementation version.
  46235. * This number does not correspond to the webxr specs version
  46236. */
  46237. static readonly Version: number;
  46238. /**
  46239. * Observers registered here will be executed when a new anchor was added to the session
  46240. */
  46241. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  46242. /**
  46243. * Observers registered here will be executed when an existing anchor updates
  46244. * This can execute N times every frame
  46245. */
  46246. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  46247. /**
  46248. * Observers registered here will be executed when an anchor was removed from the session
  46249. */
  46250. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  46251. private _planeDetector;
  46252. private _hitTestModule;
  46253. private _enabled;
  46254. private _attached;
  46255. private _trackedAnchors;
  46256. private _lastFrameDetected;
  46257. private _observerTracked;
  46258. /**
  46259. * constructs a new anchor system
  46260. * @param _xrSessionManager an instance of WebXRSessionManager
  46261. * @param _options configuration object for this feature
  46262. */
  46263. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46264. /**
  46265. * set the plane detector to use in order to create anchors from frames
  46266. * @param planeDetector the plane-detector module to use
  46267. * @param enable enable plane-anchors. default is true
  46268. */
  46269. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46270. /**
  46271. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46272. * @param hitTestModule the hit-test module to use.
  46273. */
  46274. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46275. /**
  46276. * attach this feature
  46277. * Will usually be called by the features manager
  46278. *
  46279. * @returns true if successful.
  46280. */
  46281. attach(): boolean;
  46282. /**
  46283. * detach this feature.
  46284. * Will usually be called by the features manager
  46285. *
  46286. * @returns true if successful.
  46287. */
  46288. detach(): boolean;
  46289. /**
  46290. * Dispose this feature and all of the resources attached
  46291. */
  46292. dispose(): void;
  46293. private _onSelect;
  46294. /**
  46295. * Add anchor at a specific XR point.
  46296. *
  46297. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46298. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46299. * @returns a promise the fulfills when the anchor was created
  46300. */
  46301. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46302. private _updateAnchorWithXRFrame;
  46303. /**
  46304. * avoiding using Array.find for global support.
  46305. * @param xrAnchor the plane to find in the array
  46306. */
  46307. private _findIndexInAnchorArray;
  46308. }
  46309. }
  46310. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46311. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46312. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46314. import { Observable } from "babylonjs/Misc/observable";
  46315. /**
  46316. * Options interface for the background remover plugin
  46317. */
  46318. export interface IWebXRBackgroundRemoverOptions {
  46319. /**
  46320. * don't disable the environment helper
  46321. */
  46322. ignoreEnvironmentHelper?: boolean;
  46323. /**
  46324. * flags to configure the removal of the environment helper.
  46325. * If not set, the entire background will be removed. If set, flags should be set as well.
  46326. */
  46327. environmentHelperRemovalFlags?: {
  46328. /**
  46329. * Should the skybox be removed (default false)
  46330. */
  46331. skyBox?: boolean;
  46332. /**
  46333. * Should the ground be removed (default false)
  46334. */
  46335. ground?: boolean;
  46336. };
  46337. /**
  46338. * Further background meshes to disable when entering AR
  46339. */
  46340. backgroundMeshes?: AbstractMesh[];
  46341. }
  46342. /**
  46343. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46344. */
  46345. export class WebXRBackgroundRemover implements IWebXRFeature {
  46346. private _xrSessionManager;
  46347. /**
  46348. * read-only options to be used in this module
  46349. */
  46350. readonly options: IWebXRBackgroundRemoverOptions;
  46351. /**
  46352. * The module's name
  46353. */
  46354. static readonly Name: string;
  46355. /**
  46356. * The (Babylon) version of this module.
  46357. * This is an integer representing the implementation version.
  46358. * This number does not correspond to the webxr specs version
  46359. */
  46360. static readonly Version: number;
  46361. /**
  46362. * registered observers will be triggered when the background state changes
  46363. */
  46364. onBackgroundStateChangedObservable: Observable<boolean>;
  46365. /**
  46366. * constructs a new background remover module
  46367. * @param _xrSessionManager the session manager for this module
  46368. * @param options read-only options to be used in this module
  46369. */
  46370. constructor(_xrSessionManager: WebXRSessionManager,
  46371. /**
  46372. * read-only options to be used in this module
  46373. */
  46374. options?: IWebXRBackgroundRemoverOptions);
  46375. /**
  46376. * attach this feature
  46377. * Will usually be called by the features manager
  46378. *
  46379. * @returns true if successful.
  46380. */
  46381. attach(): boolean;
  46382. /**
  46383. * detach this feature.
  46384. * Will usually be called by the features manager
  46385. *
  46386. * @returns true if successful.
  46387. */
  46388. detach(): boolean;
  46389. private _setBackgroundState;
  46390. /**
  46391. * Dispose this feature and all of the resources attached
  46392. */
  46393. dispose(): void;
  46394. }
  46395. }
  46396. declare module "babylonjs/Cameras/XR/features/index" {
  46397. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46398. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46399. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46400. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46401. }
  46402. declare module "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController" {
  46403. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46405. import { Scene } from "babylonjs/scene";
  46406. /**
  46407. * The motion controller class for all microsoft mixed reality controllers
  46408. */
  46409. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  46410. /**
  46411. * The base url used to load the left and right controller models
  46412. */
  46413. static MODEL_BASE_URL: string;
  46414. /**
  46415. * The name of the left controller model file
  46416. */
  46417. static MODEL_LEFT_FILENAME: string;
  46418. /**
  46419. * The name of the right controller model file
  46420. */
  46421. static MODEL_RIGHT_FILENAME: string;
  46422. profileId: string;
  46423. protected readonly _mapping: {
  46424. defaultButton: {
  46425. "valueNodeName": string;
  46426. "unpressedNodeName": string;
  46427. "pressedNodeName": string;
  46428. };
  46429. defaultAxis: {
  46430. "valueNodeName": string;
  46431. "minNodeName": string;
  46432. "maxNodeName": string;
  46433. };
  46434. buttons: {
  46435. "xr-standard-trigger": {
  46436. "rootNodeName": string;
  46437. "componentProperty": string;
  46438. "states": string[];
  46439. };
  46440. "xr-standard-squeeze": {
  46441. "rootNodeName": string;
  46442. "componentProperty": string;
  46443. "states": string[];
  46444. };
  46445. "xr-standard-touchpad": {
  46446. "rootNodeName": string;
  46447. "labelAnchorNodeName": string;
  46448. "touchPointNodeName": string;
  46449. };
  46450. "xr-standard-thumbstick": {
  46451. "rootNodeName": string;
  46452. "componentProperty": string;
  46453. "states": string[];
  46454. };
  46455. "menu": {
  46456. "rootNodeName": string;
  46457. "componentProperty": string;
  46458. "states": string[];
  46459. };
  46460. };
  46461. axes: {
  46462. "xr-standard-touchpad": {
  46463. "x-axis": {
  46464. "rootNodeName": string;
  46465. };
  46466. "y-axis": {
  46467. "rootNodeName": string;
  46468. };
  46469. };
  46470. "xr-standard-thumbstick": {
  46471. "x-axis": {
  46472. "rootNodeName": string;
  46473. };
  46474. "y-axis": {
  46475. "rootNodeName": string;
  46476. };
  46477. };
  46478. };
  46479. };
  46480. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  46481. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46482. private _getChildByName;
  46483. private _getImmediateChildByName;
  46484. protected _getFilenameAndPath(): {
  46485. filename: string;
  46486. path: string;
  46487. };
  46488. protected _updateModel(): void;
  46489. protected _getModelLoadingConstraints(): boolean;
  46490. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46491. }
  46492. }
  46493. declare module "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController" {
  46494. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46496. import { Scene } from "babylonjs/scene";
  46497. /**
  46498. * The motion controller class for oculus touch (quest, rift).
  46499. * This class supports legacy mapping as well the standard xr mapping
  46500. */
  46501. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  46502. private _forceLegacyControllers;
  46503. /**
  46504. * The base url used to load the left and right controller models
  46505. */
  46506. static MODEL_BASE_URL: string;
  46507. /**
  46508. * The name of the left controller model file
  46509. */
  46510. static MODEL_LEFT_FILENAME: string;
  46511. /**
  46512. * The name of the right controller model file
  46513. */
  46514. static MODEL_RIGHT_FILENAME: string;
  46515. /**
  46516. * Base Url for the Quest controller model.
  46517. */
  46518. static QUEST_MODEL_BASE_URL: string;
  46519. profileId: string;
  46520. private _modelRootNode;
  46521. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  46522. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46523. protected _getFilenameAndPath(): {
  46524. filename: string;
  46525. path: string;
  46526. };
  46527. /**
  46528. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  46529. * between the touch and touch 2.
  46530. */
  46531. private _isQuest;
  46532. protected _updateModel(): void;
  46533. protected _getModelLoadingConstraints(): boolean;
  46534. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46535. }
  46536. }
  46537. declare module "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController" {
  46538. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46539. import { Scene } from "babylonjs/scene";
  46540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46541. /**
  46542. * The motion controller class for the standard HTC-Vive controllers
  46543. */
  46544. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  46545. /**
  46546. * The base url used to load the left and right controller models
  46547. */
  46548. static MODEL_BASE_URL: string;
  46549. /**
  46550. * File name for the controller model.
  46551. */
  46552. static MODEL_FILENAME: string;
  46553. profileId: string;
  46554. private _modelRootNode;
  46555. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  46556. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46557. protected _getFilenameAndPath(): {
  46558. filename: string;
  46559. path: string;
  46560. };
  46561. protected _updateModel(): void;
  46562. protected _getModelLoadingConstraints(): boolean;
  46563. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46564. }
  46565. }
  46566. declare module "babylonjs/Cameras/XR/motionController/index" {
  46567. export * from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46568. export * from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  46569. export * from "babylonjs/Cameras/XR/motionController/webXRGenericMotionController";
  46570. export * from "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController";
  46571. export * from "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager";
  46572. export * from "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController";
  46573. export * from "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController";
  46574. }
  46575. declare module "babylonjs/Cameras/XR/index" {
  46576. export * from "babylonjs/Cameras/XR/webXRCamera";
  46577. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  46578. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46579. export * from "babylonjs/Cameras/XR/webXRInput";
  46580. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  46581. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  46582. export * from "babylonjs/Cameras/XR/webXRController";
  46583. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  46584. export * from "babylonjs/Cameras/XR/webXRTypes";
  46585. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  46586. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46587. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46588. export * from "babylonjs/Cameras/XR/features/index";
  46589. export * from "babylonjs/Cameras/XR/motionController/index";
  46590. }
  46591. declare module "babylonjs/Cameras/RigModes/index" {
  46592. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46593. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46594. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46595. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46596. }
  46597. declare module "babylonjs/Cameras/index" {
  46598. export * from "babylonjs/Cameras/Inputs/index";
  46599. export * from "babylonjs/Cameras/cameraInputsManager";
  46600. export * from "babylonjs/Cameras/camera";
  46601. export * from "babylonjs/Cameras/targetCamera";
  46602. export * from "babylonjs/Cameras/freeCamera";
  46603. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46604. export * from "babylonjs/Cameras/touchCamera";
  46605. export * from "babylonjs/Cameras/arcRotateCamera";
  46606. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46607. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46608. export * from "babylonjs/Cameras/flyCamera";
  46609. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46610. export * from "babylonjs/Cameras/followCamera";
  46611. export * from "babylonjs/Cameras/followCameraInputsManager";
  46612. export * from "babylonjs/Cameras/gamepadCamera";
  46613. export * from "babylonjs/Cameras/Stereoscopic/index";
  46614. export * from "babylonjs/Cameras/universalCamera";
  46615. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46616. export * from "babylonjs/Cameras/VR/index";
  46617. export * from "babylonjs/Cameras/XR/index";
  46618. export * from "babylonjs/Cameras/RigModes/index";
  46619. }
  46620. declare module "babylonjs/Collisions/index" {
  46621. export * from "babylonjs/Collisions/collider";
  46622. export * from "babylonjs/Collisions/collisionCoordinator";
  46623. export * from "babylonjs/Collisions/pickingInfo";
  46624. export * from "babylonjs/Collisions/intersectionInfo";
  46625. export * from "babylonjs/Collisions/meshCollisionData";
  46626. }
  46627. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46628. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46629. import { Vector3 } from "babylonjs/Maths/math.vector";
  46630. import { Ray } from "babylonjs/Culling/ray";
  46631. import { Plane } from "babylonjs/Maths/math.plane";
  46632. /**
  46633. * Contains an array of blocks representing the octree
  46634. */
  46635. export interface IOctreeContainer<T> {
  46636. /**
  46637. * Blocks within the octree
  46638. */
  46639. blocks: Array<OctreeBlock<T>>;
  46640. }
  46641. /**
  46642. * Class used to store a cell in an octree
  46643. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46644. */
  46645. export class OctreeBlock<T> {
  46646. /**
  46647. * Gets the content of the current block
  46648. */
  46649. entries: T[];
  46650. /**
  46651. * Gets the list of block children
  46652. */
  46653. blocks: Array<OctreeBlock<T>>;
  46654. private _depth;
  46655. private _maxDepth;
  46656. private _capacity;
  46657. private _minPoint;
  46658. private _maxPoint;
  46659. private _boundingVectors;
  46660. private _creationFunc;
  46661. /**
  46662. * Creates a new block
  46663. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46664. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46665. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46666. * @param depth defines the current depth of this block in the octree
  46667. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46668. * @param creationFunc defines a callback to call when an element is added to the block
  46669. */
  46670. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46671. /**
  46672. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46673. */
  46674. get capacity(): number;
  46675. /**
  46676. * Gets the minimum vector (in world space) of the block's bounding box
  46677. */
  46678. get minPoint(): Vector3;
  46679. /**
  46680. * Gets the maximum vector (in world space) of the block's bounding box
  46681. */
  46682. get maxPoint(): Vector3;
  46683. /**
  46684. * Add a new element to this block
  46685. * @param entry defines the element to add
  46686. */
  46687. addEntry(entry: T): void;
  46688. /**
  46689. * Remove an element from this block
  46690. * @param entry defines the element to remove
  46691. */
  46692. removeEntry(entry: T): void;
  46693. /**
  46694. * Add an array of elements to this block
  46695. * @param entries defines the array of elements to add
  46696. */
  46697. addEntries(entries: T[]): void;
  46698. /**
  46699. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46700. * @param frustumPlanes defines the frustum planes to test
  46701. * @param selection defines the array to store current content if selection is positive
  46702. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46703. */
  46704. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46705. /**
  46706. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46707. * @param sphereCenter defines the bounding sphere center
  46708. * @param sphereRadius defines the bounding sphere radius
  46709. * @param selection defines the array to store current content if selection is positive
  46710. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46711. */
  46712. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46713. /**
  46714. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46715. * @param ray defines the ray to test with
  46716. * @param selection defines the array to store current content if selection is positive
  46717. */
  46718. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46719. /**
  46720. * Subdivide the content into child blocks (this block will then be empty)
  46721. */
  46722. createInnerBlocks(): void;
  46723. /**
  46724. * @hidden
  46725. */
  46726. 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;
  46727. }
  46728. }
  46729. declare module "babylonjs/Culling/Octrees/octree" {
  46730. import { SmartArray } from "babylonjs/Misc/smartArray";
  46731. import { Vector3 } from "babylonjs/Maths/math.vector";
  46732. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46734. import { Ray } from "babylonjs/Culling/ray";
  46735. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46736. import { Plane } from "babylonjs/Maths/math.plane";
  46737. /**
  46738. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46739. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46740. */
  46741. export class Octree<T> {
  46742. /** 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.) */
  46743. maxDepth: number;
  46744. /**
  46745. * Blocks within the octree containing objects
  46746. */
  46747. blocks: Array<OctreeBlock<T>>;
  46748. /**
  46749. * Content stored in the octree
  46750. */
  46751. dynamicContent: T[];
  46752. private _maxBlockCapacity;
  46753. private _selectionContent;
  46754. private _creationFunc;
  46755. /**
  46756. * Creates a octree
  46757. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46758. * @param creationFunc function to be used to instatiate the octree
  46759. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46760. * @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.)
  46761. */
  46762. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46763. /** 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.) */
  46764. maxDepth?: number);
  46765. /**
  46766. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46767. * @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);
  46768. * @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);
  46769. * @param entries meshes to be added to the octree blocks
  46770. */
  46771. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46772. /**
  46773. * Adds a mesh to the octree
  46774. * @param entry Mesh to add to the octree
  46775. */
  46776. addMesh(entry: T): void;
  46777. /**
  46778. * Remove an element from the octree
  46779. * @param entry defines the element to remove
  46780. */
  46781. removeMesh(entry: T): void;
  46782. /**
  46783. * Selects an array of meshes within the frustum
  46784. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46785. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46786. * @returns array of meshes within the frustum
  46787. */
  46788. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46789. /**
  46790. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46791. * @param sphereCenter defines the bounding sphere center
  46792. * @param sphereRadius defines the bounding sphere radius
  46793. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46794. * @returns an array of objects that intersect the sphere
  46795. */
  46796. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46797. /**
  46798. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46799. * @param ray defines the ray to test with
  46800. * @returns array of intersected objects
  46801. */
  46802. intersectsRay(ray: Ray): SmartArray<T>;
  46803. /**
  46804. * Adds a mesh into the octree block if it intersects the block
  46805. */
  46806. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46807. /**
  46808. * Adds a submesh into the octree block if it intersects the block
  46809. */
  46810. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46811. }
  46812. }
  46813. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  46814. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  46815. import { Scene } from "babylonjs/scene";
  46816. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46818. import { Ray } from "babylonjs/Culling/ray";
  46819. import { Octree } from "babylonjs/Culling/Octrees/octree";
  46820. import { Collider } from "babylonjs/Collisions/collider";
  46821. module "babylonjs/scene" {
  46822. interface Scene {
  46823. /**
  46824. * @hidden
  46825. * Backing Filed
  46826. */
  46827. _selectionOctree: Octree<AbstractMesh>;
  46828. /**
  46829. * Gets the octree used to boost mesh selection (picking)
  46830. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46831. */
  46832. selectionOctree: Octree<AbstractMesh>;
  46833. /**
  46834. * Creates or updates the octree used to boost selection (picking)
  46835. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46836. * @param maxCapacity defines the maximum capacity per leaf
  46837. * @param maxDepth defines the maximum depth of the octree
  46838. * @returns an octree of AbstractMesh
  46839. */
  46840. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46841. }
  46842. }
  46843. module "babylonjs/Meshes/abstractMesh" {
  46844. interface AbstractMesh {
  46845. /**
  46846. * @hidden
  46847. * Backing Field
  46848. */
  46849. _submeshesOctree: Octree<SubMesh>;
  46850. /**
  46851. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46852. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46853. * @param maxCapacity defines the maximum size of each block (64 by default)
  46854. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46855. * @returns the new octree
  46856. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46857. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46858. */
  46859. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46860. }
  46861. }
  46862. /**
  46863. * Defines the octree scene component responsible to manage any octrees
  46864. * in a given scene.
  46865. */
  46866. export class OctreeSceneComponent {
  46867. /**
  46868. * The component name help to identify the component in the list of scene components.
  46869. */
  46870. readonly name: string;
  46871. /**
  46872. * The scene the component belongs to.
  46873. */
  46874. scene: Scene;
  46875. /**
  46876. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46877. */
  46878. readonly checksIsEnabled: boolean;
  46879. /**
  46880. * Creates a new instance of the component for the given scene
  46881. * @param scene Defines the scene to register the component in
  46882. */
  46883. constructor(scene: Scene);
  46884. /**
  46885. * Registers the component in a given scene
  46886. */
  46887. register(): void;
  46888. /**
  46889. * Return the list of active meshes
  46890. * @returns the list of active meshes
  46891. */
  46892. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46893. /**
  46894. * Return the list of active sub meshes
  46895. * @param mesh The mesh to get the candidates sub meshes from
  46896. * @returns the list of active sub meshes
  46897. */
  46898. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46899. private _tempRay;
  46900. /**
  46901. * Return the list of sub meshes intersecting with a given local ray
  46902. * @param mesh defines the mesh to find the submesh for
  46903. * @param localRay defines the ray in local space
  46904. * @returns the list of intersecting sub meshes
  46905. */
  46906. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46907. /**
  46908. * Return the list of sub meshes colliding with a collider
  46909. * @param mesh defines the mesh to find the submesh for
  46910. * @param collider defines the collider to evaluate the collision against
  46911. * @returns the list of colliding sub meshes
  46912. */
  46913. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46914. /**
  46915. * Rebuilds the elements related to this component in case of
  46916. * context lost for instance.
  46917. */
  46918. rebuild(): void;
  46919. /**
  46920. * Disposes the component and the associated ressources.
  46921. */
  46922. dispose(): void;
  46923. }
  46924. }
  46925. declare module "babylonjs/Culling/Octrees/index" {
  46926. export * from "babylonjs/Culling/Octrees/octree";
  46927. export * from "babylonjs/Culling/Octrees/octreeBlock";
  46928. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  46929. }
  46930. declare module "babylonjs/Culling/index" {
  46931. export * from "babylonjs/Culling/boundingBox";
  46932. export * from "babylonjs/Culling/boundingInfo";
  46933. export * from "babylonjs/Culling/boundingSphere";
  46934. export * from "babylonjs/Culling/Octrees/index";
  46935. export * from "babylonjs/Culling/ray";
  46936. }
  46937. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46938. import { IDisposable, Scene } from "babylonjs/scene";
  46939. import { Nullable } from "babylonjs/types";
  46940. import { Observable } from "babylonjs/Misc/observable";
  46941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46942. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46943. import { Camera } from "babylonjs/Cameras/camera";
  46944. /**
  46945. * Renders a layer on top of an existing scene
  46946. */
  46947. export class UtilityLayerRenderer implements IDisposable {
  46948. /** the original scene that will be rendered on top of */
  46949. originalScene: Scene;
  46950. private _pointerCaptures;
  46951. private _lastPointerEvents;
  46952. private static _DefaultUtilityLayer;
  46953. private static _DefaultKeepDepthUtilityLayer;
  46954. private _sharedGizmoLight;
  46955. private _renderCamera;
  46956. /**
  46957. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46958. * @returns the camera that is used when rendering the utility layer
  46959. */
  46960. getRenderCamera(): Nullable<Camera>;
  46961. /**
  46962. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46963. * @param cam the camera that should be used when rendering the utility layer
  46964. */
  46965. setRenderCamera(cam: Nullable<Camera>): void;
  46966. /**
  46967. * @hidden
  46968. * Light which used by gizmos to get light shading
  46969. */
  46970. _getSharedGizmoLight(): HemisphericLight;
  46971. /**
  46972. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46973. */
  46974. pickUtilitySceneFirst: boolean;
  46975. /**
  46976. * 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)
  46977. */
  46978. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46979. /**
  46980. * 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)
  46981. */
  46982. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46983. /**
  46984. * The scene that is rendered on top of the original scene
  46985. */
  46986. utilityLayerScene: Scene;
  46987. /**
  46988. * If the utility layer should automatically be rendered on top of existing scene
  46989. */
  46990. shouldRender: boolean;
  46991. /**
  46992. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46993. */
  46994. onlyCheckPointerDownEvents: boolean;
  46995. /**
  46996. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46997. */
  46998. processAllEvents: boolean;
  46999. /**
  47000. * Observable raised when the pointer move from the utility layer scene to the main scene
  47001. */
  47002. onPointerOutObservable: Observable<number>;
  47003. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47004. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47005. private _afterRenderObserver;
  47006. private _sceneDisposeObserver;
  47007. private _originalPointerObserver;
  47008. /**
  47009. * Instantiates a UtilityLayerRenderer
  47010. * @param originalScene the original scene that will be rendered on top of
  47011. * @param handleEvents boolean indicating if the utility layer should handle events
  47012. */
  47013. constructor(
  47014. /** the original scene that will be rendered on top of */
  47015. originalScene: Scene, handleEvents?: boolean);
  47016. private _notifyObservers;
  47017. /**
  47018. * Renders the utility layers scene on top of the original scene
  47019. */
  47020. render(): void;
  47021. /**
  47022. * Disposes of the renderer
  47023. */
  47024. dispose(): void;
  47025. private _updateCamera;
  47026. }
  47027. }
  47028. declare module "babylonjs/Gizmos/gizmo" {
  47029. import { Nullable } from "babylonjs/types";
  47030. import { IDisposable } from "babylonjs/scene";
  47031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47032. import { Mesh } from "babylonjs/Meshes/mesh";
  47033. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47034. /**
  47035. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47036. */
  47037. export class Gizmo implements IDisposable {
  47038. /** The utility layer the gizmo will be added to */
  47039. gizmoLayer: UtilityLayerRenderer;
  47040. /**
  47041. * The root mesh of the gizmo
  47042. */
  47043. _rootMesh: Mesh;
  47044. private _attachedMesh;
  47045. /**
  47046. * Ratio for the scale of the gizmo (Default: 1)
  47047. */
  47048. scaleRatio: number;
  47049. /**
  47050. * If a custom mesh has been set (Default: false)
  47051. */
  47052. protected _customMeshSet: boolean;
  47053. /**
  47054. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47055. * * When set, interactions will be enabled
  47056. */
  47057. get attachedMesh(): Nullable<AbstractMesh>;
  47058. set attachedMesh(value: Nullable<AbstractMesh>);
  47059. /**
  47060. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47061. * @param mesh The mesh to replace the default mesh of the gizmo
  47062. */
  47063. setCustomMesh(mesh: Mesh): void;
  47064. /**
  47065. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47066. */
  47067. updateGizmoRotationToMatchAttachedMesh: boolean;
  47068. /**
  47069. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47070. */
  47071. updateGizmoPositionToMatchAttachedMesh: boolean;
  47072. /**
  47073. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47074. */
  47075. updateScale: boolean;
  47076. protected _interactionsEnabled: boolean;
  47077. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47078. private _beforeRenderObserver;
  47079. private _tempVector;
  47080. /**
  47081. * Creates a gizmo
  47082. * @param gizmoLayer The utility layer the gizmo will be added to
  47083. */
  47084. constructor(
  47085. /** The utility layer the gizmo will be added to */
  47086. gizmoLayer?: UtilityLayerRenderer);
  47087. /**
  47088. * Updates the gizmo to match the attached mesh's position/rotation
  47089. */
  47090. protected _update(): void;
  47091. /**
  47092. * Disposes of the gizmo
  47093. */
  47094. dispose(): void;
  47095. }
  47096. }
  47097. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47098. import { Observable } from "babylonjs/Misc/observable";
  47099. import { Nullable } from "babylonjs/types";
  47100. import { Vector3 } from "babylonjs/Maths/math.vector";
  47101. import { Color3 } from "babylonjs/Maths/math.color";
  47102. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47104. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47105. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47106. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47107. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47108. import { Scene } from "babylonjs/scene";
  47109. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47110. /**
  47111. * Single plane drag gizmo
  47112. */
  47113. export class PlaneDragGizmo extends Gizmo {
  47114. /**
  47115. * Drag behavior responsible for the gizmos dragging interactions
  47116. */
  47117. dragBehavior: PointerDragBehavior;
  47118. private _pointerObserver;
  47119. /**
  47120. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47121. */
  47122. snapDistance: number;
  47123. /**
  47124. * Event that fires each time the gizmo snaps to a new location.
  47125. * * snapDistance is the the change in distance
  47126. */
  47127. onSnapObservable: Observable<{
  47128. snapDistance: number;
  47129. }>;
  47130. private _plane;
  47131. private _coloredMaterial;
  47132. private _hoverMaterial;
  47133. private _isEnabled;
  47134. private _parent;
  47135. /** @hidden */
  47136. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47137. /** @hidden */
  47138. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47139. /**
  47140. * Creates a PlaneDragGizmo
  47141. * @param gizmoLayer The utility layer the gizmo will be added to
  47142. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47143. * @param color The color of the gizmo
  47144. */
  47145. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47146. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47147. /**
  47148. * If the gizmo is enabled
  47149. */
  47150. set isEnabled(value: boolean);
  47151. get isEnabled(): boolean;
  47152. /**
  47153. * Disposes of the gizmo
  47154. */
  47155. dispose(): void;
  47156. }
  47157. }
  47158. declare module "babylonjs/Gizmos/positionGizmo" {
  47159. import { Observable } from "babylonjs/Misc/observable";
  47160. import { Nullable } from "babylonjs/types";
  47161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47162. import { Mesh } from "babylonjs/Meshes/mesh";
  47163. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47164. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47165. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47166. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47167. /**
  47168. * Gizmo that enables dragging a mesh along 3 axis
  47169. */
  47170. export class PositionGizmo extends Gizmo {
  47171. /**
  47172. * Internal gizmo used for interactions on the x axis
  47173. */
  47174. xGizmo: AxisDragGizmo;
  47175. /**
  47176. * Internal gizmo used for interactions on the y axis
  47177. */
  47178. yGizmo: AxisDragGizmo;
  47179. /**
  47180. * Internal gizmo used for interactions on the z axis
  47181. */
  47182. zGizmo: AxisDragGizmo;
  47183. /**
  47184. * Internal gizmo used for interactions on the yz plane
  47185. */
  47186. xPlaneGizmo: PlaneDragGizmo;
  47187. /**
  47188. * Internal gizmo used for interactions on the xz plane
  47189. */
  47190. yPlaneGizmo: PlaneDragGizmo;
  47191. /**
  47192. * Internal gizmo used for interactions on the xy plane
  47193. */
  47194. zPlaneGizmo: PlaneDragGizmo;
  47195. /**
  47196. * private variables
  47197. */
  47198. private _meshAttached;
  47199. private _updateGizmoRotationToMatchAttachedMesh;
  47200. private _snapDistance;
  47201. private _scaleRatio;
  47202. /** Fires an event when any of it's sub gizmos are dragged */
  47203. onDragStartObservable: Observable<unknown>;
  47204. /** Fires an event when any of it's sub gizmos are released from dragging */
  47205. onDragEndObservable: Observable<unknown>;
  47206. /**
  47207. * If set to true, planar drag is enabled
  47208. */
  47209. private _planarGizmoEnabled;
  47210. get attachedMesh(): Nullable<AbstractMesh>;
  47211. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47212. /**
  47213. * Creates a PositionGizmo
  47214. * @param gizmoLayer The utility layer the gizmo will be added to
  47215. */
  47216. constructor(gizmoLayer?: UtilityLayerRenderer);
  47217. /**
  47218. * If the planar drag gizmo is enabled
  47219. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47220. */
  47221. set planarGizmoEnabled(value: boolean);
  47222. get planarGizmoEnabled(): boolean;
  47223. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47224. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47225. /**
  47226. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47227. */
  47228. set snapDistance(value: number);
  47229. get snapDistance(): number;
  47230. /**
  47231. * Ratio for the scale of the gizmo (Default: 1)
  47232. */
  47233. set scaleRatio(value: number);
  47234. get scaleRatio(): number;
  47235. /**
  47236. * Disposes of the gizmo
  47237. */
  47238. dispose(): void;
  47239. /**
  47240. * CustomMeshes are not supported by this gizmo
  47241. * @param mesh The mesh to replace the default mesh of the gizmo
  47242. */
  47243. setCustomMesh(mesh: Mesh): void;
  47244. }
  47245. }
  47246. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47247. import { Observable } from "babylonjs/Misc/observable";
  47248. import { Nullable } from "babylonjs/types";
  47249. import { Vector3 } from "babylonjs/Maths/math.vector";
  47250. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47252. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47253. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47254. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47255. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47256. import { Scene } from "babylonjs/scene";
  47257. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47258. import { Color3 } from "babylonjs/Maths/math.color";
  47259. /**
  47260. * Single axis drag gizmo
  47261. */
  47262. export class AxisDragGizmo extends Gizmo {
  47263. /**
  47264. * Drag behavior responsible for the gizmos dragging interactions
  47265. */
  47266. dragBehavior: PointerDragBehavior;
  47267. private _pointerObserver;
  47268. /**
  47269. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47270. */
  47271. snapDistance: number;
  47272. /**
  47273. * Event that fires each time the gizmo snaps to a new location.
  47274. * * snapDistance is the the change in distance
  47275. */
  47276. onSnapObservable: Observable<{
  47277. snapDistance: number;
  47278. }>;
  47279. private _isEnabled;
  47280. private _parent;
  47281. private _arrow;
  47282. private _coloredMaterial;
  47283. private _hoverMaterial;
  47284. /** @hidden */
  47285. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47286. /** @hidden */
  47287. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47288. /**
  47289. * Creates an AxisDragGizmo
  47290. * @param gizmoLayer The utility layer the gizmo will be added to
  47291. * @param dragAxis The axis which the gizmo will be able to drag on
  47292. * @param color The color of the gizmo
  47293. */
  47294. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47295. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47296. /**
  47297. * If the gizmo is enabled
  47298. */
  47299. set isEnabled(value: boolean);
  47300. get isEnabled(): boolean;
  47301. /**
  47302. * Disposes of the gizmo
  47303. */
  47304. dispose(): void;
  47305. }
  47306. }
  47307. declare module "babylonjs/Debug/axesViewer" {
  47308. import { Vector3 } from "babylonjs/Maths/math.vector";
  47309. import { Nullable } from "babylonjs/types";
  47310. import { Scene } from "babylonjs/scene";
  47311. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47312. /**
  47313. * The Axes viewer will show 3 axes in a specific point in space
  47314. */
  47315. export class AxesViewer {
  47316. private _xAxis;
  47317. private _yAxis;
  47318. private _zAxis;
  47319. private _scaleLinesFactor;
  47320. private _instanced;
  47321. /**
  47322. * Gets the hosting scene
  47323. */
  47324. scene: Scene;
  47325. /**
  47326. * Gets or sets a number used to scale line length
  47327. */
  47328. scaleLines: number;
  47329. /** Gets the node hierarchy used to render x-axis */
  47330. get xAxis(): TransformNode;
  47331. /** Gets the node hierarchy used to render y-axis */
  47332. get yAxis(): TransformNode;
  47333. /** Gets the node hierarchy used to render z-axis */
  47334. get zAxis(): TransformNode;
  47335. /**
  47336. * Creates a new AxesViewer
  47337. * @param scene defines the hosting scene
  47338. * @param scaleLines defines a number used to scale line length (1 by default)
  47339. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47340. * @param xAxis defines the node hierarchy used to render the x-axis
  47341. * @param yAxis defines the node hierarchy used to render the y-axis
  47342. * @param zAxis defines the node hierarchy used to render the z-axis
  47343. */
  47344. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47345. /**
  47346. * Force the viewer to update
  47347. * @param position defines the position of the viewer
  47348. * @param xaxis defines the x axis of the viewer
  47349. * @param yaxis defines the y axis of the viewer
  47350. * @param zaxis defines the z axis of the viewer
  47351. */
  47352. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47353. /**
  47354. * Creates an instance of this axes viewer.
  47355. * @returns a new axes viewer with instanced meshes
  47356. */
  47357. createInstance(): AxesViewer;
  47358. /** Releases resources */
  47359. dispose(): void;
  47360. private static _SetRenderingGroupId;
  47361. }
  47362. }
  47363. declare module "babylonjs/Debug/boneAxesViewer" {
  47364. import { Nullable } from "babylonjs/types";
  47365. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47366. import { Vector3 } from "babylonjs/Maths/math.vector";
  47367. import { Mesh } from "babylonjs/Meshes/mesh";
  47368. import { Bone } from "babylonjs/Bones/bone";
  47369. import { Scene } from "babylonjs/scene";
  47370. /**
  47371. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47372. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47373. */
  47374. export class BoneAxesViewer extends AxesViewer {
  47375. /**
  47376. * Gets or sets the target mesh where to display the axes viewer
  47377. */
  47378. mesh: Nullable<Mesh>;
  47379. /**
  47380. * Gets or sets the target bone where to display the axes viewer
  47381. */
  47382. bone: Nullable<Bone>;
  47383. /** Gets current position */
  47384. pos: Vector3;
  47385. /** Gets direction of X axis */
  47386. xaxis: Vector3;
  47387. /** Gets direction of Y axis */
  47388. yaxis: Vector3;
  47389. /** Gets direction of Z axis */
  47390. zaxis: Vector3;
  47391. /**
  47392. * Creates a new BoneAxesViewer
  47393. * @param scene defines the hosting scene
  47394. * @param bone defines the target bone
  47395. * @param mesh defines the target mesh
  47396. * @param scaleLines defines a scaling factor for line length (1 by default)
  47397. */
  47398. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47399. /**
  47400. * Force the viewer to update
  47401. */
  47402. update(): void;
  47403. /** Releases resources */
  47404. dispose(): void;
  47405. }
  47406. }
  47407. declare module "babylonjs/Debug/debugLayer" {
  47408. import { Scene } from "babylonjs/scene";
  47409. /**
  47410. * Interface used to define scene explorer extensibility option
  47411. */
  47412. export interface IExplorerExtensibilityOption {
  47413. /**
  47414. * Define the option label
  47415. */
  47416. label: string;
  47417. /**
  47418. * Defines the action to execute on click
  47419. */
  47420. action: (entity: any) => void;
  47421. }
  47422. /**
  47423. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47424. */
  47425. export interface IExplorerExtensibilityGroup {
  47426. /**
  47427. * Defines a predicate to test if a given type mut be extended
  47428. */
  47429. predicate: (entity: any) => boolean;
  47430. /**
  47431. * Gets the list of options added to a type
  47432. */
  47433. entries: IExplorerExtensibilityOption[];
  47434. }
  47435. /**
  47436. * Interface used to define the options to use to create the Inspector
  47437. */
  47438. export interface IInspectorOptions {
  47439. /**
  47440. * Display in overlay mode (default: false)
  47441. */
  47442. overlay?: boolean;
  47443. /**
  47444. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47445. */
  47446. globalRoot?: HTMLElement;
  47447. /**
  47448. * Display the Scene explorer
  47449. */
  47450. showExplorer?: boolean;
  47451. /**
  47452. * Display the property inspector
  47453. */
  47454. showInspector?: boolean;
  47455. /**
  47456. * Display in embed mode (both panes on the right)
  47457. */
  47458. embedMode?: boolean;
  47459. /**
  47460. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47461. */
  47462. handleResize?: boolean;
  47463. /**
  47464. * Allow the panes to popup (default: true)
  47465. */
  47466. enablePopup?: boolean;
  47467. /**
  47468. * Allow the panes to be closed by users (default: true)
  47469. */
  47470. enableClose?: boolean;
  47471. /**
  47472. * Optional list of extensibility entries
  47473. */
  47474. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47475. /**
  47476. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47477. */
  47478. inspectorURL?: string;
  47479. /**
  47480. * Optional initial tab (default to DebugLayerTab.Properties)
  47481. */
  47482. initialTab?: DebugLayerTab;
  47483. }
  47484. module "babylonjs/scene" {
  47485. interface Scene {
  47486. /**
  47487. * @hidden
  47488. * Backing field
  47489. */
  47490. _debugLayer: DebugLayer;
  47491. /**
  47492. * Gets the debug layer (aka Inspector) associated with the scene
  47493. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47494. */
  47495. debugLayer: DebugLayer;
  47496. }
  47497. }
  47498. /**
  47499. * Enum of inspector action tab
  47500. */
  47501. export enum DebugLayerTab {
  47502. /**
  47503. * Properties tag (default)
  47504. */
  47505. Properties = 0,
  47506. /**
  47507. * Debug tab
  47508. */
  47509. Debug = 1,
  47510. /**
  47511. * Statistics tab
  47512. */
  47513. Statistics = 2,
  47514. /**
  47515. * Tools tab
  47516. */
  47517. Tools = 3,
  47518. /**
  47519. * Settings tab
  47520. */
  47521. Settings = 4
  47522. }
  47523. /**
  47524. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47525. * what is happening in your scene
  47526. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47527. */
  47528. export class DebugLayer {
  47529. /**
  47530. * Define the url to get the inspector script from.
  47531. * By default it uses the babylonjs CDN.
  47532. * @ignoreNaming
  47533. */
  47534. static InspectorURL: string;
  47535. private _scene;
  47536. private BJSINSPECTOR;
  47537. private _onPropertyChangedObservable?;
  47538. /**
  47539. * Observable triggered when a property is changed through the inspector.
  47540. */
  47541. get onPropertyChangedObservable(): any;
  47542. /**
  47543. * Instantiates a new debug layer.
  47544. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47545. * what is happening in your scene
  47546. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47547. * @param scene Defines the scene to inspect
  47548. */
  47549. constructor(scene: Scene);
  47550. /** Creates the inspector window. */
  47551. private _createInspector;
  47552. /**
  47553. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47554. * @param entity defines the entity to select
  47555. * @param lineContainerTitle defines the specific block to highlight
  47556. */
  47557. select(entity: any, lineContainerTitle?: string): void;
  47558. /** Get the inspector from bundle or global */
  47559. private _getGlobalInspector;
  47560. /**
  47561. * Get if the inspector is visible or not.
  47562. * @returns true if visible otherwise, false
  47563. */
  47564. isVisible(): boolean;
  47565. /**
  47566. * Hide the inspector and close its window.
  47567. */
  47568. hide(): void;
  47569. /**
  47570. * Launch the debugLayer.
  47571. * @param config Define the configuration of the inspector
  47572. * @return a promise fulfilled when the debug layer is visible
  47573. */
  47574. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47575. }
  47576. }
  47577. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47578. import { Nullable } from "babylonjs/types";
  47579. import { Scene } from "babylonjs/scene";
  47580. import { Vector4 } from "babylonjs/Maths/math.vector";
  47581. import { Color4 } from "babylonjs/Maths/math.color";
  47582. import { Mesh } from "babylonjs/Meshes/mesh";
  47583. /**
  47584. * Class containing static functions to help procedurally build meshes
  47585. */
  47586. export class BoxBuilder {
  47587. /**
  47588. * Creates a box mesh
  47589. * * The parameter `size` sets the size (float) of each box side (default 1)
  47590. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47591. * * 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)
  47592. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47596. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47597. * @param name defines the name of the mesh
  47598. * @param options defines the options used to create the mesh
  47599. * @param scene defines the hosting scene
  47600. * @returns the box mesh
  47601. */
  47602. static CreateBox(name: string, options: {
  47603. size?: number;
  47604. width?: number;
  47605. height?: number;
  47606. depth?: number;
  47607. faceUV?: Vector4[];
  47608. faceColors?: Color4[];
  47609. sideOrientation?: number;
  47610. frontUVs?: Vector4;
  47611. backUVs?: Vector4;
  47612. wrap?: boolean;
  47613. topBaseAt?: number;
  47614. bottomBaseAt?: number;
  47615. updatable?: boolean;
  47616. }, scene?: Nullable<Scene>): Mesh;
  47617. }
  47618. }
  47619. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  47620. import { Vector4 } from "babylonjs/Maths/math.vector";
  47621. import { Mesh } from "babylonjs/Meshes/mesh";
  47622. import { Scene } from "babylonjs/scene";
  47623. import { Nullable } from "babylonjs/types";
  47624. /**
  47625. * Class containing static functions to help procedurally build meshes
  47626. */
  47627. export class SphereBuilder {
  47628. /**
  47629. * Creates a sphere mesh
  47630. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47631. * * 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`)
  47632. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47633. * * 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
  47634. * * 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)
  47635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47638. * @param name defines the name of the mesh
  47639. * @param options defines the options used to create the mesh
  47640. * @param scene defines the hosting scene
  47641. * @returns the sphere mesh
  47642. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47643. */
  47644. static CreateSphere(name: string, options: {
  47645. segments?: number;
  47646. diameter?: number;
  47647. diameterX?: number;
  47648. diameterY?: number;
  47649. diameterZ?: number;
  47650. arc?: number;
  47651. slice?: number;
  47652. sideOrientation?: number;
  47653. frontUVs?: Vector4;
  47654. backUVs?: Vector4;
  47655. updatable?: boolean;
  47656. }, scene?: Nullable<Scene>): Mesh;
  47657. }
  47658. }
  47659. declare module "babylonjs/Debug/physicsViewer" {
  47660. import { Nullable } from "babylonjs/types";
  47661. import { Scene } from "babylonjs/scene";
  47662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47663. import { Mesh } from "babylonjs/Meshes/mesh";
  47664. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47665. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47666. /**
  47667. * Used to show the physics impostor around the specific mesh
  47668. */
  47669. export class PhysicsViewer {
  47670. /** @hidden */
  47671. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47672. /** @hidden */
  47673. protected _meshes: Array<Nullable<AbstractMesh>>;
  47674. /** @hidden */
  47675. protected _scene: Nullable<Scene>;
  47676. /** @hidden */
  47677. protected _numMeshes: number;
  47678. /** @hidden */
  47679. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47680. private _renderFunction;
  47681. private _utilityLayer;
  47682. private _debugBoxMesh;
  47683. private _debugSphereMesh;
  47684. private _debugCylinderMesh;
  47685. private _debugMaterial;
  47686. private _debugMeshMeshes;
  47687. /**
  47688. * Creates a new PhysicsViewer
  47689. * @param scene defines the hosting scene
  47690. */
  47691. constructor(scene: Scene);
  47692. /** @hidden */
  47693. protected _updateDebugMeshes(): void;
  47694. /**
  47695. * Renders a specified physic impostor
  47696. * @param impostor defines the impostor to render
  47697. * @param targetMesh defines the mesh represented by the impostor
  47698. * @returns the new debug mesh used to render the impostor
  47699. */
  47700. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47701. /**
  47702. * Hides a specified physic impostor
  47703. * @param impostor defines the impostor to hide
  47704. */
  47705. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47706. private _getDebugMaterial;
  47707. private _getDebugBoxMesh;
  47708. private _getDebugSphereMesh;
  47709. private _getDebugCylinderMesh;
  47710. private _getDebugMeshMesh;
  47711. private _getDebugMesh;
  47712. /** Releases all resources */
  47713. dispose(): void;
  47714. }
  47715. }
  47716. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  47717. import { Vector3 } from "babylonjs/Maths/math.vector";
  47718. import { Color4 } from "babylonjs/Maths/math.color";
  47719. import { Nullable } from "babylonjs/types";
  47720. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47721. import { Scene } from "babylonjs/scene";
  47722. /**
  47723. * Class containing static functions to help procedurally build meshes
  47724. */
  47725. export class LinesBuilder {
  47726. /**
  47727. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47728. * * 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
  47729. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47730. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47731. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47732. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47733. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47734. * * 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
  47735. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47738. * @param name defines the name of the new line system
  47739. * @param options defines the options used to create the line system
  47740. * @param scene defines the hosting scene
  47741. * @returns a new line system mesh
  47742. */
  47743. static CreateLineSystem(name: string, options: {
  47744. lines: Vector3[][];
  47745. updatable?: boolean;
  47746. instance?: Nullable<LinesMesh>;
  47747. colors?: Nullable<Color4[][]>;
  47748. useVertexAlpha?: boolean;
  47749. }, scene: Nullable<Scene>): LinesMesh;
  47750. /**
  47751. * Creates a line mesh
  47752. * 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
  47753. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47754. * * The parameter `points` is an array successive Vector3
  47755. * * 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
  47756. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47757. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47758. * * When updating an instance, remember that only point positions can change, not the number of points
  47759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47761. * @param name defines the name of the new line system
  47762. * @param options defines the options used to create the line system
  47763. * @param scene defines the hosting scene
  47764. * @returns a new line mesh
  47765. */
  47766. static CreateLines(name: string, options: {
  47767. points: Vector3[];
  47768. updatable?: boolean;
  47769. instance?: Nullable<LinesMesh>;
  47770. colors?: Color4[];
  47771. useVertexAlpha?: boolean;
  47772. }, scene?: Nullable<Scene>): LinesMesh;
  47773. /**
  47774. * Creates a dashed line mesh
  47775. * * 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
  47776. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47777. * * The parameter `points` is an array successive Vector3
  47778. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47779. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47780. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47781. * * 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
  47782. * * When updating an instance, remember that only point positions can change, not the number of points
  47783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47784. * @param name defines the name of the mesh
  47785. * @param options defines the options used to create the mesh
  47786. * @param scene defines the hosting scene
  47787. * @returns the dashed line mesh
  47788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47789. */
  47790. static CreateDashedLines(name: string, options: {
  47791. points: Vector3[];
  47792. dashSize?: number;
  47793. gapSize?: number;
  47794. dashNb?: number;
  47795. updatable?: boolean;
  47796. instance?: LinesMesh;
  47797. }, scene?: Nullable<Scene>): LinesMesh;
  47798. }
  47799. }
  47800. declare module "babylonjs/Debug/rayHelper" {
  47801. import { Nullable } from "babylonjs/types";
  47802. import { Ray } from "babylonjs/Culling/ray";
  47803. import { Vector3 } from "babylonjs/Maths/math.vector";
  47804. import { Color3 } from "babylonjs/Maths/math.color";
  47805. import { Scene } from "babylonjs/scene";
  47806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47807. import "babylonjs/Meshes/Builders/linesBuilder";
  47808. /**
  47809. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47810. * in order to better appreciate the issue one might have.
  47811. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47812. */
  47813. export class RayHelper {
  47814. /**
  47815. * Defines the ray we are currently tryin to visualize.
  47816. */
  47817. ray: Nullable<Ray>;
  47818. private _renderPoints;
  47819. private _renderLine;
  47820. private _renderFunction;
  47821. private _scene;
  47822. private _updateToMeshFunction;
  47823. private _attachedToMesh;
  47824. private _meshSpaceDirection;
  47825. private _meshSpaceOrigin;
  47826. /**
  47827. * Helper function to create a colored helper in a scene in one line.
  47828. * @param ray Defines the ray we are currently tryin to visualize
  47829. * @param scene Defines the scene the ray is used in
  47830. * @param color Defines the color we want to see the ray in
  47831. * @returns The newly created ray helper.
  47832. */
  47833. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47834. /**
  47835. * Instantiate a new ray helper.
  47836. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47837. * in order to better appreciate the issue one might have.
  47838. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47839. * @param ray Defines the ray we are currently tryin to visualize
  47840. */
  47841. constructor(ray: Ray);
  47842. /**
  47843. * Shows the ray we are willing to debug.
  47844. * @param scene Defines the scene the ray needs to be rendered in
  47845. * @param color Defines the color the ray needs to be rendered in
  47846. */
  47847. show(scene: Scene, color?: Color3): void;
  47848. /**
  47849. * Hides the ray we are debugging.
  47850. */
  47851. hide(): void;
  47852. private _render;
  47853. /**
  47854. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47855. * @param mesh Defines the mesh we want the helper attached to
  47856. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47857. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47858. * @param length Defines the length of the ray
  47859. */
  47860. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47861. /**
  47862. * Detach the ray helper from the mesh it has previously been attached to.
  47863. */
  47864. detachFromMesh(): void;
  47865. private _updateToMesh;
  47866. /**
  47867. * Dispose the helper and release its associated resources.
  47868. */
  47869. dispose(): void;
  47870. }
  47871. }
  47872. declare module "babylonjs/Debug/skeletonViewer" {
  47873. import { Color3 } from "babylonjs/Maths/math.color";
  47874. import { Scene } from "babylonjs/scene";
  47875. import { Nullable } from "babylonjs/types";
  47876. import { Skeleton } from "babylonjs/Bones/skeleton";
  47877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47878. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47879. /**
  47880. * Class used to render a debug view of a given skeleton
  47881. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47882. */
  47883. export class SkeletonViewer {
  47884. /** defines the skeleton to render */
  47885. skeleton: Skeleton;
  47886. /** defines the mesh attached to the skeleton */
  47887. mesh: AbstractMesh;
  47888. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47889. autoUpdateBonesMatrices: boolean;
  47890. /** defines the rendering group id to use with the viewer */
  47891. renderingGroupId: number;
  47892. /** Gets or sets the color used to render the skeleton */
  47893. color: Color3;
  47894. private _scene;
  47895. private _debugLines;
  47896. private _debugMesh;
  47897. private _isEnabled;
  47898. private _renderFunction;
  47899. private _utilityLayer;
  47900. /**
  47901. * Returns the mesh used to render the bones
  47902. */
  47903. get debugMesh(): Nullable<LinesMesh>;
  47904. /**
  47905. * Creates a new SkeletonViewer
  47906. * @param skeleton defines the skeleton to render
  47907. * @param mesh defines the mesh attached to the skeleton
  47908. * @param scene defines the hosting scene
  47909. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47910. * @param renderingGroupId defines the rendering group id to use with the viewer
  47911. */
  47912. constructor(
  47913. /** defines the skeleton to render */
  47914. skeleton: Skeleton,
  47915. /** defines the mesh attached to the skeleton */
  47916. mesh: AbstractMesh, scene: Scene,
  47917. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47918. autoUpdateBonesMatrices?: boolean,
  47919. /** defines the rendering group id to use with the viewer */
  47920. renderingGroupId?: number);
  47921. /** Gets or sets a boolean indicating if the viewer is enabled */
  47922. set isEnabled(value: boolean);
  47923. get isEnabled(): boolean;
  47924. private _getBonePosition;
  47925. private _getLinesForBonesWithLength;
  47926. private _getLinesForBonesNoLength;
  47927. /** Update the viewer to sync with current skeleton state */
  47928. update(): void;
  47929. /** Release associated resources */
  47930. dispose(): void;
  47931. }
  47932. }
  47933. declare module "babylonjs/Debug/index" {
  47934. export * from "babylonjs/Debug/axesViewer";
  47935. export * from "babylonjs/Debug/boneAxesViewer";
  47936. export * from "babylonjs/Debug/debugLayer";
  47937. export * from "babylonjs/Debug/physicsViewer";
  47938. export * from "babylonjs/Debug/rayHelper";
  47939. export * from "babylonjs/Debug/skeletonViewer";
  47940. }
  47941. declare module "babylonjs/Engines/nullEngine" {
  47942. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  47943. import { Scene } from "babylonjs/scene";
  47944. import { Engine } from "babylonjs/Engines/engine";
  47945. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47946. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47948. import { Effect } from "babylonjs/Materials/effect";
  47949. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47950. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47951. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  47952. /**
  47953. * Options to create the null engine
  47954. */
  47955. export class NullEngineOptions {
  47956. /**
  47957. * Render width (Default: 512)
  47958. */
  47959. renderWidth: number;
  47960. /**
  47961. * Render height (Default: 256)
  47962. */
  47963. renderHeight: number;
  47964. /**
  47965. * Texture size (Default: 512)
  47966. */
  47967. textureSize: number;
  47968. /**
  47969. * If delta time between frames should be constant
  47970. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47971. */
  47972. deterministicLockstep: boolean;
  47973. /**
  47974. * Maximum about of steps between frames (Default: 4)
  47975. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47976. */
  47977. lockstepMaxSteps: number;
  47978. }
  47979. /**
  47980. * The null engine class provides support for headless version of babylon.js.
  47981. * This can be used in server side scenario or for testing purposes
  47982. */
  47983. export class NullEngine extends Engine {
  47984. private _options;
  47985. /**
  47986. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47987. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47988. * @returns true if engine is in deterministic lock step mode
  47989. */
  47990. isDeterministicLockStep(): boolean;
  47991. /**
  47992. * Gets the max steps when engine is running in deterministic lock step
  47993. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47994. * @returns the max steps
  47995. */
  47996. getLockstepMaxSteps(): number;
  47997. /**
  47998. * Gets the current hardware scaling level.
  47999. * By default the hardware scaling level is computed from the window device ratio.
  48000. * 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.
  48001. * @returns a number indicating the current hardware scaling level
  48002. */
  48003. getHardwareScalingLevel(): number;
  48004. constructor(options?: NullEngineOptions);
  48005. /**
  48006. * Creates a vertex buffer
  48007. * @param vertices the data for the vertex buffer
  48008. * @returns the new WebGL static buffer
  48009. */
  48010. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48011. /**
  48012. * Creates a new index buffer
  48013. * @param indices defines the content of the index buffer
  48014. * @param updatable defines if the index buffer must be updatable
  48015. * @returns a new webGL buffer
  48016. */
  48017. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48018. /**
  48019. * Clear the current render buffer or the current render target (if any is set up)
  48020. * @param color defines the color to use
  48021. * @param backBuffer defines if the back buffer must be cleared
  48022. * @param depth defines if the depth buffer must be cleared
  48023. * @param stencil defines if the stencil buffer must be cleared
  48024. */
  48025. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48026. /**
  48027. * Gets the current render width
  48028. * @param useScreen defines if screen size must be used (or the current render target if any)
  48029. * @returns a number defining the current render width
  48030. */
  48031. getRenderWidth(useScreen?: boolean): number;
  48032. /**
  48033. * Gets the current render height
  48034. * @param useScreen defines if screen size must be used (or the current render target if any)
  48035. * @returns a number defining the current render height
  48036. */
  48037. getRenderHeight(useScreen?: boolean): number;
  48038. /**
  48039. * Set the WebGL's viewport
  48040. * @param viewport defines the viewport element to be used
  48041. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48042. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48043. */
  48044. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48045. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48046. /**
  48047. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48048. * @param pipelineContext defines the pipeline context to use
  48049. * @param uniformsNames defines the list of uniform names
  48050. * @returns an array of webGL uniform locations
  48051. */
  48052. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48053. /**
  48054. * Gets the lsit of active attributes for a given webGL program
  48055. * @param pipelineContext defines the pipeline context to use
  48056. * @param attributesNames defines the list of attribute names to get
  48057. * @returns an array of indices indicating the offset of each attribute
  48058. */
  48059. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48060. /**
  48061. * Binds an effect to the webGL context
  48062. * @param effect defines the effect to bind
  48063. */
  48064. bindSamplers(effect: Effect): void;
  48065. /**
  48066. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48067. * @param effect defines the effect to activate
  48068. */
  48069. enableEffect(effect: Effect): void;
  48070. /**
  48071. * Set various states to the webGL context
  48072. * @param culling defines backface culling state
  48073. * @param zOffset defines the value to apply to zOffset (0 by default)
  48074. * @param force defines if states must be applied even if cache is up to date
  48075. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48076. */
  48077. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48078. /**
  48079. * Set the value of an uniform to an array of int32
  48080. * @param uniform defines the webGL uniform location where to store the value
  48081. * @param array defines the array of int32 to store
  48082. */
  48083. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48084. /**
  48085. * Set the value of an uniform to an array of int32 (stored as vec2)
  48086. * @param uniform defines the webGL uniform location where to store the value
  48087. * @param array defines the array of int32 to store
  48088. */
  48089. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48090. /**
  48091. * Set the value of an uniform to an array of int32 (stored as vec3)
  48092. * @param uniform defines the webGL uniform location where to store the value
  48093. * @param array defines the array of int32 to store
  48094. */
  48095. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48096. /**
  48097. * Set the value of an uniform to an array of int32 (stored as vec4)
  48098. * @param uniform defines the webGL uniform location where to store the value
  48099. * @param array defines the array of int32 to store
  48100. */
  48101. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48102. /**
  48103. * Set the value of an uniform to an array of float32
  48104. * @param uniform defines the webGL uniform location where to store the value
  48105. * @param array defines the array of float32 to store
  48106. */
  48107. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48108. /**
  48109. * Set the value of an uniform to an array of float32 (stored as vec2)
  48110. * @param uniform defines the webGL uniform location where to store the value
  48111. * @param array defines the array of float32 to store
  48112. */
  48113. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48114. /**
  48115. * Set the value of an uniform to an array of float32 (stored as vec3)
  48116. * @param uniform defines the webGL uniform location where to store the value
  48117. * @param array defines the array of float32 to store
  48118. */
  48119. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48120. /**
  48121. * Set the value of an uniform to an array of float32 (stored as vec4)
  48122. * @param uniform defines the webGL uniform location where to store the value
  48123. * @param array defines the array of float32 to store
  48124. */
  48125. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48126. /**
  48127. * Set the value of an uniform to an array of number
  48128. * @param uniform defines the webGL uniform location where to store the value
  48129. * @param array defines the array of number to store
  48130. */
  48131. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48132. /**
  48133. * Set the value of an uniform to an array of number (stored as vec2)
  48134. * @param uniform defines the webGL uniform location where to store the value
  48135. * @param array defines the array of number to store
  48136. */
  48137. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48138. /**
  48139. * Set the value of an uniform to an array of number (stored as vec3)
  48140. * @param uniform defines the webGL uniform location where to store the value
  48141. * @param array defines the array of number to store
  48142. */
  48143. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48144. /**
  48145. * Set the value of an uniform to an array of number (stored as vec4)
  48146. * @param uniform defines the webGL uniform location where to store the value
  48147. * @param array defines the array of number to store
  48148. */
  48149. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48150. /**
  48151. * Set the value of an uniform to an array of float32 (stored as matrices)
  48152. * @param uniform defines the webGL uniform location where to store the value
  48153. * @param matrices defines the array of float32 to store
  48154. */
  48155. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48156. /**
  48157. * Set the value of an uniform to a matrix (3x3)
  48158. * @param uniform defines the webGL uniform location where to store the value
  48159. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48160. */
  48161. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48162. /**
  48163. * Set the value of an uniform to a matrix (2x2)
  48164. * @param uniform defines the webGL uniform location where to store the value
  48165. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48166. */
  48167. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48168. /**
  48169. * Set the value of an uniform to a number (float)
  48170. * @param uniform defines the webGL uniform location where to store the value
  48171. * @param value defines the float number to store
  48172. */
  48173. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48174. /**
  48175. * Set the value of an uniform to a vec2
  48176. * @param uniform defines the webGL uniform location where to store the value
  48177. * @param x defines the 1st component of the value
  48178. * @param y defines the 2nd component of the value
  48179. */
  48180. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48181. /**
  48182. * Set the value of an uniform to a vec3
  48183. * @param uniform defines the webGL uniform location where to store the value
  48184. * @param x defines the 1st component of the value
  48185. * @param y defines the 2nd component of the value
  48186. * @param z defines the 3rd component of the value
  48187. */
  48188. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48189. /**
  48190. * Set the value of an uniform to a boolean
  48191. * @param uniform defines the webGL uniform location where to store the value
  48192. * @param bool defines the boolean to store
  48193. */
  48194. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48195. /**
  48196. * Set the value of an uniform to a vec4
  48197. * @param uniform defines the webGL uniform location where to store the value
  48198. * @param x defines the 1st component of the value
  48199. * @param y defines the 2nd component of the value
  48200. * @param z defines the 3rd component of the value
  48201. * @param w defines the 4th component of the value
  48202. */
  48203. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48204. /**
  48205. * Sets the current alpha mode
  48206. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48207. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48208. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48209. */
  48210. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48211. /**
  48212. * Bind webGl buffers directly to the webGL context
  48213. * @param vertexBuffers defines the vertex buffer to bind
  48214. * @param indexBuffer defines the index buffer to bind
  48215. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48216. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48217. * @param effect defines the effect associated with the vertex buffer
  48218. */
  48219. bindBuffers(vertexBuffers: {
  48220. [key: string]: VertexBuffer;
  48221. }, indexBuffer: DataBuffer, effect: Effect): void;
  48222. /**
  48223. * Force the entire cache to be cleared
  48224. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48225. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48226. */
  48227. wipeCaches(bruteForce?: boolean): void;
  48228. /**
  48229. * Send a draw order
  48230. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48231. * @param indexStart defines the starting index
  48232. * @param indexCount defines the number of index to draw
  48233. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48234. */
  48235. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48236. /**
  48237. * Draw a list of indexed primitives
  48238. * @param fillMode defines the primitive to use
  48239. * @param indexStart defines the starting index
  48240. * @param indexCount defines the number of index to draw
  48241. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48242. */
  48243. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48244. /**
  48245. * Draw a list of unindexed primitives
  48246. * @param fillMode defines the primitive to use
  48247. * @param verticesStart defines the index of first vertex to draw
  48248. * @param verticesCount defines the count of vertices to draw
  48249. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48250. */
  48251. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48252. /** @hidden */
  48253. _createTexture(): WebGLTexture;
  48254. /** @hidden */
  48255. _releaseTexture(texture: InternalTexture): void;
  48256. /**
  48257. * Usually called from Texture.ts.
  48258. * Passed information to create a WebGLTexture
  48259. * @param urlArg defines a value which contains one of the following:
  48260. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48261. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48262. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48263. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48264. * @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)
  48265. * @param scene needed for loading to the correct scene
  48266. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48267. * @param onLoad optional callback to be called upon successful completion
  48268. * @param onError optional callback to be called upon failure
  48269. * @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
  48270. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48271. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48272. * @param forcedExtension defines the extension to use to pick the right loader
  48273. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48274. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48275. */
  48276. 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;
  48277. /**
  48278. * Creates a new render target texture
  48279. * @param size defines the size of the texture
  48280. * @param options defines the options used to create the texture
  48281. * @returns a new render target texture stored in an InternalTexture
  48282. */
  48283. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48284. /**
  48285. * Update the sampling mode of a given texture
  48286. * @param samplingMode defines the required sampling mode
  48287. * @param texture defines the texture to update
  48288. */
  48289. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48290. /**
  48291. * Binds the frame buffer to the specified texture.
  48292. * @param texture The texture to render to or null for the default canvas
  48293. * @param faceIndex The face of the texture to render to in case of cube texture
  48294. * @param requiredWidth The width of the target to render to
  48295. * @param requiredHeight The height of the target to render to
  48296. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48297. * @param depthStencilTexture The depth stencil texture to use to render
  48298. * @param lodLevel defines le lod level to bind to the frame buffer
  48299. */
  48300. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48301. /**
  48302. * Unbind the current render target texture from the webGL context
  48303. * @param texture defines the render target texture to unbind
  48304. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48305. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48306. */
  48307. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48308. /**
  48309. * Creates a dynamic vertex buffer
  48310. * @param vertices the data for the dynamic vertex buffer
  48311. * @returns the new WebGL dynamic buffer
  48312. */
  48313. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48314. /**
  48315. * Update the content of a dynamic texture
  48316. * @param texture defines the texture to update
  48317. * @param canvas defines the canvas containing the source
  48318. * @param invertY defines if data must be stored with Y axis inverted
  48319. * @param premulAlpha defines if alpha is stored as premultiplied
  48320. * @param format defines the format of the data
  48321. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48322. */
  48323. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48324. /**
  48325. * Gets a boolean indicating if all created effects are ready
  48326. * @returns true if all effects are ready
  48327. */
  48328. areAllEffectsReady(): boolean;
  48329. /**
  48330. * @hidden
  48331. * Get the current error code of the webGL context
  48332. * @returns the error code
  48333. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48334. */
  48335. getError(): number;
  48336. /** @hidden */
  48337. _getUnpackAlignement(): number;
  48338. /** @hidden */
  48339. _unpackFlipY(value: boolean): void;
  48340. /**
  48341. * Update a dynamic index buffer
  48342. * @param indexBuffer defines the target index buffer
  48343. * @param indices defines the data to update
  48344. * @param offset defines the offset in the target index buffer where update should start
  48345. */
  48346. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48347. /**
  48348. * Updates a dynamic vertex buffer.
  48349. * @param vertexBuffer the vertex buffer to update
  48350. * @param vertices the data used to update the vertex buffer
  48351. * @param byteOffset the byte offset of the data (optional)
  48352. * @param byteLength the byte length of the data (optional)
  48353. */
  48354. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48355. /** @hidden */
  48356. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48357. /** @hidden */
  48358. _bindTexture(channel: number, texture: InternalTexture): void;
  48359. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48360. /**
  48361. * 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
  48362. */
  48363. releaseEffects(): void;
  48364. displayLoadingUI(): void;
  48365. hideLoadingUI(): void;
  48366. /** @hidden */
  48367. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48368. /** @hidden */
  48369. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48370. /** @hidden */
  48371. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48372. /** @hidden */
  48373. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48374. }
  48375. }
  48376. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48377. import { Nullable, int } from "babylonjs/types";
  48378. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48379. /** @hidden */
  48380. export class _OcclusionDataStorage {
  48381. /** @hidden */
  48382. occlusionInternalRetryCounter: number;
  48383. /** @hidden */
  48384. isOcclusionQueryInProgress: boolean;
  48385. /** @hidden */
  48386. isOccluded: boolean;
  48387. /** @hidden */
  48388. occlusionRetryCount: number;
  48389. /** @hidden */
  48390. occlusionType: number;
  48391. /** @hidden */
  48392. occlusionQueryAlgorithmType: number;
  48393. }
  48394. module "babylonjs/Engines/engine" {
  48395. interface Engine {
  48396. /**
  48397. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48398. * @return the new query
  48399. */
  48400. createQuery(): WebGLQuery;
  48401. /**
  48402. * Delete and release a webGL query
  48403. * @param query defines the query to delete
  48404. * @return the current engine
  48405. */
  48406. deleteQuery(query: WebGLQuery): Engine;
  48407. /**
  48408. * Check if a given query has resolved and got its value
  48409. * @param query defines the query to check
  48410. * @returns true if the query got its value
  48411. */
  48412. isQueryResultAvailable(query: WebGLQuery): boolean;
  48413. /**
  48414. * Gets the value of a given query
  48415. * @param query defines the query to check
  48416. * @returns the value of the query
  48417. */
  48418. getQueryResult(query: WebGLQuery): number;
  48419. /**
  48420. * Initiates an occlusion query
  48421. * @param algorithmType defines the algorithm to use
  48422. * @param query defines the query to use
  48423. * @returns the current engine
  48424. * @see http://doc.babylonjs.com/features/occlusionquery
  48425. */
  48426. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48427. /**
  48428. * Ends an occlusion query
  48429. * @see http://doc.babylonjs.com/features/occlusionquery
  48430. * @param algorithmType defines the algorithm to use
  48431. * @returns the current engine
  48432. */
  48433. endOcclusionQuery(algorithmType: number): Engine;
  48434. /**
  48435. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48436. * Please note that only one query can be issued at a time
  48437. * @returns a time token used to track the time span
  48438. */
  48439. startTimeQuery(): Nullable<_TimeToken>;
  48440. /**
  48441. * Ends a time query
  48442. * @param token defines the token used to measure the time span
  48443. * @returns the time spent (in ns)
  48444. */
  48445. endTimeQuery(token: _TimeToken): int;
  48446. /** @hidden */
  48447. _currentNonTimestampToken: Nullable<_TimeToken>;
  48448. /** @hidden */
  48449. _createTimeQuery(): WebGLQuery;
  48450. /** @hidden */
  48451. _deleteTimeQuery(query: WebGLQuery): void;
  48452. /** @hidden */
  48453. _getGlAlgorithmType(algorithmType: number): number;
  48454. /** @hidden */
  48455. _getTimeQueryResult(query: WebGLQuery): any;
  48456. /** @hidden */
  48457. _getTimeQueryAvailability(query: WebGLQuery): any;
  48458. }
  48459. }
  48460. module "babylonjs/Meshes/abstractMesh" {
  48461. interface AbstractMesh {
  48462. /**
  48463. * Backing filed
  48464. * @hidden
  48465. */
  48466. __occlusionDataStorage: _OcclusionDataStorage;
  48467. /**
  48468. * Access property
  48469. * @hidden
  48470. */
  48471. _occlusionDataStorage: _OcclusionDataStorage;
  48472. /**
  48473. * 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.
  48474. * The default value is -1 which means don't break the query and wait till the result
  48475. * @see http://doc.babylonjs.com/features/occlusionquery
  48476. */
  48477. occlusionRetryCount: number;
  48478. /**
  48479. * 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:
  48480. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48481. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48482. * * 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.
  48483. * @see http://doc.babylonjs.com/features/occlusionquery
  48484. */
  48485. occlusionType: number;
  48486. /**
  48487. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48488. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48489. * * 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.
  48490. * @see http://doc.babylonjs.com/features/occlusionquery
  48491. */
  48492. occlusionQueryAlgorithmType: number;
  48493. /**
  48494. * 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
  48495. * @see http://doc.babylonjs.com/features/occlusionquery
  48496. */
  48497. isOccluded: boolean;
  48498. /**
  48499. * Flag to check the progress status of the query
  48500. * @see http://doc.babylonjs.com/features/occlusionquery
  48501. */
  48502. isOcclusionQueryInProgress: boolean;
  48503. }
  48504. }
  48505. }
  48506. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48507. import { Nullable } from "babylonjs/types";
  48508. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48509. /** @hidden */
  48510. export var _forceTransformFeedbackToBundle: boolean;
  48511. module "babylonjs/Engines/engine" {
  48512. interface Engine {
  48513. /**
  48514. * Creates a webGL transform feedback object
  48515. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48516. * @returns the webGL transform feedback object
  48517. */
  48518. createTransformFeedback(): WebGLTransformFeedback;
  48519. /**
  48520. * Delete a webGL transform feedback object
  48521. * @param value defines the webGL transform feedback object to delete
  48522. */
  48523. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48524. /**
  48525. * Bind a webGL transform feedback object to the webgl context
  48526. * @param value defines the webGL transform feedback object to bind
  48527. */
  48528. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48529. /**
  48530. * Begins a transform feedback operation
  48531. * @param usePoints defines if points or triangles must be used
  48532. */
  48533. beginTransformFeedback(usePoints: boolean): void;
  48534. /**
  48535. * Ends a transform feedback operation
  48536. */
  48537. endTransformFeedback(): void;
  48538. /**
  48539. * Specify the varyings to use with transform feedback
  48540. * @param program defines the associated webGL program
  48541. * @param value defines the list of strings representing the varying names
  48542. */
  48543. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48544. /**
  48545. * Bind a webGL buffer for a transform feedback operation
  48546. * @param value defines the webGL buffer to bind
  48547. */
  48548. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48549. }
  48550. }
  48551. }
  48552. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48553. import { Scene } from "babylonjs/scene";
  48554. import { Engine } from "babylonjs/Engines/engine";
  48555. import { Texture } from "babylonjs/Materials/Textures/texture";
  48556. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48557. import "babylonjs/Engines/Extensions/engine.multiRender";
  48558. /**
  48559. * Creation options of the multi render target texture.
  48560. */
  48561. export interface IMultiRenderTargetOptions {
  48562. /**
  48563. * Define if the texture needs to create mip maps after render.
  48564. */
  48565. generateMipMaps?: boolean;
  48566. /**
  48567. * Define the types of all the draw buffers we want to create
  48568. */
  48569. types?: number[];
  48570. /**
  48571. * Define the sampling modes of all the draw buffers we want to create
  48572. */
  48573. samplingModes?: number[];
  48574. /**
  48575. * Define if a depth buffer is required
  48576. */
  48577. generateDepthBuffer?: boolean;
  48578. /**
  48579. * Define if a stencil buffer is required
  48580. */
  48581. generateStencilBuffer?: boolean;
  48582. /**
  48583. * Define if a depth texture is required instead of a depth buffer
  48584. */
  48585. generateDepthTexture?: boolean;
  48586. /**
  48587. * Define the number of desired draw buffers
  48588. */
  48589. textureCount?: number;
  48590. /**
  48591. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48592. */
  48593. doNotChangeAspectRatio?: boolean;
  48594. /**
  48595. * Define the default type of the buffers we are creating
  48596. */
  48597. defaultType?: number;
  48598. }
  48599. /**
  48600. * A multi render target, like a render target provides the ability to render to a texture.
  48601. * Unlike the render target, it can render to several draw buffers in one draw.
  48602. * This is specially interesting in deferred rendering or for any effects requiring more than
  48603. * just one color from a single pass.
  48604. */
  48605. export class MultiRenderTarget extends RenderTargetTexture {
  48606. private _internalTextures;
  48607. private _textures;
  48608. private _multiRenderTargetOptions;
  48609. /**
  48610. * Get if draw buffers are currently supported by the used hardware and browser.
  48611. */
  48612. get isSupported(): boolean;
  48613. /**
  48614. * Get the list of textures generated by the multi render target.
  48615. */
  48616. get textures(): Texture[];
  48617. /**
  48618. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48619. */
  48620. get depthTexture(): Texture;
  48621. /**
  48622. * Set the wrapping mode on U of all the textures we are rendering to.
  48623. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48624. */
  48625. set wrapU(wrap: number);
  48626. /**
  48627. * Set the wrapping mode on V of all the textures we are rendering to.
  48628. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48629. */
  48630. set wrapV(wrap: number);
  48631. /**
  48632. * Instantiate a new multi render target texture.
  48633. * A multi render target, like a render target provides the ability to render to a texture.
  48634. * Unlike the render target, it can render to several draw buffers in one draw.
  48635. * This is specially interesting in deferred rendering or for any effects requiring more than
  48636. * just one color from a single pass.
  48637. * @param name Define the name of the texture
  48638. * @param size Define the size of the buffers to render to
  48639. * @param count Define the number of target we are rendering into
  48640. * @param scene Define the scene the texture belongs to
  48641. * @param options Define the options used to create the multi render target
  48642. */
  48643. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48644. /** @hidden */
  48645. _rebuild(): void;
  48646. private _createInternalTextures;
  48647. private _createTextures;
  48648. /**
  48649. * Define the number of samples used if MSAA is enabled.
  48650. */
  48651. get samples(): number;
  48652. set samples(value: number);
  48653. /**
  48654. * Resize all the textures in the multi render target.
  48655. * Be carrefull as it will recreate all the data in the new texture.
  48656. * @param size Define the new size
  48657. */
  48658. resize(size: any): void;
  48659. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48660. /**
  48661. * Dispose the render targets and their associated resources
  48662. */
  48663. dispose(): void;
  48664. /**
  48665. * Release all the underlying texture used as draw buffers.
  48666. */
  48667. releaseInternalTextures(): void;
  48668. }
  48669. }
  48670. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48671. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48672. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48673. import { Nullable } from "babylonjs/types";
  48674. module "babylonjs/Engines/thinEngine" {
  48675. interface ThinEngine {
  48676. /**
  48677. * Unbind a list of render target textures from the webGL context
  48678. * This is used only when drawBuffer extension or webGL2 are active
  48679. * @param textures defines the render target textures to unbind
  48680. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48681. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48682. */
  48683. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48684. /**
  48685. * Create a multi render target texture
  48686. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48687. * @param size defines the size of the texture
  48688. * @param options defines the creation options
  48689. * @returns the cube texture as an InternalTexture
  48690. */
  48691. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48692. /**
  48693. * Update the sample count for a given multiple render target texture
  48694. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48695. * @param textures defines the textures to update
  48696. * @param samples defines the sample count to set
  48697. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48698. */
  48699. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48700. }
  48701. }
  48702. }
  48703. declare module "babylonjs/Engines/Extensions/engine.views" {
  48704. import { Camera } from "babylonjs/Cameras/camera";
  48705. import { Nullable } from "babylonjs/types";
  48706. /**
  48707. * Class used to define an additional view for the engine
  48708. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48709. */
  48710. export class EngineView {
  48711. /** Defines the canvas where to render the view */
  48712. target: HTMLCanvasElement;
  48713. /** Defines an optional camera used to render the view (will use active camera else) */
  48714. camera?: Camera;
  48715. }
  48716. module "babylonjs/Engines/engine" {
  48717. interface Engine {
  48718. /**
  48719. * Gets or sets the HTML element to use for attaching events
  48720. */
  48721. inputElement: Nullable<HTMLElement>;
  48722. /**
  48723. * Gets the current engine view
  48724. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48725. */
  48726. activeView: Nullable<EngineView>;
  48727. /** Gets or sets the list of views */
  48728. views: EngineView[];
  48729. /**
  48730. * Register a new child canvas
  48731. * @param canvas defines the canvas to register
  48732. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48733. * @returns the associated view
  48734. */
  48735. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48736. /**
  48737. * Remove a registered child canvas
  48738. * @param canvas defines the canvas to remove
  48739. * @returns the current engine
  48740. */
  48741. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48742. }
  48743. }
  48744. }
  48745. declare module "babylonjs/Engines/Extensions/index" {
  48746. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48747. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48748. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48749. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48750. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48751. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48752. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48753. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48754. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48755. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48756. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48757. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48758. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48759. export * from "babylonjs/Engines/Extensions/engine.views";
  48760. }
  48761. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48762. import { Nullable } from "babylonjs/types";
  48763. /**
  48764. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48765. */
  48766. export interface CubeMapInfo {
  48767. /**
  48768. * The pixel array for the front face.
  48769. * This is stored in format, left to right, up to down format.
  48770. */
  48771. front: Nullable<ArrayBufferView>;
  48772. /**
  48773. * The pixel array for the back face.
  48774. * This is stored in format, left to right, up to down format.
  48775. */
  48776. back: Nullable<ArrayBufferView>;
  48777. /**
  48778. * The pixel array for the left face.
  48779. * This is stored in format, left to right, up to down format.
  48780. */
  48781. left: Nullable<ArrayBufferView>;
  48782. /**
  48783. * The pixel array for the right face.
  48784. * This is stored in format, left to right, up to down format.
  48785. */
  48786. right: Nullable<ArrayBufferView>;
  48787. /**
  48788. * The pixel array for the up face.
  48789. * This is stored in format, left to right, up to down format.
  48790. */
  48791. up: Nullable<ArrayBufferView>;
  48792. /**
  48793. * The pixel array for the down face.
  48794. * This is stored in format, left to right, up to down format.
  48795. */
  48796. down: Nullable<ArrayBufferView>;
  48797. /**
  48798. * The size of the cubemap stored.
  48799. *
  48800. * Each faces will be size * size pixels.
  48801. */
  48802. size: number;
  48803. /**
  48804. * The format of the texture.
  48805. *
  48806. * RGBA, RGB.
  48807. */
  48808. format: number;
  48809. /**
  48810. * The type of the texture data.
  48811. *
  48812. * UNSIGNED_INT, FLOAT.
  48813. */
  48814. type: number;
  48815. /**
  48816. * Specifies whether the texture is in gamma space.
  48817. */
  48818. gammaSpace: boolean;
  48819. }
  48820. /**
  48821. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48822. */
  48823. export class PanoramaToCubeMapTools {
  48824. private static FACE_FRONT;
  48825. private static FACE_BACK;
  48826. private static FACE_RIGHT;
  48827. private static FACE_LEFT;
  48828. private static FACE_DOWN;
  48829. private static FACE_UP;
  48830. /**
  48831. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48832. *
  48833. * @param float32Array The source data.
  48834. * @param inputWidth The width of the input panorama.
  48835. * @param inputHeight The height of the input panorama.
  48836. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48837. * @return The cubemap data
  48838. */
  48839. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48840. private static CreateCubemapTexture;
  48841. private static CalcProjectionSpherical;
  48842. }
  48843. }
  48844. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48845. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48846. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48847. import { Nullable } from "babylonjs/types";
  48848. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48849. /**
  48850. * Helper class dealing with the extraction of spherical polynomial dataArray
  48851. * from a cube map.
  48852. */
  48853. export class CubeMapToSphericalPolynomialTools {
  48854. private static FileFaces;
  48855. /**
  48856. * Converts a texture to the according Spherical Polynomial data.
  48857. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48858. *
  48859. * @param texture The texture to extract the information from.
  48860. * @return The Spherical Polynomial data.
  48861. */
  48862. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48863. /**
  48864. * Converts a cubemap to the according Spherical Polynomial data.
  48865. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48866. *
  48867. * @param cubeInfo The Cube map to extract the information from.
  48868. * @return The Spherical Polynomial data.
  48869. */
  48870. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48871. }
  48872. }
  48873. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48874. import { Nullable } from "babylonjs/types";
  48875. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48876. module "babylonjs/Materials/Textures/baseTexture" {
  48877. interface BaseTexture {
  48878. /**
  48879. * Get the polynomial representation of the texture data.
  48880. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48881. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48882. */
  48883. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48884. }
  48885. }
  48886. }
  48887. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48888. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48889. /** @hidden */
  48890. export var rgbdEncodePixelShader: {
  48891. name: string;
  48892. shader: string;
  48893. };
  48894. }
  48895. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48896. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48897. /** @hidden */
  48898. export var rgbdDecodePixelShader: {
  48899. name: string;
  48900. shader: string;
  48901. };
  48902. }
  48903. declare module "babylonjs/Misc/environmentTextureTools" {
  48904. import { Nullable } from "babylonjs/types";
  48905. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48906. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48907. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48908. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48909. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  48910. import "babylonjs/Shaders/rgbdEncode.fragment";
  48911. import "babylonjs/Shaders/rgbdDecode.fragment";
  48912. /**
  48913. * Raw texture data and descriptor sufficient for WebGL texture upload
  48914. */
  48915. export interface EnvironmentTextureInfo {
  48916. /**
  48917. * Version of the environment map
  48918. */
  48919. version: number;
  48920. /**
  48921. * Width of image
  48922. */
  48923. width: number;
  48924. /**
  48925. * Irradiance information stored in the file.
  48926. */
  48927. irradiance: any;
  48928. /**
  48929. * Specular information stored in the file.
  48930. */
  48931. specular: any;
  48932. }
  48933. /**
  48934. * Defines One Image in the file. It requires only the position in the file
  48935. * as well as the length.
  48936. */
  48937. interface BufferImageData {
  48938. /**
  48939. * Length of the image data.
  48940. */
  48941. length: number;
  48942. /**
  48943. * Position of the data from the null terminator delimiting the end of the JSON.
  48944. */
  48945. position: number;
  48946. }
  48947. /**
  48948. * Defines the specular data enclosed in the file.
  48949. * This corresponds to the version 1 of the data.
  48950. */
  48951. export interface EnvironmentTextureSpecularInfoV1 {
  48952. /**
  48953. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48954. */
  48955. specularDataPosition?: number;
  48956. /**
  48957. * This contains all the images data needed to reconstruct the cubemap.
  48958. */
  48959. mipmaps: Array<BufferImageData>;
  48960. /**
  48961. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48962. */
  48963. lodGenerationScale: number;
  48964. }
  48965. /**
  48966. * Sets of helpers addressing the serialization and deserialization of environment texture
  48967. * stored in a BabylonJS env file.
  48968. * Those files are usually stored as .env files.
  48969. */
  48970. export class EnvironmentTextureTools {
  48971. /**
  48972. * Magic number identifying the env file.
  48973. */
  48974. private static _MagicBytes;
  48975. /**
  48976. * Gets the environment info from an env file.
  48977. * @param data The array buffer containing the .env bytes.
  48978. * @returns the environment file info (the json header) if successfully parsed.
  48979. */
  48980. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48981. /**
  48982. * Creates an environment texture from a loaded cube texture.
  48983. * @param texture defines the cube texture to convert in env file
  48984. * @return a promise containing the environment data if succesfull.
  48985. */
  48986. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48987. /**
  48988. * Creates a JSON representation of the spherical data.
  48989. * @param texture defines the texture containing the polynomials
  48990. * @return the JSON representation of the spherical info
  48991. */
  48992. private static _CreateEnvTextureIrradiance;
  48993. /**
  48994. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48995. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  48996. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48997. * @return the views described by info providing access to the underlying buffer
  48998. */
  48999. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49000. /**
  49001. * Uploads the texture info contained in the env file to the GPU.
  49002. * @param texture defines the internal texture to upload to
  49003. * @param arrayBuffer defines the buffer cotaining the data to load
  49004. * @param info defines the texture info retrieved through the GetEnvInfo method
  49005. * @returns a promise
  49006. */
  49007. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49008. private static _OnImageReadyAsync;
  49009. /**
  49010. * Uploads the levels of image data to the GPU.
  49011. * @param texture defines the internal texture to upload to
  49012. * @param imageData defines the array buffer views of image data [mipmap][face]
  49013. * @returns a promise
  49014. */
  49015. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49016. /**
  49017. * Uploads spherical polynomials information to the texture.
  49018. * @param texture defines the texture we are trying to upload the information to
  49019. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49020. */
  49021. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49022. /** @hidden */
  49023. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49024. }
  49025. }
  49026. declare module "babylonjs/Maths/math.vertexFormat" {
  49027. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49028. /**
  49029. * Contains position and normal vectors for a vertex
  49030. */
  49031. export class PositionNormalVertex {
  49032. /** the position of the vertex (defaut: 0,0,0) */
  49033. position: Vector3;
  49034. /** the normal of the vertex (defaut: 0,1,0) */
  49035. normal: Vector3;
  49036. /**
  49037. * Creates a PositionNormalVertex
  49038. * @param position the position of the vertex (defaut: 0,0,0)
  49039. * @param normal the normal of the vertex (defaut: 0,1,0)
  49040. */
  49041. constructor(
  49042. /** the position of the vertex (defaut: 0,0,0) */
  49043. position?: Vector3,
  49044. /** the normal of the vertex (defaut: 0,1,0) */
  49045. normal?: Vector3);
  49046. /**
  49047. * Clones the PositionNormalVertex
  49048. * @returns the cloned PositionNormalVertex
  49049. */
  49050. clone(): PositionNormalVertex;
  49051. }
  49052. /**
  49053. * Contains position, normal and uv vectors for a vertex
  49054. */
  49055. export class PositionNormalTextureVertex {
  49056. /** the position of the vertex (defaut: 0,0,0) */
  49057. position: Vector3;
  49058. /** the normal of the vertex (defaut: 0,1,0) */
  49059. normal: Vector3;
  49060. /** the uv of the vertex (default: 0,0) */
  49061. uv: Vector2;
  49062. /**
  49063. * Creates a PositionNormalTextureVertex
  49064. * @param position the position of the vertex (defaut: 0,0,0)
  49065. * @param normal the normal of the vertex (defaut: 0,1,0)
  49066. * @param uv the uv of the vertex (default: 0,0)
  49067. */
  49068. constructor(
  49069. /** the position of the vertex (defaut: 0,0,0) */
  49070. position?: Vector3,
  49071. /** the normal of the vertex (defaut: 0,1,0) */
  49072. normal?: Vector3,
  49073. /** the uv of the vertex (default: 0,0) */
  49074. uv?: Vector2);
  49075. /**
  49076. * Clones the PositionNormalTextureVertex
  49077. * @returns the cloned PositionNormalTextureVertex
  49078. */
  49079. clone(): PositionNormalTextureVertex;
  49080. }
  49081. }
  49082. declare module "babylonjs/Maths/math" {
  49083. export * from "babylonjs/Maths/math.axis";
  49084. export * from "babylonjs/Maths/math.color";
  49085. export * from "babylonjs/Maths/math.constants";
  49086. export * from "babylonjs/Maths/math.frustum";
  49087. export * from "babylonjs/Maths/math.path";
  49088. export * from "babylonjs/Maths/math.plane";
  49089. export * from "babylonjs/Maths/math.size";
  49090. export * from "babylonjs/Maths/math.vector";
  49091. export * from "babylonjs/Maths/math.vertexFormat";
  49092. export * from "babylonjs/Maths/math.viewport";
  49093. }
  49094. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49095. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49096. /** @hidden */
  49097. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49098. private _genericAttributeLocation;
  49099. private _varyingLocationCount;
  49100. private _varyingLocationMap;
  49101. private _replacements;
  49102. private _textureCount;
  49103. private _uniforms;
  49104. lineProcessor(line: string): string;
  49105. attributeProcessor(attribute: string): string;
  49106. varyingProcessor(varying: string, isFragment: boolean): string;
  49107. uniformProcessor(uniform: string): string;
  49108. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49109. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49110. }
  49111. }
  49112. declare module "babylonjs/Engines/nativeEngine" {
  49113. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49114. import { Engine } from "babylonjs/Engines/engine";
  49115. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49116. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49117. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49118. import { Effect } from "babylonjs/Materials/effect";
  49119. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49120. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49121. import { IColor4Like } from "babylonjs/Maths/math.like";
  49122. import { Scene } from "babylonjs/scene";
  49123. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49124. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49125. /**
  49126. * Container for accessors for natively-stored mesh data buffers.
  49127. */
  49128. class NativeDataBuffer extends DataBuffer {
  49129. /**
  49130. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49131. */
  49132. nativeIndexBuffer?: any;
  49133. /**
  49134. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49135. */
  49136. nativeVertexBuffer?: any;
  49137. }
  49138. /** @hidden */
  49139. class NativeTexture extends InternalTexture {
  49140. getInternalTexture(): InternalTexture;
  49141. getViewCount(): number;
  49142. }
  49143. /** @hidden */
  49144. export class NativeEngine extends Engine {
  49145. private readonly _native;
  49146. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49147. private readonly INVALID_HANDLE;
  49148. getHardwareScalingLevel(): number;
  49149. constructor();
  49150. /**
  49151. * Can be used to override the current requestAnimationFrame requester.
  49152. * @hidden
  49153. */
  49154. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49155. /**
  49156. * Override default engine behavior.
  49157. * @param color
  49158. * @param backBuffer
  49159. * @param depth
  49160. * @param stencil
  49161. */
  49162. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49163. /**
  49164. * Gets host document
  49165. * @returns the host document object
  49166. */
  49167. getHostDocument(): Nullable<Document>;
  49168. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49169. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49170. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49171. recordVertexArrayObject(vertexBuffers: {
  49172. [key: string]: VertexBuffer;
  49173. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49174. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49175. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49176. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49177. /**
  49178. * Draw a list of indexed primitives
  49179. * @param fillMode defines the primitive to use
  49180. * @param indexStart defines the starting index
  49181. * @param indexCount defines the number of index to draw
  49182. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49183. */
  49184. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49185. /**
  49186. * Draw a list of unindexed primitives
  49187. * @param fillMode defines the primitive to use
  49188. * @param verticesStart defines the index of first vertex to draw
  49189. * @param verticesCount defines the count of vertices to draw
  49190. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49191. */
  49192. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49193. createPipelineContext(): IPipelineContext;
  49194. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49195. /** @hidden */
  49196. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49197. /** @hidden */
  49198. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49199. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49200. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49201. protected _setProgram(program: WebGLProgram): void;
  49202. _releaseEffect(effect: Effect): void;
  49203. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49204. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49205. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49206. bindSamplers(effect: Effect): void;
  49207. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49208. getRenderWidth(useScreen?: boolean): number;
  49209. getRenderHeight(useScreen?: boolean): number;
  49210. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49211. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49212. /**
  49213. * Set the z offset to apply to current rendering
  49214. * @param value defines the offset to apply
  49215. */
  49216. setZOffset(value: number): void;
  49217. /**
  49218. * Gets the current value of the zOffset
  49219. * @returns the current zOffset state
  49220. */
  49221. getZOffset(): number;
  49222. /**
  49223. * Enable or disable depth buffering
  49224. * @param enable defines the state to set
  49225. */
  49226. setDepthBuffer(enable: boolean): void;
  49227. /**
  49228. * Gets a boolean indicating if depth writing is enabled
  49229. * @returns the current depth writing state
  49230. */
  49231. getDepthWrite(): boolean;
  49232. /**
  49233. * Enable or disable depth writing
  49234. * @param enable defines the state to set
  49235. */
  49236. setDepthWrite(enable: boolean): void;
  49237. /**
  49238. * Enable or disable color writing
  49239. * @param enable defines the state to set
  49240. */
  49241. setColorWrite(enable: boolean): void;
  49242. /**
  49243. * Gets a boolean indicating if color writing is enabled
  49244. * @returns the current color writing state
  49245. */
  49246. getColorWrite(): boolean;
  49247. /**
  49248. * Sets alpha constants used by some alpha blending modes
  49249. * @param r defines the red component
  49250. * @param g defines the green component
  49251. * @param b defines the blue component
  49252. * @param a defines the alpha component
  49253. */
  49254. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49255. /**
  49256. * Sets the current alpha mode
  49257. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49258. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49259. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49260. */
  49261. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49262. /**
  49263. * Gets the current alpha mode
  49264. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49265. * @returns the current alpha mode
  49266. */
  49267. getAlphaMode(): number;
  49268. setInt(uniform: WebGLUniformLocation, int: number): void;
  49269. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49270. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49271. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49272. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49273. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49274. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49275. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49276. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49277. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49278. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49279. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49280. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49281. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49282. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49283. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49284. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49285. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49286. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49287. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49288. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49289. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49290. wipeCaches(bruteForce?: boolean): void;
  49291. _createTexture(): WebGLTexture;
  49292. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49293. /**
  49294. * Usually called from BABYLON.Texture.ts.
  49295. * Passed information to create a WebGLTexture
  49296. * @param urlArg defines a value which contains one of the following:
  49297. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49298. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49299. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49300. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49301. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49302. * @param scene needed for loading to the correct scene
  49303. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49304. * @param onLoad optional callback to be called upon successful completion
  49305. * @param onError optional callback to be called upon failure
  49306. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49307. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49308. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49309. * @param forcedExtension defines the extension to use to pick the right loader
  49310. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49311. */
  49312. 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;
  49313. /**
  49314. * Creates a cube texture
  49315. * @param rootUrl defines the url where the files to load is located
  49316. * @param scene defines the current scene
  49317. * @param files defines the list of files to load (1 per face)
  49318. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49319. * @param onLoad defines an optional callback raised when the texture is loaded
  49320. * @param onError defines an optional callback raised if there is an issue to load the texture
  49321. * @param format defines the format of the data
  49322. * @param forcedExtension defines the extension to use to pick the right loader
  49323. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49324. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49325. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49326. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49327. * @returns the cube texture as an InternalTexture
  49328. */
  49329. 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;
  49330. private _getSamplingFilter;
  49331. private static _GetNativeTextureFormat;
  49332. createRenderTargetTexture(size: number | {
  49333. width: number;
  49334. height: number;
  49335. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49336. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49337. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49338. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49339. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49340. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49341. /**
  49342. * Updates a dynamic vertex buffer.
  49343. * @param vertexBuffer the vertex buffer to update
  49344. * @param data the data used to update the vertex buffer
  49345. * @param byteOffset the byte offset of the data (optional)
  49346. * @param byteLength the byte length of the data (optional)
  49347. */
  49348. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49349. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49350. private _updateAnisotropicLevel;
  49351. private _getAddressMode;
  49352. /** @hidden */
  49353. _bindTexture(channel: number, texture: InternalTexture): void;
  49354. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49355. releaseEffects(): void;
  49356. /** @hidden */
  49357. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49358. /** @hidden */
  49359. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49360. /** @hidden */
  49361. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49362. /** @hidden */
  49363. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49364. }
  49365. }
  49366. declare module "babylonjs/Engines/index" {
  49367. export * from "babylonjs/Engines/constants";
  49368. export * from "babylonjs/Engines/engineCapabilities";
  49369. export * from "babylonjs/Engines/instancingAttributeInfo";
  49370. export * from "babylonjs/Engines/thinEngine";
  49371. export * from "babylonjs/Engines/engine";
  49372. export * from "babylonjs/Engines/engineStore";
  49373. export * from "babylonjs/Engines/nullEngine";
  49374. export * from "babylonjs/Engines/Extensions/index";
  49375. export * from "babylonjs/Engines/IPipelineContext";
  49376. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49377. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49378. export * from "babylonjs/Engines/nativeEngine";
  49379. }
  49380. declare module "babylonjs/Events/clipboardEvents" {
  49381. /**
  49382. * Gather the list of clipboard event types as constants.
  49383. */
  49384. export class ClipboardEventTypes {
  49385. /**
  49386. * The clipboard event is fired when a copy command is active (pressed).
  49387. */
  49388. static readonly COPY: number;
  49389. /**
  49390. * The clipboard event is fired when a cut command is active (pressed).
  49391. */
  49392. static readonly CUT: number;
  49393. /**
  49394. * The clipboard event is fired when a paste command is active (pressed).
  49395. */
  49396. static readonly PASTE: number;
  49397. }
  49398. /**
  49399. * This class is used to store clipboard related info for the onClipboardObservable event.
  49400. */
  49401. export class ClipboardInfo {
  49402. /**
  49403. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49404. */
  49405. type: number;
  49406. /**
  49407. * Defines the related dom event
  49408. */
  49409. event: ClipboardEvent;
  49410. /**
  49411. *Creates an instance of ClipboardInfo.
  49412. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49413. * @param event Defines the related dom event
  49414. */
  49415. constructor(
  49416. /**
  49417. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49418. */
  49419. type: number,
  49420. /**
  49421. * Defines the related dom event
  49422. */
  49423. event: ClipboardEvent);
  49424. /**
  49425. * Get the clipboard event's type from the keycode.
  49426. * @param keyCode Defines the keyCode for the current keyboard event.
  49427. * @return {number}
  49428. */
  49429. static GetTypeFromCharacter(keyCode: number): number;
  49430. }
  49431. }
  49432. declare module "babylonjs/Events/index" {
  49433. export * from "babylonjs/Events/keyboardEvents";
  49434. export * from "babylonjs/Events/pointerEvents";
  49435. export * from "babylonjs/Events/clipboardEvents";
  49436. }
  49437. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49438. import { Scene } from "babylonjs/scene";
  49439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49440. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49441. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49442. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49443. /**
  49444. * Google Daydream controller
  49445. */
  49446. export class DaydreamController extends WebVRController {
  49447. /**
  49448. * Base Url for the controller model.
  49449. */
  49450. static MODEL_BASE_URL: string;
  49451. /**
  49452. * File name for the controller model.
  49453. */
  49454. static MODEL_FILENAME: string;
  49455. /**
  49456. * Gamepad Id prefix used to identify Daydream Controller.
  49457. */
  49458. static readonly GAMEPAD_ID_PREFIX: string;
  49459. /**
  49460. * Creates a new DaydreamController from a gamepad
  49461. * @param vrGamepad the gamepad that the controller should be created from
  49462. */
  49463. constructor(vrGamepad: any);
  49464. /**
  49465. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49466. * @param scene scene in which to add meshes
  49467. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49468. */
  49469. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49470. /**
  49471. * Called once for each button that changed state since the last frame
  49472. * @param buttonIdx Which button index changed
  49473. * @param state New state of the button
  49474. * @param changes Which properties on the state changed since last frame
  49475. */
  49476. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49477. }
  49478. }
  49479. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49480. import { Scene } from "babylonjs/scene";
  49481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49482. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49483. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49484. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49485. /**
  49486. * Gear VR Controller
  49487. */
  49488. export class GearVRController extends WebVRController {
  49489. /**
  49490. * Base Url for the controller model.
  49491. */
  49492. static MODEL_BASE_URL: string;
  49493. /**
  49494. * File name for the controller model.
  49495. */
  49496. static MODEL_FILENAME: string;
  49497. /**
  49498. * Gamepad Id prefix used to identify this controller.
  49499. */
  49500. static readonly GAMEPAD_ID_PREFIX: string;
  49501. private readonly _buttonIndexToObservableNameMap;
  49502. /**
  49503. * Creates a new GearVRController from a gamepad
  49504. * @param vrGamepad the gamepad that the controller should be created from
  49505. */
  49506. constructor(vrGamepad: any);
  49507. /**
  49508. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49509. * @param scene scene in which to add meshes
  49510. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49511. */
  49512. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49513. /**
  49514. * Called once for each button that changed state since the last frame
  49515. * @param buttonIdx Which button index changed
  49516. * @param state New state of the button
  49517. * @param changes Which properties on the state changed since last frame
  49518. */
  49519. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49520. }
  49521. }
  49522. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49523. import { Scene } from "babylonjs/scene";
  49524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49525. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49526. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49527. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49528. /**
  49529. * Generic Controller
  49530. */
  49531. export class GenericController extends WebVRController {
  49532. /**
  49533. * Base Url for the controller model.
  49534. */
  49535. static readonly MODEL_BASE_URL: string;
  49536. /**
  49537. * File name for the controller model.
  49538. */
  49539. static readonly MODEL_FILENAME: string;
  49540. /**
  49541. * Creates a new GenericController from a gamepad
  49542. * @param vrGamepad the gamepad that the controller should be created from
  49543. */
  49544. constructor(vrGamepad: any);
  49545. /**
  49546. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49547. * @param scene scene in which to add meshes
  49548. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49549. */
  49550. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49551. /**
  49552. * Called once for each button that changed state since the last frame
  49553. * @param buttonIdx Which button index changed
  49554. * @param state New state of the button
  49555. * @param changes Which properties on the state changed since last frame
  49556. */
  49557. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49558. }
  49559. }
  49560. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49561. import { Observable } from "babylonjs/Misc/observable";
  49562. import { Scene } from "babylonjs/scene";
  49563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49564. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49565. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49566. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49567. /**
  49568. * Oculus Touch Controller
  49569. */
  49570. export class OculusTouchController extends WebVRController {
  49571. /**
  49572. * Base Url for the controller model.
  49573. */
  49574. static MODEL_BASE_URL: string;
  49575. /**
  49576. * File name for the left controller model.
  49577. */
  49578. static MODEL_LEFT_FILENAME: string;
  49579. /**
  49580. * File name for the right controller model.
  49581. */
  49582. static MODEL_RIGHT_FILENAME: string;
  49583. /**
  49584. * Base Url for the Quest controller model.
  49585. */
  49586. static QUEST_MODEL_BASE_URL: string;
  49587. /**
  49588. * @hidden
  49589. * If the controllers are running on a device that needs the updated Quest controller models
  49590. */
  49591. static _IsQuest: boolean;
  49592. /**
  49593. * Fired when the secondary trigger on this controller is modified
  49594. */
  49595. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49596. /**
  49597. * Fired when the thumb rest on this controller is modified
  49598. */
  49599. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49600. /**
  49601. * Creates a new OculusTouchController from a gamepad
  49602. * @param vrGamepad the gamepad that the controller should be created from
  49603. */
  49604. constructor(vrGamepad: any);
  49605. /**
  49606. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49607. * @param scene scene in which to add meshes
  49608. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49609. */
  49610. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49611. /**
  49612. * Fired when the A button on this controller is modified
  49613. */
  49614. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49615. /**
  49616. * Fired when the B button on this controller is modified
  49617. */
  49618. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49619. /**
  49620. * Fired when the X button on this controller is modified
  49621. */
  49622. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49623. /**
  49624. * Fired when the Y button on this controller is modified
  49625. */
  49626. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49627. /**
  49628. * Called once for each button that changed state since the last frame
  49629. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49630. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49631. * 2) secondary trigger (same)
  49632. * 3) A (right) X (left), touch, pressed = value
  49633. * 4) B / Y
  49634. * 5) thumb rest
  49635. * @param buttonIdx Which button index changed
  49636. * @param state New state of the button
  49637. * @param changes Which properties on the state changed since last frame
  49638. */
  49639. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49640. }
  49641. }
  49642. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49643. import { Scene } from "babylonjs/scene";
  49644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49645. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49646. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49647. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49648. import { Observable } from "babylonjs/Misc/observable";
  49649. /**
  49650. * Vive Controller
  49651. */
  49652. export class ViveController extends WebVRController {
  49653. /**
  49654. * Base Url for the controller model.
  49655. */
  49656. static MODEL_BASE_URL: string;
  49657. /**
  49658. * File name for the controller model.
  49659. */
  49660. static MODEL_FILENAME: string;
  49661. /**
  49662. * Creates a new ViveController from a gamepad
  49663. * @param vrGamepad the gamepad that the controller should be created from
  49664. */
  49665. constructor(vrGamepad: any);
  49666. /**
  49667. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49668. * @param scene scene in which to add meshes
  49669. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49670. */
  49671. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49672. /**
  49673. * Fired when the left button on this controller is modified
  49674. */
  49675. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49676. /**
  49677. * Fired when the right button on this controller is modified
  49678. */
  49679. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49680. /**
  49681. * Fired when the menu button on this controller is modified
  49682. */
  49683. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49684. /**
  49685. * Called once for each button that changed state since the last frame
  49686. * Vive mapping:
  49687. * 0: touchpad
  49688. * 1: trigger
  49689. * 2: left AND right buttons
  49690. * 3: menu button
  49691. * @param buttonIdx Which button index changed
  49692. * @param state New state of the button
  49693. * @param changes Which properties on the state changed since last frame
  49694. */
  49695. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49696. }
  49697. }
  49698. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49699. import { Observable } from "babylonjs/Misc/observable";
  49700. import { Scene } from "babylonjs/scene";
  49701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49702. import { Ray } from "babylonjs/Culling/ray";
  49703. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49704. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49705. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49706. /**
  49707. * Defines the WindowsMotionController object that the state of the windows motion controller
  49708. */
  49709. export class WindowsMotionController extends WebVRController {
  49710. /**
  49711. * The base url used to load the left and right controller models
  49712. */
  49713. static MODEL_BASE_URL: string;
  49714. /**
  49715. * The name of the left controller model file
  49716. */
  49717. static MODEL_LEFT_FILENAME: string;
  49718. /**
  49719. * The name of the right controller model file
  49720. */
  49721. static MODEL_RIGHT_FILENAME: string;
  49722. /**
  49723. * The controller name prefix for this controller type
  49724. */
  49725. static readonly GAMEPAD_ID_PREFIX: string;
  49726. /**
  49727. * The controller id pattern for this controller type
  49728. */
  49729. private static readonly GAMEPAD_ID_PATTERN;
  49730. private _loadedMeshInfo;
  49731. protected readonly _mapping: {
  49732. buttons: string[];
  49733. buttonMeshNames: {
  49734. 'trigger': string;
  49735. 'menu': string;
  49736. 'grip': string;
  49737. 'thumbstick': string;
  49738. 'trackpad': string;
  49739. };
  49740. buttonObservableNames: {
  49741. 'trigger': string;
  49742. 'menu': string;
  49743. 'grip': string;
  49744. 'thumbstick': string;
  49745. 'trackpad': string;
  49746. };
  49747. axisMeshNames: string[];
  49748. pointingPoseMeshName: string;
  49749. };
  49750. /**
  49751. * Fired when the trackpad on this controller is clicked
  49752. */
  49753. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49754. /**
  49755. * Fired when the trackpad on this controller is modified
  49756. */
  49757. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49758. /**
  49759. * The current x and y values of this controller's trackpad
  49760. */
  49761. trackpad: StickValues;
  49762. /**
  49763. * Creates a new WindowsMotionController from a gamepad
  49764. * @param vrGamepad the gamepad that the controller should be created from
  49765. */
  49766. constructor(vrGamepad: any);
  49767. /**
  49768. * Fired when the trigger on this controller is modified
  49769. */
  49770. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49771. /**
  49772. * Fired when the menu button on this controller is modified
  49773. */
  49774. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49775. /**
  49776. * Fired when the grip button on this controller is modified
  49777. */
  49778. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49779. /**
  49780. * Fired when the thumbstick button on this controller is modified
  49781. */
  49782. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49783. /**
  49784. * Fired when the touchpad button on this controller is modified
  49785. */
  49786. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49787. /**
  49788. * Fired when the touchpad values on this controller are modified
  49789. */
  49790. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  49791. protected _updateTrackpad(): void;
  49792. /**
  49793. * Called once per frame by the engine.
  49794. */
  49795. update(): void;
  49796. /**
  49797. * Called once for each button that changed state since the last frame
  49798. * @param buttonIdx Which button index changed
  49799. * @param state New state of the button
  49800. * @param changes Which properties on the state changed since last frame
  49801. */
  49802. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49803. /**
  49804. * Moves the buttons on the controller mesh based on their current state
  49805. * @param buttonName the name of the button to move
  49806. * @param buttonValue the value of the button which determines the buttons new position
  49807. */
  49808. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  49809. /**
  49810. * Moves the axis on the controller mesh based on its current state
  49811. * @param axis the index of the axis
  49812. * @param axisValue the value of the axis which determines the meshes new position
  49813. * @hidden
  49814. */
  49815. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  49816. /**
  49817. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49818. * @param scene scene in which to add meshes
  49819. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49820. */
  49821. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  49822. /**
  49823. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  49824. * can be transformed by button presses and axes values, based on this._mapping.
  49825. *
  49826. * @param scene scene in which the meshes exist
  49827. * @param meshes list of meshes that make up the controller model to process
  49828. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  49829. */
  49830. private processModel;
  49831. private createMeshInfo;
  49832. /**
  49833. * Gets the ray of the controller in the direction the controller is pointing
  49834. * @param length the length the resulting ray should be
  49835. * @returns a ray in the direction the controller is pointing
  49836. */
  49837. getForwardRay(length?: number): Ray;
  49838. /**
  49839. * Disposes of the controller
  49840. */
  49841. dispose(): void;
  49842. }
  49843. /**
  49844. * This class represents a new windows motion controller in XR.
  49845. */
  49846. export class XRWindowsMotionController extends WindowsMotionController {
  49847. /**
  49848. * Changing the original WIndowsMotionController mapping to fir the new mapping
  49849. */
  49850. protected readonly _mapping: {
  49851. buttons: string[];
  49852. buttonMeshNames: {
  49853. 'trigger': string;
  49854. 'menu': string;
  49855. 'grip': string;
  49856. 'thumbstick': string;
  49857. 'trackpad': string;
  49858. };
  49859. buttonObservableNames: {
  49860. 'trigger': string;
  49861. 'menu': string;
  49862. 'grip': string;
  49863. 'thumbstick': string;
  49864. 'trackpad': string;
  49865. };
  49866. axisMeshNames: string[];
  49867. pointingPoseMeshName: string;
  49868. };
  49869. /**
  49870. * Construct a new XR-Based windows motion controller
  49871. *
  49872. * @param gamepadInfo the gamepad object from the browser
  49873. */
  49874. constructor(gamepadInfo: any);
  49875. /**
  49876. * holds the thumbstick values (X,Y)
  49877. */
  49878. thumbstickValues: StickValues;
  49879. /**
  49880. * Fired when the thumbstick on this controller is clicked
  49881. */
  49882. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  49883. /**
  49884. * Fired when the thumbstick on this controller is modified
  49885. */
  49886. onThumbstickValuesChangedObservable: Observable<StickValues>;
  49887. /**
  49888. * Fired when the touchpad button on this controller is modified
  49889. */
  49890. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49891. /**
  49892. * Fired when the touchpad values on this controller are modified
  49893. */
  49894. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49895. /**
  49896. * Fired when the thumbstick button on this controller is modified
  49897. * here to prevent breaking changes
  49898. */
  49899. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49900. /**
  49901. * updating the thumbstick(!) and not the trackpad.
  49902. * This is named this way due to the difference between WebVR and XR and to avoid
  49903. * changing the parent class.
  49904. */
  49905. protected _updateTrackpad(): void;
  49906. /**
  49907. * Disposes the class with joy
  49908. */
  49909. dispose(): void;
  49910. }
  49911. }
  49912. declare module "babylonjs/Gamepads/Controllers/index" {
  49913. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  49914. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  49915. export * from "babylonjs/Gamepads/Controllers/genericController";
  49916. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  49917. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49918. export * from "babylonjs/Gamepads/Controllers/viveController";
  49919. export * from "babylonjs/Gamepads/Controllers/webVRController";
  49920. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  49921. }
  49922. declare module "babylonjs/Gamepads/index" {
  49923. export * from "babylonjs/Gamepads/Controllers/index";
  49924. export * from "babylonjs/Gamepads/gamepad";
  49925. export * from "babylonjs/Gamepads/gamepadManager";
  49926. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  49927. export * from "babylonjs/Gamepads/xboxGamepad";
  49928. export * from "babylonjs/Gamepads/dualShockGamepad";
  49929. }
  49930. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  49931. import { Scene } from "babylonjs/scene";
  49932. import { Vector4 } from "babylonjs/Maths/math.vector";
  49933. import { Color4 } from "babylonjs/Maths/math.color";
  49934. import { Mesh } from "babylonjs/Meshes/mesh";
  49935. import { Nullable } from "babylonjs/types";
  49936. /**
  49937. * Class containing static functions to help procedurally build meshes
  49938. */
  49939. export class PolyhedronBuilder {
  49940. /**
  49941. * Creates a polyhedron mesh
  49942. * * 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
  49943. * * The parameter `size` (positive float, default 1) sets the polygon size
  49944. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49945. * * 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`
  49946. * * 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
  49947. * * 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)`)
  49948. * * 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
  49949. * * 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
  49950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49953. * @param name defines the name of the mesh
  49954. * @param options defines the options used to create the mesh
  49955. * @param scene defines the hosting scene
  49956. * @returns the polyhedron mesh
  49957. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49958. */
  49959. static CreatePolyhedron(name: string, options: {
  49960. type?: number;
  49961. size?: number;
  49962. sizeX?: number;
  49963. sizeY?: number;
  49964. sizeZ?: number;
  49965. custom?: any;
  49966. faceUV?: Vector4[];
  49967. faceColors?: Color4[];
  49968. flat?: boolean;
  49969. updatable?: boolean;
  49970. sideOrientation?: number;
  49971. frontUVs?: Vector4;
  49972. backUVs?: Vector4;
  49973. }, scene?: Nullable<Scene>): Mesh;
  49974. }
  49975. }
  49976. declare module "babylonjs/Gizmos/scaleGizmo" {
  49977. import { Observable } from "babylonjs/Misc/observable";
  49978. import { Nullable } from "babylonjs/types";
  49979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49980. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49981. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  49982. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49983. /**
  49984. * Gizmo that enables scaling a mesh along 3 axis
  49985. */
  49986. export class ScaleGizmo extends Gizmo {
  49987. /**
  49988. * Internal gizmo used for interactions on the x axis
  49989. */
  49990. xGizmo: AxisScaleGizmo;
  49991. /**
  49992. * Internal gizmo used for interactions on the y axis
  49993. */
  49994. yGizmo: AxisScaleGizmo;
  49995. /**
  49996. * Internal gizmo used for interactions on the z axis
  49997. */
  49998. zGizmo: AxisScaleGizmo;
  49999. /**
  50000. * Internal gizmo used to scale all axis equally
  50001. */
  50002. uniformScaleGizmo: AxisScaleGizmo;
  50003. private _meshAttached;
  50004. private _updateGizmoRotationToMatchAttachedMesh;
  50005. private _snapDistance;
  50006. private _scaleRatio;
  50007. private _uniformScalingMesh;
  50008. private _octahedron;
  50009. private _sensitivity;
  50010. /** Fires an event when any of it's sub gizmos are dragged */
  50011. onDragStartObservable: Observable<unknown>;
  50012. /** Fires an event when any of it's sub gizmos are released from dragging */
  50013. onDragEndObservable: Observable<unknown>;
  50014. get attachedMesh(): Nullable<AbstractMesh>;
  50015. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50016. /**
  50017. * Creates a ScaleGizmo
  50018. * @param gizmoLayer The utility layer the gizmo will be added to
  50019. */
  50020. constructor(gizmoLayer?: UtilityLayerRenderer);
  50021. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50022. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50023. /**
  50024. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50025. */
  50026. set snapDistance(value: number);
  50027. get snapDistance(): number;
  50028. /**
  50029. * Ratio for the scale of the gizmo (Default: 1)
  50030. */
  50031. set scaleRatio(value: number);
  50032. get scaleRatio(): number;
  50033. /**
  50034. * Sensitivity factor for dragging (Default: 1)
  50035. */
  50036. set sensitivity(value: number);
  50037. get sensitivity(): number;
  50038. /**
  50039. * Disposes of the gizmo
  50040. */
  50041. dispose(): void;
  50042. }
  50043. }
  50044. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50045. import { Observable } from "babylonjs/Misc/observable";
  50046. import { Nullable } from "babylonjs/types";
  50047. import { Vector3 } from "babylonjs/Maths/math.vector";
  50048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50049. import { Mesh } from "babylonjs/Meshes/mesh";
  50050. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50051. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50052. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50053. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50054. import { Color3 } from "babylonjs/Maths/math.color";
  50055. /**
  50056. * Single axis scale gizmo
  50057. */
  50058. export class AxisScaleGizmo extends Gizmo {
  50059. /**
  50060. * Drag behavior responsible for the gizmos dragging interactions
  50061. */
  50062. dragBehavior: PointerDragBehavior;
  50063. private _pointerObserver;
  50064. /**
  50065. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50066. */
  50067. snapDistance: number;
  50068. /**
  50069. * Event that fires each time the gizmo snaps to a new location.
  50070. * * snapDistance is the the change in distance
  50071. */
  50072. onSnapObservable: Observable<{
  50073. snapDistance: number;
  50074. }>;
  50075. /**
  50076. * If the scaling operation should be done on all axis (default: false)
  50077. */
  50078. uniformScaling: boolean;
  50079. /**
  50080. * Custom sensitivity value for the drag strength
  50081. */
  50082. sensitivity: number;
  50083. private _isEnabled;
  50084. private _parent;
  50085. private _arrow;
  50086. private _coloredMaterial;
  50087. private _hoverMaterial;
  50088. /**
  50089. * Creates an AxisScaleGizmo
  50090. * @param gizmoLayer The utility layer the gizmo will be added to
  50091. * @param dragAxis The axis which the gizmo will be able to scale on
  50092. * @param color The color of the gizmo
  50093. */
  50094. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50095. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50096. /**
  50097. * If the gizmo is enabled
  50098. */
  50099. set isEnabled(value: boolean);
  50100. get isEnabled(): boolean;
  50101. /**
  50102. * Disposes of the gizmo
  50103. */
  50104. dispose(): void;
  50105. /**
  50106. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50107. * @param mesh The mesh to replace the default mesh of the gizmo
  50108. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50109. */
  50110. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50111. }
  50112. }
  50113. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50114. import { Observable } from "babylonjs/Misc/observable";
  50115. import { Nullable } from "babylonjs/types";
  50116. import { Vector3 } from "babylonjs/Maths/math.vector";
  50117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50118. import { Mesh } from "babylonjs/Meshes/mesh";
  50119. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50120. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50121. import { Color3 } from "babylonjs/Maths/math.color";
  50122. import "babylonjs/Meshes/Builders/boxBuilder";
  50123. /**
  50124. * Bounding box gizmo
  50125. */
  50126. export class BoundingBoxGizmo extends Gizmo {
  50127. private _lineBoundingBox;
  50128. private _rotateSpheresParent;
  50129. private _scaleBoxesParent;
  50130. private _boundingDimensions;
  50131. private _renderObserver;
  50132. private _pointerObserver;
  50133. private _scaleDragSpeed;
  50134. private _tmpQuaternion;
  50135. private _tmpVector;
  50136. private _tmpRotationMatrix;
  50137. /**
  50138. * 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)
  50139. */
  50140. ignoreChildren: boolean;
  50141. /**
  50142. * 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)
  50143. */
  50144. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50145. /**
  50146. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50147. */
  50148. rotationSphereSize: number;
  50149. /**
  50150. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50151. */
  50152. scaleBoxSize: number;
  50153. /**
  50154. * 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)
  50155. */
  50156. fixedDragMeshScreenSize: boolean;
  50157. /**
  50158. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50159. */
  50160. fixedDragMeshScreenSizeDistanceFactor: number;
  50161. /**
  50162. * Fired when a rotation sphere or scale box is dragged
  50163. */
  50164. onDragStartObservable: Observable<{}>;
  50165. /**
  50166. * Fired when a scale box is dragged
  50167. */
  50168. onScaleBoxDragObservable: Observable<{}>;
  50169. /**
  50170. * Fired when a scale box drag is ended
  50171. */
  50172. onScaleBoxDragEndObservable: Observable<{}>;
  50173. /**
  50174. * Fired when a rotation sphere is dragged
  50175. */
  50176. onRotationSphereDragObservable: Observable<{}>;
  50177. /**
  50178. * Fired when a rotation sphere drag is ended
  50179. */
  50180. onRotationSphereDragEndObservable: Observable<{}>;
  50181. /**
  50182. * 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)
  50183. */
  50184. scalePivot: Nullable<Vector3>;
  50185. /**
  50186. * Mesh used as a pivot to rotate the attached mesh
  50187. */
  50188. private _anchorMesh;
  50189. private _existingMeshScale;
  50190. private _dragMesh;
  50191. private pointerDragBehavior;
  50192. private coloredMaterial;
  50193. private hoverColoredMaterial;
  50194. /**
  50195. * Sets the color of the bounding box gizmo
  50196. * @param color the color to set
  50197. */
  50198. setColor(color: Color3): void;
  50199. /**
  50200. * Creates an BoundingBoxGizmo
  50201. * @param gizmoLayer The utility layer the gizmo will be added to
  50202. * @param color The color of the gizmo
  50203. */
  50204. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50205. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50206. private _selectNode;
  50207. /**
  50208. * Updates the bounding box information for the Gizmo
  50209. */
  50210. updateBoundingBox(): void;
  50211. private _updateRotationSpheres;
  50212. private _updateScaleBoxes;
  50213. /**
  50214. * Enables rotation on the specified axis and disables rotation on the others
  50215. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50216. */
  50217. setEnabledRotationAxis(axis: string): void;
  50218. /**
  50219. * Enables/disables scaling
  50220. * @param enable if scaling should be enabled
  50221. */
  50222. setEnabledScaling(enable: boolean): void;
  50223. private _updateDummy;
  50224. /**
  50225. * Enables a pointer drag behavior on the bounding box of the gizmo
  50226. */
  50227. enableDragBehavior(): void;
  50228. /**
  50229. * Disposes of the gizmo
  50230. */
  50231. dispose(): void;
  50232. /**
  50233. * 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)
  50234. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50235. * @returns the bounding box mesh with the passed in mesh as a child
  50236. */
  50237. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50238. /**
  50239. * CustomMeshes are not supported by this gizmo
  50240. * @param mesh The mesh to replace the default mesh of the gizmo
  50241. */
  50242. setCustomMesh(mesh: Mesh): void;
  50243. }
  50244. }
  50245. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50246. import { Observable } from "babylonjs/Misc/observable";
  50247. import { Nullable } from "babylonjs/types";
  50248. import { Vector3 } from "babylonjs/Maths/math.vector";
  50249. import { Color3 } from "babylonjs/Maths/math.color";
  50250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50251. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50252. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50253. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50254. import "babylonjs/Meshes/Builders/linesBuilder";
  50255. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50256. /**
  50257. * Single plane rotation gizmo
  50258. */
  50259. export class PlaneRotationGizmo extends Gizmo {
  50260. /**
  50261. * Drag behavior responsible for the gizmos dragging interactions
  50262. */
  50263. dragBehavior: PointerDragBehavior;
  50264. private _pointerObserver;
  50265. /**
  50266. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50267. */
  50268. snapDistance: number;
  50269. /**
  50270. * Event that fires each time the gizmo snaps to a new location.
  50271. * * snapDistance is the the change in distance
  50272. */
  50273. onSnapObservable: Observable<{
  50274. snapDistance: number;
  50275. }>;
  50276. private _isEnabled;
  50277. private _parent;
  50278. /**
  50279. * Creates a PlaneRotationGizmo
  50280. * @param gizmoLayer The utility layer the gizmo will be added to
  50281. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50282. * @param color The color of the gizmo
  50283. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50284. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50285. */
  50286. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50287. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50288. /**
  50289. * If the gizmo is enabled
  50290. */
  50291. set isEnabled(value: boolean);
  50292. get isEnabled(): boolean;
  50293. /**
  50294. * Disposes of the gizmo
  50295. */
  50296. dispose(): void;
  50297. }
  50298. }
  50299. declare module "babylonjs/Gizmos/rotationGizmo" {
  50300. import { Observable } from "babylonjs/Misc/observable";
  50301. import { Nullable } from "babylonjs/types";
  50302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50303. import { Mesh } from "babylonjs/Meshes/mesh";
  50304. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50305. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50306. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50307. /**
  50308. * Gizmo that enables rotating a mesh along 3 axis
  50309. */
  50310. export class RotationGizmo extends Gizmo {
  50311. /**
  50312. * Internal gizmo used for interactions on the x axis
  50313. */
  50314. xGizmo: PlaneRotationGizmo;
  50315. /**
  50316. * Internal gizmo used for interactions on the y axis
  50317. */
  50318. yGizmo: PlaneRotationGizmo;
  50319. /**
  50320. * Internal gizmo used for interactions on the z axis
  50321. */
  50322. zGizmo: PlaneRotationGizmo;
  50323. /** Fires an event when any of it's sub gizmos are dragged */
  50324. onDragStartObservable: Observable<unknown>;
  50325. /** Fires an event when any of it's sub gizmos are released from dragging */
  50326. onDragEndObservable: Observable<unknown>;
  50327. private _meshAttached;
  50328. get attachedMesh(): Nullable<AbstractMesh>;
  50329. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50330. /**
  50331. * Creates a RotationGizmo
  50332. * @param gizmoLayer The utility layer the gizmo will be added to
  50333. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50334. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50335. */
  50336. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50337. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50338. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50339. /**
  50340. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50341. */
  50342. set snapDistance(value: number);
  50343. get snapDistance(): number;
  50344. /**
  50345. * Ratio for the scale of the gizmo (Default: 1)
  50346. */
  50347. set scaleRatio(value: number);
  50348. get scaleRatio(): number;
  50349. /**
  50350. * Disposes of the gizmo
  50351. */
  50352. dispose(): void;
  50353. /**
  50354. * CustomMeshes are not supported by this gizmo
  50355. * @param mesh The mesh to replace the default mesh of the gizmo
  50356. */
  50357. setCustomMesh(mesh: Mesh): void;
  50358. }
  50359. }
  50360. declare module "babylonjs/Gizmos/gizmoManager" {
  50361. import { Observable } from "babylonjs/Misc/observable";
  50362. import { Nullable } from "babylonjs/types";
  50363. import { Scene, IDisposable } from "babylonjs/scene";
  50364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50365. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50366. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50367. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50368. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50369. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50370. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50371. /**
  50372. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50373. */
  50374. export class GizmoManager implements IDisposable {
  50375. private scene;
  50376. /**
  50377. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50378. */
  50379. gizmos: {
  50380. positionGizmo: Nullable<PositionGizmo>;
  50381. rotationGizmo: Nullable<RotationGizmo>;
  50382. scaleGizmo: Nullable<ScaleGizmo>;
  50383. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50384. };
  50385. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50386. clearGizmoOnEmptyPointerEvent: boolean;
  50387. /** Fires an event when the manager is attached to a mesh */
  50388. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50389. private _gizmosEnabled;
  50390. private _pointerObserver;
  50391. private _attachedMesh;
  50392. private _boundingBoxColor;
  50393. private _defaultUtilityLayer;
  50394. private _defaultKeepDepthUtilityLayer;
  50395. /**
  50396. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50397. */
  50398. boundingBoxDragBehavior: SixDofDragBehavior;
  50399. /**
  50400. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50401. */
  50402. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50403. /**
  50404. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50405. */
  50406. usePointerToAttachGizmos: boolean;
  50407. /**
  50408. * Utility layer that the bounding box gizmo belongs to
  50409. */
  50410. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50411. /**
  50412. * Utility layer that all gizmos besides bounding box belong to
  50413. */
  50414. get utilityLayer(): UtilityLayerRenderer;
  50415. /**
  50416. * Instatiates a gizmo manager
  50417. * @param scene the scene to overlay the gizmos on top of
  50418. */
  50419. constructor(scene: Scene);
  50420. /**
  50421. * Attaches a set of gizmos to the specified mesh
  50422. * @param mesh The mesh the gizmo's should be attached to
  50423. */
  50424. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50425. /**
  50426. * If the position gizmo is enabled
  50427. */
  50428. set positionGizmoEnabled(value: boolean);
  50429. get positionGizmoEnabled(): boolean;
  50430. /**
  50431. * If the rotation gizmo is enabled
  50432. */
  50433. set rotationGizmoEnabled(value: boolean);
  50434. get rotationGizmoEnabled(): boolean;
  50435. /**
  50436. * If the scale gizmo is enabled
  50437. */
  50438. set scaleGizmoEnabled(value: boolean);
  50439. get scaleGizmoEnabled(): boolean;
  50440. /**
  50441. * If the boundingBox gizmo is enabled
  50442. */
  50443. set boundingBoxGizmoEnabled(value: boolean);
  50444. get boundingBoxGizmoEnabled(): boolean;
  50445. /**
  50446. * Disposes of the gizmo manager
  50447. */
  50448. dispose(): void;
  50449. }
  50450. }
  50451. declare module "babylonjs/Lights/directionalLight" {
  50452. import { Camera } from "babylonjs/Cameras/camera";
  50453. import { Scene } from "babylonjs/scene";
  50454. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50456. import { Light } from "babylonjs/Lights/light";
  50457. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50458. import { Effect } from "babylonjs/Materials/effect";
  50459. /**
  50460. * A directional light is defined by a direction (what a surprise!).
  50461. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50462. * 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.
  50463. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50464. */
  50465. export class DirectionalLight extends ShadowLight {
  50466. private _shadowFrustumSize;
  50467. /**
  50468. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50469. */
  50470. get shadowFrustumSize(): number;
  50471. /**
  50472. * Specifies a fix frustum size for the shadow generation.
  50473. */
  50474. set shadowFrustumSize(value: number);
  50475. private _shadowOrthoScale;
  50476. /**
  50477. * Gets the shadow projection scale against the optimal computed one.
  50478. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50479. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50480. */
  50481. get shadowOrthoScale(): number;
  50482. /**
  50483. * Sets the shadow projection scale against the optimal computed one.
  50484. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50485. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50486. */
  50487. set shadowOrthoScale(value: number);
  50488. /**
  50489. * Automatically compute the projection matrix to best fit (including all the casters)
  50490. * on each frame.
  50491. */
  50492. autoUpdateExtends: boolean;
  50493. /**
  50494. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50495. * on each frame. autoUpdateExtends must be set to true for this to work
  50496. */
  50497. autoCalcShadowZBounds: boolean;
  50498. private _orthoLeft;
  50499. private _orthoRight;
  50500. private _orthoTop;
  50501. private _orthoBottom;
  50502. /**
  50503. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50504. * The directional light is emitted from everywhere in the given direction.
  50505. * It can cast shadows.
  50506. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50507. * @param name The friendly name of the light
  50508. * @param direction The direction of the light
  50509. * @param scene The scene the light belongs to
  50510. */
  50511. constructor(name: string, direction: Vector3, scene: Scene);
  50512. /**
  50513. * Returns the string "DirectionalLight".
  50514. * @return The class name
  50515. */
  50516. getClassName(): string;
  50517. /**
  50518. * Returns the integer 1.
  50519. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50520. */
  50521. getTypeID(): number;
  50522. /**
  50523. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50524. * Returns the DirectionalLight Shadow projection matrix.
  50525. */
  50526. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50527. /**
  50528. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50529. * Returns the DirectionalLight Shadow projection matrix.
  50530. */
  50531. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50532. /**
  50533. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50534. * Returns the DirectionalLight Shadow projection matrix.
  50535. */
  50536. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50537. protected _buildUniformLayout(): void;
  50538. /**
  50539. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50540. * @param effect The effect to update
  50541. * @param lightIndex The index of the light in the effect to update
  50542. * @returns The directional light
  50543. */
  50544. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50545. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50546. /**
  50547. * Gets the minZ used for shadow according to both the scene and the light.
  50548. *
  50549. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50550. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50551. * @param activeCamera The camera we are returning the min for
  50552. * @returns the depth min z
  50553. */
  50554. getDepthMinZ(activeCamera: Camera): number;
  50555. /**
  50556. * Gets the maxZ used for shadow according to both the scene and the light.
  50557. *
  50558. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50559. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50560. * @param activeCamera The camera we are returning the max for
  50561. * @returns the depth max z
  50562. */
  50563. getDepthMaxZ(activeCamera: Camera): number;
  50564. /**
  50565. * Prepares the list of defines specific to the light type.
  50566. * @param defines the list of defines
  50567. * @param lightIndex defines the index of the light for the effect
  50568. */
  50569. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50570. }
  50571. }
  50572. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50573. import { Mesh } from "babylonjs/Meshes/mesh";
  50574. /**
  50575. * Class containing static functions to help procedurally build meshes
  50576. */
  50577. export class HemisphereBuilder {
  50578. /**
  50579. * Creates a hemisphere mesh
  50580. * @param name defines the name of the mesh
  50581. * @param options defines the options used to create the mesh
  50582. * @param scene defines the hosting scene
  50583. * @returns the hemisphere mesh
  50584. */
  50585. static CreateHemisphere(name: string, options: {
  50586. segments?: number;
  50587. diameter?: number;
  50588. sideOrientation?: number;
  50589. }, scene: any): Mesh;
  50590. }
  50591. }
  50592. declare module "babylonjs/Lights/spotLight" {
  50593. import { Nullable } from "babylonjs/types";
  50594. import { Scene } from "babylonjs/scene";
  50595. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50597. import { Effect } from "babylonjs/Materials/effect";
  50598. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50599. import { Light } from "babylonjs/Lights/light";
  50600. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50601. /**
  50602. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50603. * These values define a cone of light starting from the position, emitting toward the direction.
  50604. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50605. * and the exponent defines the speed of the decay of the light with distance (reach).
  50606. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50607. */
  50608. export class SpotLight extends ShadowLight {
  50609. private _angle;
  50610. private _innerAngle;
  50611. private _cosHalfAngle;
  50612. private _lightAngleScale;
  50613. private _lightAngleOffset;
  50614. /**
  50615. * Gets the cone angle of the spot light in Radians.
  50616. */
  50617. get angle(): number;
  50618. /**
  50619. * Sets the cone angle of the spot light in Radians.
  50620. */
  50621. set angle(value: number);
  50622. /**
  50623. * Only used in gltf falloff mode, this defines the angle where
  50624. * the directional falloff will start before cutting at angle which could be seen
  50625. * as outer angle.
  50626. */
  50627. get innerAngle(): number;
  50628. /**
  50629. * Only used in gltf falloff mode, this defines the angle where
  50630. * the directional falloff will start before cutting at angle which could be seen
  50631. * as outer angle.
  50632. */
  50633. set innerAngle(value: number);
  50634. private _shadowAngleScale;
  50635. /**
  50636. * Allows scaling the angle of the light for shadow generation only.
  50637. */
  50638. get shadowAngleScale(): number;
  50639. /**
  50640. * Allows scaling the angle of the light for shadow generation only.
  50641. */
  50642. set shadowAngleScale(value: number);
  50643. /**
  50644. * The light decay speed with the distance from the emission spot.
  50645. */
  50646. exponent: number;
  50647. private _projectionTextureMatrix;
  50648. /**
  50649. * Allows reading the projecton texture
  50650. */
  50651. get projectionTextureMatrix(): Matrix;
  50652. protected _projectionTextureLightNear: number;
  50653. /**
  50654. * Gets the near clip of the Spotlight for texture projection.
  50655. */
  50656. get projectionTextureLightNear(): number;
  50657. /**
  50658. * Sets the near clip of the Spotlight for texture projection.
  50659. */
  50660. set projectionTextureLightNear(value: number);
  50661. protected _projectionTextureLightFar: number;
  50662. /**
  50663. * Gets the far clip of the Spotlight for texture projection.
  50664. */
  50665. get projectionTextureLightFar(): number;
  50666. /**
  50667. * Sets the far clip of the Spotlight for texture projection.
  50668. */
  50669. set projectionTextureLightFar(value: number);
  50670. protected _projectionTextureUpDirection: Vector3;
  50671. /**
  50672. * Gets the Up vector of the Spotlight for texture projection.
  50673. */
  50674. get projectionTextureUpDirection(): Vector3;
  50675. /**
  50676. * Sets the Up vector of the Spotlight for texture projection.
  50677. */
  50678. set projectionTextureUpDirection(value: Vector3);
  50679. private _projectionTexture;
  50680. /**
  50681. * Gets the projection texture of the light.
  50682. */
  50683. get projectionTexture(): Nullable<BaseTexture>;
  50684. /**
  50685. * Sets the projection texture of the light.
  50686. */
  50687. set projectionTexture(value: Nullable<BaseTexture>);
  50688. private _projectionTextureViewLightDirty;
  50689. private _projectionTextureProjectionLightDirty;
  50690. private _projectionTextureDirty;
  50691. private _projectionTextureViewTargetVector;
  50692. private _projectionTextureViewLightMatrix;
  50693. private _projectionTextureProjectionLightMatrix;
  50694. private _projectionTextureScalingMatrix;
  50695. /**
  50696. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50697. * It can cast shadows.
  50698. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50699. * @param name The light friendly name
  50700. * @param position The position of the spot light in the scene
  50701. * @param direction The direction of the light in the scene
  50702. * @param angle The cone angle of the light in Radians
  50703. * @param exponent The light decay speed with the distance from the emission spot
  50704. * @param scene The scene the lights belongs to
  50705. */
  50706. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50707. /**
  50708. * Returns the string "SpotLight".
  50709. * @returns the class name
  50710. */
  50711. getClassName(): string;
  50712. /**
  50713. * Returns the integer 2.
  50714. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50715. */
  50716. getTypeID(): number;
  50717. /**
  50718. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50719. */
  50720. protected _setDirection(value: Vector3): void;
  50721. /**
  50722. * Overrides the position setter to recompute the projection texture view light Matrix.
  50723. */
  50724. protected _setPosition(value: Vector3): void;
  50725. /**
  50726. * 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.
  50727. * Returns the SpotLight.
  50728. */
  50729. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50730. protected _computeProjectionTextureViewLightMatrix(): void;
  50731. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50732. /**
  50733. * Main function for light texture projection matrix computing.
  50734. */
  50735. protected _computeProjectionTextureMatrix(): void;
  50736. protected _buildUniformLayout(): void;
  50737. private _computeAngleValues;
  50738. /**
  50739. * Sets the passed Effect "effect" with the Light textures.
  50740. * @param effect The effect to update
  50741. * @param lightIndex The index of the light in the effect to update
  50742. * @returns The light
  50743. */
  50744. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50745. /**
  50746. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50747. * @param effect The effect to update
  50748. * @param lightIndex The index of the light in the effect to update
  50749. * @returns The spot light
  50750. */
  50751. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50752. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50753. /**
  50754. * Disposes the light and the associated resources.
  50755. */
  50756. dispose(): void;
  50757. /**
  50758. * Prepares the list of defines specific to the light type.
  50759. * @param defines the list of defines
  50760. * @param lightIndex defines the index of the light for the effect
  50761. */
  50762. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50763. }
  50764. }
  50765. declare module "babylonjs/Gizmos/lightGizmo" {
  50766. import { Nullable } from "babylonjs/types";
  50767. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50768. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50769. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50770. import { Light } from "babylonjs/Lights/light";
  50771. /**
  50772. * Gizmo that enables viewing a light
  50773. */
  50774. export class LightGizmo extends Gizmo {
  50775. private _lightMesh;
  50776. private _material;
  50777. private _cachedPosition;
  50778. private _cachedForward;
  50779. private _attachedMeshParent;
  50780. /**
  50781. * Creates a LightGizmo
  50782. * @param gizmoLayer The utility layer the gizmo will be added to
  50783. */
  50784. constructor(gizmoLayer?: UtilityLayerRenderer);
  50785. private _light;
  50786. /**
  50787. * The light that the gizmo is attached to
  50788. */
  50789. set light(light: Nullable<Light>);
  50790. get light(): Nullable<Light>;
  50791. /**
  50792. * Gets the material used to render the light gizmo
  50793. */
  50794. get material(): StandardMaterial;
  50795. /**
  50796. * @hidden
  50797. * Updates the gizmo to match the attached mesh's position/rotation
  50798. */
  50799. protected _update(): void;
  50800. private static _Scale;
  50801. /**
  50802. * Creates the lines for a light mesh
  50803. */
  50804. private static _CreateLightLines;
  50805. /**
  50806. * Disposes of the light gizmo
  50807. */
  50808. dispose(): void;
  50809. private static _CreateHemisphericLightMesh;
  50810. private static _CreatePointLightMesh;
  50811. private static _CreateSpotLightMesh;
  50812. private static _CreateDirectionalLightMesh;
  50813. }
  50814. }
  50815. declare module "babylonjs/Gizmos/index" {
  50816. export * from "babylonjs/Gizmos/axisDragGizmo";
  50817. export * from "babylonjs/Gizmos/axisScaleGizmo";
  50818. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  50819. export * from "babylonjs/Gizmos/gizmo";
  50820. export * from "babylonjs/Gizmos/gizmoManager";
  50821. export * from "babylonjs/Gizmos/planeRotationGizmo";
  50822. export * from "babylonjs/Gizmos/positionGizmo";
  50823. export * from "babylonjs/Gizmos/rotationGizmo";
  50824. export * from "babylonjs/Gizmos/scaleGizmo";
  50825. export * from "babylonjs/Gizmos/lightGizmo";
  50826. export * from "babylonjs/Gizmos/planeDragGizmo";
  50827. }
  50828. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  50829. /** @hidden */
  50830. export var backgroundFragmentDeclaration: {
  50831. name: string;
  50832. shader: string;
  50833. };
  50834. }
  50835. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  50836. /** @hidden */
  50837. export var backgroundUboDeclaration: {
  50838. name: string;
  50839. shader: string;
  50840. };
  50841. }
  50842. declare module "babylonjs/Shaders/background.fragment" {
  50843. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50844. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50845. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50846. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50847. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50848. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50849. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50850. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50851. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50852. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50853. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50854. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50855. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50856. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50857. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50858. /** @hidden */
  50859. export var backgroundPixelShader: {
  50860. name: string;
  50861. shader: string;
  50862. };
  50863. }
  50864. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50865. /** @hidden */
  50866. export var backgroundVertexDeclaration: {
  50867. name: string;
  50868. shader: string;
  50869. };
  50870. }
  50871. declare module "babylonjs/Shaders/background.vertex" {
  50872. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50873. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50874. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50875. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50876. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50877. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50878. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50879. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50880. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50881. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50882. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50883. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50884. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50885. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50886. /** @hidden */
  50887. export var backgroundVertexShader: {
  50888. name: string;
  50889. shader: string;
  50890. };
  50891. }
  50892. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  50893. import { Nullable, int, float } from "babylonjs/types";
  50894. import { Scene } from "babylonjs/scene";
  50895. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50896. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50898. import { Mesh } from "babylonjs/Meshes/mesh";
  50899. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50900. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50901. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50902. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50903. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  50904. import { Color3 } from "babylonjs/Maths/math.color";
  50905. import "babylonjs/Shaders/background.fragment";
  50906. import "babylonjs/Shaders/background.vertex";
  50907. /**
  50908. * Background material used to create an efficient environement around your scene.
  50909. */
  50910. export class BackgroundMaterial extends PushMaterial {
  50911. /**
  50912. * Standard reflectance value at parallel view angle.
  50913. */
  50914. static StandardReflectance0: number;
  50915. /**
  50916. * Standard reflectance value at grazing angle.
  50917. */
  50918. static StandardReflectance90: number;
  50919. protected _primaryColor: Color3;
  50920. /**
  50921. * Key light Color (multiply against the environement texture)
  50922. */
  50923. primaryColor: Color3;
  50924. protected __perceptualColor: Nullable<Color3>;
  50925. /**
  50926. * Experimental Internal Use Only.
  50927. *
  50928. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50929. * This acts as a helper to set the primary color to a more "human friendly" value.
  50930. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50931. * output color as close as possible from the chosen value.
  50932. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50933. * part of lighting setup.)
  50934. */
  50935. get _perceptualColor(): Nullable<Color3>;
  50936. set _perceptualColor(value: Nullable<Color3>);
  50937. protected _primaryColorShadowLevel: float;
  50938. /**
  50939. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50940. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50941. */
  50942. get primaryColorShadowLevel(): float;
  50943. set primaryColorShadowLevel(value: float);
  50944. protected _primaryColorHighlightLevel: float;
  50945. /**
  50946. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50947. * The primary color is used at the level chosen to define what the white area would look.
  50948. */
  50949. get primaryColorHighlightLevel(): float;
  50950. set primaryColorHighlightLevel(value: float);
  50951. protected _reflectionTexture: Nullable<BaseTexture>;
  50952. /**
  50953. * Reflection Texture used in the material.
  50954. * Should be author in a specific way for the best result (refer to the documentation).
  50955. */
  50956. reflectionTexture: Nullable<BaseTexture>;
  50957. protected _reflectionBlur: float;
  50958. /**
  50959. * Reflection Texture level of blur.
  50960. *
  50961. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50962. * texture twice.
  50963. */
  50964. reflectionBlur: float;
  50965. protected _diffuseTexture: Nullable<BaseTexture>;
  50966. /**
  50967. * Diffuse Texture used in the material.
  50968. * Should be author in a specific way for the best result (refer to the documentation).
  50969. */
  50970. diffuseTexture: Nullable<BaseTexture>;
  50971. protected _shadowLights: Nullable<IShadowLight[]>;
  50972. /**
  50973. * Specify the list of lights casting shadow on the material.
  50974. * All scene shadow lights will be included if null.
  50975. */
  50976. shadowLights: Nullable<IShadowLight[]>;
  50977. protected _shadowLevel: float;
  50978. /**
  50979. * Helps adjusting the shadow to a softer level if required.
  50980. * 0 means black shadows and 1 means no shadows.
  50981. */
  50982. shadowLevel: float;
  50983. protected _sceneCenter: Vector3;
  50984. /**
  50985. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50986. * It is usually zero but might be interesting to modify according to your setup.
  50987. */
  50988. sceneCenter: Vector3;
  50989. protected _opacityFresnel: boolean;
  50990. /**
  50991. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50992. * This helps ensuring a nice transition when the camera goes under the ground.
  50993. */
  50994. opacityFresnel: boolean;
  50995. protected _reflectionFresnel: boolean;
  50996. /**
  50997. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50998. * This helps adding a mirror texture on the ground.
  50999. */
  51000. reflectionFresnel: boolean;
  51001. protected _reflectionFalloffDistance: number;
  51002. /**
  51003. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51004. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51005. */
  51006. reflectionFalloffDistance: number;
  51007. protected _reflectionAmount: number;
  51008. /**
  51009. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51010. */
  51011. reflectionAmount: number;
  51012. protected _reflectionReflectance0: number;
  51013. /**
  51014. * This specifies the weight of the reflection at grazing angle.
  51015. */
  51016. reflectionReflectance0: number;
  51017. protected _reflectionReflectance90: number;
  51018. /**
  51019. * This specifies the weight of the reflection at a perpendicular point of view.
  51020. */
  51021. reflectionReflectance90: number;
  51022. /**
  51023. * Sets the reflection reflectance fresnel values according to the default standard
  51024. * empirically know to work well :-)
  51025. */
  51026. set reflectionStandardFresnelWeight(value: number);
  51027. protected _useRGBColor: boolean;
  51028. /**
  51029. * Helps to directly use the maps channels instead of their level.
  51030. */
  51031. useRGBColor: boolean;
  51032. protected _enableNoise: boolean;
  51033. /**
  51034. * This helps reducing the banding effect that could occur on the background.
  51035. */
  51036. enableNoise: boolean;
  51037. /**
  51038. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51039. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51040. * Recommended to be keep at 1.0 except for special cases.
  51041. */
  51042. get fovMultiplier(): number;
  51043. set fovMultiplier(value: number);
  51044. private _fovMultiplier;
  51045. /**
  51046. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51047. */
  51048. useEquirectangularFOV: boolean;
  51049. private _maxSimultaneousLights;
  51050. /**
  51051. * Number of Simultaneous lights allowed on the material.
  51052. */
  51053. maxSimultaneousLights: int;
  51054. /**
  51055. * Default configuration related to image processing available in the Background Material.
  51056. */
  51057. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51058. /**
  51059. * Keep track of the image processing observer to allow dispose and replace.
  51060. */
  51061. private _imageProcessingObserver;
  51062. /**
  51063. * Attaches a new image processing configuration to the PBR Material.
  51064. * @param configuration (if null the scene configuration will be use)
  51065. */
  51066. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51067. /**
  51068. * Gets the image processing configuration used either in this material.
  51069. */
  51070. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51071. /**
  51072. * Sets the Default image processing configuration used either in the this material.
  51073. *
  51074. * If sets to null, the scene one is in use.
  51075. */
  51076. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51077. /**
  51078. * Gets wether the color curves effect is enabled.
  51079. */
  51080. get cameraColorCurvesEnabled(): boolean;
  51081. /**
  51082. * Sets wether the color curves effect is enabled.
  51083. */
  51084. set cameraColorCurvesEnabled(value: boolean);
  51085. /**
  51086. * Gets wether the color grading effect is enabled.
  51087. */
  51088. get cameraColorGradingEnabled(): boolean;
  51089. /**
  51090. * Gets wether the color grading effect is enabled.
  51091. */
  51092. set cameraColorGradingEnabled(value: boolean);
  51093. /**
  51094. * Gets wether tonemapping is enabled or not.
  51095. */
  51096. get cameraToneMappingEnabled(): boolean;
  51097. /**
  51098. * Sets wether tonemapping is enabled or not
  51099. */
  51100. set cameraToneMappingEnabled(value: boolean);
  51101. /**
  51102. * The camera exposure used on this material.
  51103. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51104. * This corresponds to a photographic exposure.
  51105. */
  51106. get cameraExposure(): float;
  51107. /**
  51108. * The camera exposure used on this material.
  51109. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51110. * This corresponds to a photographic exposure.
  51111. */
  51112. set cameraExposure(value: float);
  51113. /**
  51114. * Gets The camera contrast used on this material.
  51115. */
  51116. get cameraContrast(): float;
  51117. /**
  51118. * Sets The camera contrast used on this material.
  51119. */
  51120. set cameraContrast(value: float);
  51121. /**
  51122. * Gets the Color Grading 2D Lookup Texture.
  51123. */
  51124. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51125. /**
  51126. * Sets the Color Grading 2D Lookup Texture.
  51127. */
  51128. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51129. /**
  51130. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51131. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51132. * 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;
  51133. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51134. */
  51135. get cameraColorCurves(): Nullable<ColorCurves>;
  51136. /**
  51137. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51138. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51139. * 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;
  51140. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51141. */
  51142. set cameraColorCurves(value: Nullable<ColorCurves>);
  51143. /**
  51144. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51145. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51146. */
  51147. switchToBGR: boolean;
  51148. private _renderTargets;
  51149. private _reflectionControls;
  51150. private _white;
  51151. private _primaryShadowColor;
  51152. private _primaryHighlightColor;
  51153. /**
  51154. * Instantiates a Background Material in the given scene
  51155. * @param name The friendly name of the material
  51156. * @param scene The scene to add the material to
  51157. */
  51158. constructor(name: string, scene: Scene);
  51159. /**
  51160. * Gets a boolean indicating that current material needs to register RTT
  51161. */
  51162. get hasRenderTargetTextures(): boolean;
  51163. /**
  51164. * The entire material has been created in order to prevent overdraw.
  51165. * @returns false
  51166. */
  51167. needAlphaTesting(): boolean;
  51168. /**
  51169. * The entire material has been created in order to prevent overdraw.
  51170. * @returns true if blending is enable
  51171. */
  51172. needAlphaBlending(): boolean;
  51173. /**
  51174. * Checks wether the material is ready to be rendered for a given mesh.
  51175. * @param mesh The mesh to render
  51176. * @param subMesh The submesh to check against
  51177. * @param useInstances Specify wether or not the material is used with instances
  51178. * @returns true if all the dependencies are ready (Textures, Effects...)
  51179. */
  51180. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51181. /**
  51182. * Compute the primary color according to the chosen perceptual color.
  51183. */
  51184. private _computePrimaryColorFromPerceptualColor;
  51185. /**
  51186. * Compute the highlights and shadow colors according to their chosen levels.
  51187. */
  51188. private _computePrimaryColors;
  51189. /**
  51190. * Build the uniform buffer used in the material.
  51191. */
  51192. buildUniformLayout(): void;
  51193. /**
  51194. * Unbind the material.
  51195. */
  51196. unbind(): void;
  51197. /**
  51198. * Bind only the world matrix to the material.
  51199. * @param world The world matrix to bind.
  51200. */
  51201. bindOnlyWorldMatrix(world: Matrix): void;
  51202. /**
  51203. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51204. * @param world The world matrix to bind.
  51205. * @param subMesh The submesh to bind for.
  51206. */
  51207. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51208. /**
  51209. * Checks to see if a texture is used in the material.
  51210. * @param texture - Base texture to use.
  51211. * @returns - Boolean specifying if a texture is used in the material.
  51212. */
  51213. hasTexture(texture: BaseTexture): boolean;
  51214. /**
  51215. * Dispose the material.
  51216. * @param forceDisposeEffect Force disposal of the associated effect.
  51217. * @param forceDisposeTextures Force disposal of the associated textures.
  51218. */
  51219. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51220. /**
  51221. * Clones the material.
  51222. * @param name The cloned name.
  51223. * @returns The cloned material.
  51224. */
  51225. clone(name: string): BackgroundMaterial;
  51226. /**
  51227. * Serializes the current material to its JSON representation.
  51228. * @returns The JSON representation.
  51229. */
  51230. serialize(): any;
  51231. /**
  51232. * Gets the class name of the material
  51233. * @returns "BackgroundMaterial"
  51234. */
  51235. getClassName(): string;
  51236. /**
  51237. * Parse a JSON input to create back a background material.
  51238. * @param source The JSON data to parse
  51239. * @param scene The scene to create the parsed material in
  51240. * @param rootUrl The root url of the assets the material depends upon
  51241. * @returns the instantiated BackgroundMaterial.
  51242. */
  51243. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51244. }
  51245. }
  51246. declare module "babylonjs/Helpers/environmentHelper" {
  51247. import { Observable } from "babylonjs/Misc/observable";
  51248. import { Nullable } from "babylonjs/types";
  51249. import { Scene } from "babylonjs/scene";
  51250. import { Vector3 } from "babylonjs/Maths/math.vector";
  51251. import { Color3 } from "babylonjs/Maths/math.color";
  51252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51253. import { Mesh } from "babylonjs/Meshes/mesh";
  51254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51255. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51256. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51257. import "babylonjs/Meshes/Builders/planeBuilder";
  51258. import "babylonjs/Meshes/Builders/boxBuilder";
  51259. /**
  51260. * Represents the different options available during the creation of
  51261. * a Environment helper.
  51262. *
  51263. * This can control the default ground, skybox and image processing setup of your scene.
  51264. */
  51265. export interface IEnvironmentHelperOptions {
  51266. /**
  51267. * Specifies wether or not to create a ground.
  51268. * True by default.
  51269. */
  51270. createGround: boolean;
  51271. /**
  51272. * Specifies the ground size.
  51273. * 15 by default.
  51274. */
  51275. groundSize: number;
  51276. /**
  51277. * The texture used on the ground for the main color.
  51278. * Comes from the BabylonJS CDN by default.
  51279. *
  51280. * Remarks: Can be either a texture or a url.
  51281. */
  51282. groundTexture: string | BaseTexture;
  51283. /**
  51284. * The color mixed in the ground texture by default.
  51285. * BabylonJS clearColor by default.
  51286. */
  51287. groundColor: Color3;
  51288. /**
  51289. * Specifies the ground opacity.
  51290. * 1 by default.
  51291. */
  51292. groundOpacity: number;
  51293. /**
  51294. * Enables the ground to receive shadows.
  51295. * True by default.
  51296. */
  51297. enableGroundShadow: boolean;
  51298. /**
  51299. * Helps preventing the shadow to be fully black on the ground.
  51300. * 0.5 by default.
  51301. */
  51302. groundShadowLevel: number;
  51303. /**
  51304. * Creates a mirror texture attach to the ground.
  51305. * false by default.
  51306. */
  51307. enableGroundMirror: boolean;
  51308. /**
  51309. * Specifies the ground mirror size ratio.
  51310. * 0.3 by default as the default kernel is 64.
  51311. */
  51312. groundMirrorSizeRatio: number;
  51313. /**
  51314. * Specifies the ground mirror blur kernel size.
  51315. * 64 by default.
  51316. */
  51317. groundMirrorBlurKernel: number;
  51318. /**
  51319. * Specifies the ground mirror visibility amount.
  51320. * 1 by default
  51321. */
  51322. groundMirrorAmount: number;
  51323. /**
  51324. * Specifies the ground mirror reflectance weight.
  51325. * This uses the standard weight of the background material to setup the fresnel effect
  51326. * of the mirror.
  51327. * 1 by default.
  51328. */
  51329. groundMirrorFresnelWeight: number;
  51330. /**
  51331. * Specifies the ground mirror Falloff distance.
  51332. * This can helps reducing the size of the reflection.
  51333. * 0 by Default.
  51334. */
  51335. groundMirrorFallOffDistance: number;
  51336. /**
  51337. * Specifies the ground mirror texture type.
  51338. * Unsigned Int by Default.
  51339. */
  51340. groundMirrorTextureType: number;
  51341. /**
  51342. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51343. * the shown objects.
  51344. */
  51345. groundYBias: number;
  51346. /**
  51347. * Specifies wether or not to create a skybox.
  51348. * True by default.
  51349. */
  51350. createSkybox: boolean;
  51351. /**
  51352. * Specifies the skybox size.
  51353. * 20 by default.
  51354. */
  51355. skyboxSize: number;
  51356. /**
  51357. * The texture used on the skybox for the main color.
  51358. * Comes from the BabylonJS CDN by default.
  51359. *
  51360. * Remarks: Can be either a texture or a url.
  51361. */
  51362. skyboxTexture: string | BaseTexture;
  51363. /**
  51364. * The color mixed in the skybox texture by default.
  51365. * BabylonJS clearColor by default.
  51366. */
  51367. skyboxColor: Color3;
  51368. /**
  51369. * The background rotation around the Y axis of the scene.
  51370. * This helps aligning the key lights of your scene with the background.
  51371. * 0 by default.
  51372. */
  51373. backgroundYRotation: number;
  51374. /**
  51375. * Compute automatically the size of the elements to best fit with the scene.
  51376. */
  51377. sizeAuto: boolean;
  51378. /**
  51379. * Default position of the rootMesh if autoSize is not true.
  51380. */
  51381. rootPosition: Vector3;
  51382. /**
  51383. * Sets up the image processing in the scene.
  51384. * true by default.
  51385. */
  51386. setupImageProcessing: boolean;
  51387. /**
  51388. * The texture used as your environment texture in the scene.
  51389. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51390. *
  51391. * Remarks: Can be either a texture or a url.
  51392. */
  51393. environmentTexture: string | BaseTexture;
  51394. /**
  51395. * The value of the exposure to apply to the scene.
  51396. * 0.6 by default if setupImageProcessing is true.
  51397. */
  51398. cameraExposure: number;
  51399. /**
  51400. * The value of the contrast to apply to the scene.
  51401. * 1.6 by default if setupImageProcessing is true.
  51402. */
  51403. cameraContrast: number;
  51404. /**
  51405. * Specifies wether or not tonemapping should be enabled in the scene.
  51406. * true by default if setupImageProcessing is true.
  51407. */
  51408. toneMappingEnabled: boolean;
  51409. }
  51410. /**
  51411. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51412. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51413. * It also helps with the default setup of your imageProcessing configuration.
  51414. */
  51415. export class EnvironmentHelper {
  51416. /**
  51417. * Default ground texture URL.
  51418. */
  51419. private static _groundTextureCDNUrl;
  51420. /**
  51421. * Default skybox texture URL.
  51422. */
  51423. private static _skyboxTextureCDNUrl;
  51424. /**
  51425. * Default environment texture URL.
  51426. */
  51427. private static _environmentTextureCDNUrl;
  51428. /**
  51429. * Creates the default options for the helper.
  51430. */
  51431. private static _getDefaultOptions;
  51432. private _rootMesh;
  51433. /**
  51434. * Gets the root mesh created by the helper.
  51435. */
  51436. get rootMesh(): Mesh;
  51437. private _skybox;
  51438. /**
  51439. * Gets the skybox created by the helper.
  51440. */
  51441. get skybox(): Nullable<Mesh>;
  51442. private _skyboxTexture;
  51443. /**
  51444. * Gets the skybox texture created by the helper.
  51445. */
  51446. get skyboxTexture(): Nullable<BaseTexture>;
  51447. private _skyboxMaterial;
  51448. /**
  51449. * Gets the skybox material created by the helper.
  51450. */
  51451. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51452. private _ground;
  51453. /**
  51454. * Gets the ground mesh created by the helper.
  51455. */
  51456. get ground(): Nullable<Mesh>;
  51457. private _groundTexture;
  51458. /**
  51459. * Gets the ground texture created by the helper.
  51460. */
  51461. get groundTexture(): Nullable<BaseTexture>;
  51462. private _groundMirror;
  51463. /**
  51464. * Gets the ground mirror created by the helper.
  51465. */
  51466. get groundMirror(): Nullable<MirrorTexture>;
  51467. /**
  51468. * Gets the ground mirror render list to helps pushing the meshes
  51469. * you wish in the ground reflection.
  51470. */
  51471. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51472. private _groundMaterial;
  51473. /**
  51474. * Gets the ground material created by the helper.
  51475. */
  51476. get groundMaterial(): Nullable<BackgroundMaterial>;
  51477. /**
  51478. * Stores the creation options.
  51479. */
  51480. private readonly _scene;
  51481. private _options;
  51482. /**
  51483. * This observable will be notified with any error during the creation of the environment,
  51484. * mainly texture creation errors.
  51485. */
  51486. onErrorObservable: Observable<{
  51487. message?: string;
  51488. exception?: any;
  51489. }>;
  51490. /**
  51491. * constructor
  51492. * @param options Defines the options we want to customize the helper
  51493. * @param scene The scene to add the material to
  51494. */
  51495. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51496. /**
  51497. * Updates the background according to the new options
  51498. * @param options
  51499. */
  51500. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51501. /**
  51502. * Sets the primary color of all the available elements.
  51503. * @param color the main color to affect to the ground and the background
  51504. */
  51505. setMainColor(color: Color3): void;
  51506. /**
  51507. * Setup the image processing according to the specified options.
  51508. */
  51509. private _setupImageProcessing;
  51510. /**
  51511. * Setup the environment texture according to the specified options.
  51512. */
  51513. private _setupEnvironmentTexture;
  51514. /**
  51515. * Setup the background according to the specified options.
  51516. */
  51517. private _setupBackground;
  51518. /**
  51519. * Get the scene sizes according to the setup.
  51520. */
  51521. private _getSceneSize;
  51522. /**
  51523. * Setup the ground according to the specified options.
  51524. */
  51525. private _setupGround;
  51526. /**
  51527. * Setup the ground material according to the specified options.
  51528. */
  51529. private _setupGroundMaterial;
  51530. /**
  51531. * Setup the ground diffuse texture according to the specified options.
  51532. */
  51533. private _setupGroundDiffuseTexture;
  51534. /**
  51535. * Setup the ground mirror texture according to the specified options.
  51536. */
  51537. private _setupGroundMirrorTexture;
  51538. /**
  51539. * Setup the ground to receive the mirror texture.
  51540. */
  51541. private _setupMirrorInGroundMaterial;
  51542. /**
  51543. * Setup the skybox according to the specified options.
  51544. */
  51545. private _setupSkybox;
  51546. /**
  51547. * Setup the skybox material according to the specified options.
  51548. */
  51549. private _setupSkyboxMaterial;
  51550. /**
  51551. * Setup the skybox reflection texture according to the specified options.
  51552. */
  51553. private _setupSkyboxReflectionTexture;
  51554. private _errorHandler;
  51555. /**
  51556. * Dispose all the elements created by the Helper.
  51557. */
  51558. dispose(): void;
  51559. }
  51560. }
  51561. declare module "babylonjs/Helpers/photoDome" {
  51562. import { Observable } from "babylonjs/Misc/observable";
  51563. import { Nullable } from "babylonjs/types";
  51564. import { Scene } from "babylonjs/scene";
  51565. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51566. import { Mesh } from "babylonjs/Meshes/mesh";
  51567. import { Texture } from "babylonjs/Materials/Textures/texture";
  51568. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51569. import "babylonjs/Meshes/Builders/sphereBuilder";
  51570. /**
  51571. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51572. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51573. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51574. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51575. */
  51576. export class PhotoDome extends TransformNode {
  51577. /**
  51578. * Define the image as a Monoscopic panoramic 360 image.
  51579. */
  51580. static readonly MODE_MONOSCOPIC: number;
  51581. /**
  51582. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51583. */
  51584. static readonly MODE_TOPBOTTOM: number;
  51585. /**
  51586. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51587. */
  51588. static readonly MODE_SIDEBYSIDE: number;
  51589. private _useDirectMapping;
  51590. /**
  51591. * The texture being displayed on the sphere
  51592. */
  51593. protected _photoTexture: Texture;
  51594. /**
  51595. * Gets or sets the texture being displayed on the sphere
  51596. */
  51597. get photoTexture(): Texture;
  51598. set photoTexture(value: Texture);
  51599. /**
  51600. * Observable raised when an error occured while loading the 360 image
  51601. */
  51602. onLoadErrorObservable: Observable<string>;
  51603. /**
  51604. * The skybox material
  51605. */
  51606. protected _material: BackgroundMaterial;
  51607. /**
  51608. * The surface used for the skybox
  51609. */
  51610. protected _mesh: Mesh;
  51611. /**
  51612. * Gets the mesh used for the skybox.
  51613. */
  51614. get mesh(): Mesh;
  51615. /**
  51616. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51617. * Also see the options.resolution property.
  51618. */
  51619. get fovMultiplier(): number;
  51620. set fovMultiplier(value: number);
  51621. private _imageMode;
  51622. /**
  51623. * Gets or set the current video mode for the video. It can be:
  51624. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51625. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51626. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51627. */
  51628. get imageMode(): number;
  51629. set imageMode(value: number);
  51630. /**
  51631. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51632. * @param name Element's name, child elements will append suffixes for their own names.
  51633. * @param urlsOfPhoto defines the url of the photo to display
  51634. * @param options defines an object containing optional or exposed sub element properties
  51635. * @param onError defines a callback called when an error occured while loading the texture
  51636. */
  51637. constructor(name: string, urlOfPhoto: string, options: {
  51638. resolution?: number;
  51639. size?: number;
  51640. useDirectMapping?: boolean;
  51641. faceForward?: boolean;
  51642. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51643. private _onBeforeCameraRenderObserver;
  51644. private _changeImageMode;
  51645. /**
  51646. * Releases resources associated with this node.
  51647. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51648. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51649. */
  51650. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51651. }
  51652. }
  51653. declare module "babylonjs/Misc/rgbdTextureTools" {
  51654. import "babylonjs/Shaders/rgbdDecode.fragment";
  51655. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51656. import { Texture } from "babylonjs/Materials/Textures/texture";
  51657. /**
  51658. * Class used to host RGBD texture specific utilities
  51659. */
  51660. export class RGBDTextureTools {
  51661. /**
  51662. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51663. * @param texture the texture to expand.
  51664. */
  51665. static ExpandRGBDTexture(texture: Texture): void;
  51666. }
  51667. }
  51668. declare module "babylonjs/Misc/brdfTextureTools" {
  51669. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51670. import { Scene } from "babylonjs/scene";
  51671. /**
  51672. * Class used to host texture specific utilities
  51673. */
  51674. export class BRDFTextureTools {
  51675. /**
  51676. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51677. * @param scene defines the hosting scene
  51678. * @returns the environment BRDF texture
  51679. */
  51680. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51681. private static _environmentBRDFBase64Texture;
  51682. }
  51683. }
  51684. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51685. import { Nullable } from "babylonjs/types";
  51686. import { Color3 } from "babylonjs/Maths/math.color";
  51687. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51688. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51689. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51690. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51691. import { Engine } from "babylonjs/Engines/engine";
  51692. import { Scene } from "babylonjs/scene";
  51693. /**
  51694. * @hidden
  51695. */
  51696. export interface IMaterialClearCoatDefines {
  51697. CLEARCOAT: boolean;
  51698. CLEARCOAT_DEFAULTIOR: boolean;
  51699. CLEARCOAT_TEXTURE: boolean;
  51700. CLEARCOAT_TEXTUREDIRECTUV: number;
  51701. CLEARCOAT_BUMP: boolean;
  51702. CLEARCOAT_BUMPDIRECTUV: number;
  51703. CLEARCOAT_TINT: boolean;
  51704. CLEARCOAT_TINT_TEXTURE: boolean;
  51705. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51706. /** @hidden */
  51707. _areTexturesDirty: boolean;
  51708. }
  51709. /**
  51710. * Define the code related to the clear coat parameters of the pbr material.
  51711. */
  51712. export class PBRClearCoatConfiguration {
  51713. /**
  51714. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51715. * The default fits with a polyurethane material.
  51716. */
  51717. private static readonly _DefaultIndexOfRefraction;
  51718. private _isEnabled;
  51719. /**
  51720. * Defines if the clear coat is enabled in the material.
  51721. */
  51722. isEnabled: boolean;
  51723. /**
  51724. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51725. */
  51726. intensity: number;
  51727. /**
  51728. * Defines the clear coat layer roughness.
  51729. */
  51730. roughness: number;
  51731. private _indexOfRefraction;
  51732. /**
  51733. * Defines the index of refraction of the clear coat.
  51734. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51735. * The default fits with a polyurethane material.
  51736. * Changing the default value is more performance intensive.
  51737. */
  51738. indexOfRefraction: number;
  51739. private _texture;
  51740. /**
  51741. * Stores the clear coat values in a texture.
  51742. */
  51743. texture: Nullable<BaseTexture>;
  51744. private _bumpTexture;
  51745. /**
  51746. * Define the clear coat specific bump texture.
  51747. */
  51748. bumpTexture: Nullable<BaseTexture>;
  51749. private _isTintEnabled;
  51750. /**
  51751. * Defines if the clear coat tint is enabled in the material.
  51752. */
  51753. isTintEnabled: boolean;
  51754. /**
  51755. * Defines the clear coat tint of the material.
  51756. * This is only use if tint is enabled
  51757. */
  51758. tintColor: Color3;
  51759. /**
  51760. * Defines the distance at which the tint color should be found in the
  51761. * clear coat media.
  51762. * This is only use if tint is enabled
  51763. */
  51764. tintColorAtDistance: number;
  51765. /**
  51766. * Defines the clear coat layer thickness.
  51767. * This is only use if tint is enabled
  51768. */
  51769. tintThickness: number;
  51770. private _tintTexture;
  51771. /**
  51772. * Stores the clear tint values in a texture.
  51773. * rgb is tint
  51774. * a is a thickness factor
  51775. */
  51776. tintTexture: Nullable<BaseTexture>;
  51777. /** @hidden */
  51778. private _internalMarkAllSubMeshesAsTexturesDirty;
  51779. /** @hidden */
  51780. _markAllSubMeshesAsTexturesDirty(): void;
  51781. /**
  51782. * Instantiate a new istance of clear coat configuration.
  51783. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51784. */
  51785. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51786. /**
  51787. * Gets wehter the submesh is ready to be used or not.
  51788. * @param defines the list of "defines" to update.
  51789. * @param scene defines the scene the material belongs to.
  51790. * @param engine defines the engine the material belongs to.
  51791. * @param disableBumpMap defines wether the material disables bump or not.
  51792. * @returns - boolean indicating that the submesh is ready or not.
  51793. */
  51794. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  51795. /**
  51796. * Checks to see if a texture is used in the material.
  51797. * @param defines the list of "defines" to update.
  51798. * @param scene defines the scene to the material belongs to.
  51799. */
  51800. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  51801. /**
  51802. * Binds the material data.
  51803. * @param uniformBuffer defines the Uniform buffer to fill in.
  51804. * @param scene defines the scene the material belongs to.
  51805. * @param engine defines the engine the material belongs to.
  51806. * @param disableBumpMap defines wether the material disables bump or not.
  51807. * @param isFrozen defines wether the material is frozen or not.
  51808. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51809. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51810. */
  51811. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  51812. /**
  51813. * Checks to see if a texture is used in the material.
  51814. * @param texture - Base texture to use.
  51815. * @returns - Boolean specifying if a texture is used in the material.
  51816. */
  51817. hasTexture(texture: BaseTexture): boolean;
  51818. /**
  51819. * Returns an array of the actively used textures.
  51820. * @param activeTextures Array of BaseTextures
  51821. */
  51822. getActiveTextures(activeTextures: BaseTexture[]): void;
  51823. /**
  51824. * Returns the animatable textures.
  51825. * @param animatables Array of animatable textures.
  51826. */
  51827. getAnimatables(animatables: IAnimatable[]): void;
  51828. /**
  51829. * Disposes the resources of the material.
  51830. * @param forceDisposeTextures - Forces the disposal of all textures.
  51831. */
  51832. dispose(forceDisposeTextures?: boolean): void;
  51833. /**
  51834. * Get the current class name of the texture useful for serialization or dynamic coding.
  51835. * @returns "PBRClearCoatConfiguration"
  51836. */
  51837. getClassName(): string;
  51838. /**
  51839. * Add fallbacks to the effect fallbacks list.
  51840. * @param defines defines the Base texture to use.
  51841. * @param fallbacks defines the current fallback list.
  51842. * @param currentRank defines the current fallback rank.
  51843. * @returns the new fallback rank.
  51844. */
  51845. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51846. /**
  51847. * Add the required uniforms to the current list.
  51848. * @param uniforms defines the current uniform list.
  51849. */
  51850. static AddUniforms(uniforms: string[]): void;
  51851. /**
  51852. * Add the required samplers to the current list.
  51853. * @param samplers defines the current sampler list.
  51854. */
  51855. static AddSamplers(samplers: string[]): void;
  51856. /**
  51857. * Add the required uniforms to the current buffer.
  51858. * @param uniformBuffer defines the current uniform buffer.
  51859. */
  51860. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51861. /**
  51862. * Makes a duplicate of the current configuration into another one.
  51863. * @param clearCoatConfiguration define the config where to copy the info
  51864. */
  51865. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51866. /**
  51867. * Serializes this clear coat configuration.
  51868. * @returns - An object with the serialized config.
  51869. */
  51870. serialize(): any;
  51871. /**
  51872. * Parses a anisotropy Configuration from a serialized object.
  51873. * @param source - Serialized object.
  51874. * @param scene Defines the scene we are parsing for
  51875. * @param rootUrl Defines the rootUrl to load from
  51876. */
  51877. parse(source: any, scene: Scene, rootUrl: string): void;
  51878. }
  51879. }
  51880. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51881. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51883. import { Vector2 } from "babylonjs/Maths/math.vector";
  51884. import { Scene } from "babylonjs/scene";
  51885. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51886. import { Nullable } from "babylonjs/types";
  51887. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51888. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51889. /**
  51890. * @hidden
  51891. */
  51892. export interface IMaterialAnisotropicDefines {
  51893. ANISOTROPIC: boolean;
  51894. ANISOTROPIC_TEXTURE: boolean;
  51895. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51896. MAINUV1: boolean;
  51897. _areTexturesDirty: boolean;
  51898. _needUVs: boolean;
  51899. }
  51900. /**
  51901. * Define the code related to the anisotropic parameters of the pbr material.
  51902. */
  51903. export class PBRAnisotropicConfiguration {
  51904. private _isEnabled;
  51905. /**
  51906. * Defines if the anisotropy is enabled in the material.
  51907. */
  51908. isEnabled: boolean;
  51909. /**
  51910. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51911. */
  51912. intensity: number;
  51913. /**
  51914. * Defines if the effect is along the tangents, bitangents or in between.
  51915. * By default, the effect is "strectching" the highlights along the tangents.
  51916. */
  51917. direction: Vector2;
  51918. private _texture;
  51919. /**
  51920. * Stores the anisotropy values in a texture.
  51921. * rg is direction (like normal from -1 to 1)
  51922. * b is a intensity
  51923. */
  51924. texture: Nullable<BaseTexture>;
  51925. /** @hidden */
  51926. private _internalMarkAllSubMeshesAsTexturesDirty;
  51927. /** @hidden */
  51928. _markAllSubMeshesAsTexturesDirty(): void;
  51929. /**
  51930. * Instantiate a new istance of anisotropy configuration.
  51931. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51932. */
  51933. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51934. /**
  51935. * Specifies that the submesh is ready to be used.
  51936. * @param defines the list of "defines" to update.
  51937. * @param scene defines the scene the material belongs to.
  51938. * @returns - boolean indicating that the submesh is ready or not.
  51939. */
  51940. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  51941. /**
  51942. * Checks to see if a texture is used in the material.
  51943. * @param defines the list of "defines" to update.
  51944. * @param mesh the mesh we are preparing the defines for.
  51945. * @param scene defines the scene the material belongs to.
  51946. */
  51947. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  51948. /**
  51949. * Binds the material data.
  51950. * @param uniformBuffer defines the Uniform buffer to fill in.
  51951. * @param scene defines the scene the material belongs to.
  51952. * @param isFrozen defines wether the material is frozen or not.
  51953. */
  51954. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51955. /**
  51956. * Checks to see if a texture is used in the material.
  51957. * @param texture - Base texture to use.
  51958. * @returns - Boolean specifying if a texture is used in the material.
  51959. */
  51960. hasTexture(texture: BaseTexture): boolean;
  51961. /**
  51962. * Returns an array of the actively used textures.
  51963. * @param activeTextures Array of BaseTextures
  51964. */
  51965. getActiveTextures(activeTextures: BaseTexture[]): void;
  51966. /**
  51967. * Returns the animatable textures.
  51968. * @param animatables Array of animatable textures.
  51969. */
  51970. getAnimatables(animatables: IAnimatable[]): void;
  51971. /**
  51972. * Disposes the resources of the material.
  51973. * @param forceDisposeTextures - Forces the disposal of all textures.
  51974. */
  51975. dispose(forceDisposeTextures?: boolean): void;
  51976. /**
  51977. * Get the current class name of the texture useful for serialization or dynamic coding.
  51978. * @returns "PBRAnisotropicConfiguration"
  51979. */
  51980. getClassName(): string;
  51981. /**
  51982. * Add fallbacks to the effect fallbacks list.
  51983. * @param defines defines the Base texture to use.
  51984. * @param fallbacks defines the current fallback list.
  51985. * @param currentRank defines the current fallback rank.
  51986. * @returns the new fallback rank.
  51987. */
  51988. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51989. /**
  51990. * Add the required uniforms to the current list.
  51991. * @param uniforms defines the current uniform list.
  51992. */
  51993. static AddUniforms(uniforms: string[]): void;
  51994. /**
  51995. * Add the required uniforms to the current buffer.
  51996. * @param uniformBuffer defines the current uniform buffer.
  51997. */
  51998. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51999. /**
  52000. * Add the required samplers to the current list.
  52001. * @param samplers defines the current sampler list.
  52002. */
  52003. static AddSamplers(samplers: string[]): void;
  52004. /**
  52005. * Makes a duplicate of the current configuration into another one.
  52006. * @param anisotropicConfiguration define the config where to copy the info
  52007. */
  52008. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52009. /**
  52010. * Serializes this anisotropy configuration.
  52011. * @returns - An object with the serialized config.
  52012. */
  52013. serialize(): any;
  52014. /**
  52015. * Parses a anisotropy Configuration from a serialized object.
  52016. * @param source - Serialized object.
  52017. * @param scene Defines the scene we are parsing for
  52018. * @param rootUrl Defines the rootUrl to load from
  52019. */
  52020. parse(source: any, scene: Scene, rootUrl: string): void;
  52021. }
  52022. }
  52023. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52024. import { Scene } from "babylonjs/scene";
  52025. /**
  52026. * @hidden
  52027. */
  52028. export interface IMaterialBRDFDefines {
  52029. BRDF_V_HEIGHT_CORRELATED: boolean;
  52030. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52031. SPHERICAL_HARMONICS: boolean;
  52032. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52033. /** @hidden */
  52034. _areMiscDirty: boolean;
  52035. }
  52036. /**
  52037. * Define the code related to the BRDF parameters of the pbr material.
  52038. */
  52039. export class PBRBRDFConfiguration {
  52040. /**
  52041. * Default value used for the energy conservation.
  52042. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52043. */
  52044. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52045. /**
  52046. * Default value used for the Smith Visibility Height Correlated mode.
  52047. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52048. */
  52049. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52050. /**
  52051. * Default value used for the IBL diffuse part.
  52052. * This can help switching back to the polynomials mode globally which is a tiny bit
  52053. * less GPU intensive at the drawback of a lower quality.
  52054. */
  52055. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52056. /**
  52057. * Default value used for activating energy conservation for the specular workflow.
  52058. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52059. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52060. */
  52061. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52062. private _useEnergyConservation;
  52063. /**
  52064. * Defines if the material uses energy conservation.
  52065. */
  52066. useEnergyConservation: boolean;
  52067. private _useSmithVisibilityHeightCorrelated;
  52068. /**
  52069. * LEGACY Mode set to false
  52070. * Defines if the material uses height smith correlated visibility term.
  52071. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52072. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52073. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52074. * Not relying on height correlated will also disable energy conservation.
  52075. */
  52076. useSmithVisibilityHeightCorrelated: boolean;
  52077. private _useSphericalHarmonics;
  52078. /**
  52079. * LEGACY Mode set to false
  52080. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52081. * diffuse part of the IBL.
  52082. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52083. * to the ground truth.
  52084. */
  52085. useSphericalHarmonics: boolean;
  52086. private _useSpecularGlossinessInputEnergyConservation;
  52087. /**
  52088. * Defines if the material uses energy conservation, when the specular workflow is active.
  52089. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52090. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52091. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52092. */
  52093. useSpecularGlossinessInputEnergyConservation: boolean;
  52094. /** @hidden */
  52095. private _internalMarkAllSubMeshesAsMiscDirty;
  52096. /** @hidden */
  52097. _markAllSubMeshesAsMiscDirty(): void;
  52098. /**
  52099. * Instantiate a new istance of clear coat configuration.
  52100. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52101. */
  52102. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52103. /**
  52104. * Checks to see if a texture is used in the material.
  52105. * @param defines the list of "defines" to update.
  52106. */
  52107. prepareDefines(defines: IMaterialBRDFDefines): void;
  52108. /**
  52109. * Get the current class name of the texture useful for serialization or dynamic coding.
  52110. * @returns "PBRClearCoatConfiguration"
  52111. */
  52112. getClassName(): string;
  52113. /**
  52114. * Makes a duplicate of the current configuration into another one.
  52115. * @param brdfConfiguration define the config where to copy the info
  52116. */
  52117. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52118. /**
  52119. * Serializes this BRDF configuration.
  52120. * @returns - An object with the serialized config.
  52121. */
  52122. serialize(): any;
  52123. /**
  52124. * Parses a anisotropy Configuration from a serialized object.
  52125. * @param source - Serialized object.
  52126. * @param scene Defines the scene we are parsing for
  52127. * @param rootUrl Defines the rootUrl to load from
  52128. */
  52129. parse(source: any, scene: Scene, rootUrl: string): void;
  52130. }
  52131. }
  52132. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52133. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52134. import { Color3 } from "babylonjs/Maths/math.color";
  52135. import { Scene } from "babylonjs/scene";
  52136. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52137. import { Nullable } from "babylonjs/types";
  52138. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52139. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52140. /**
  52141. * @hidden
  52142. */
  52143. export interface IMaterialSheenDefines {
  52144. SHEEN: boolean;
  52145. SHEEN_TEXTURE: boolean;
  52146. SHEEN_TEXTUREDIRECTUV: number;
  52147. SHEEN_LINKWITHALBEDO: boolean;
  52148. /** @hidden */
  52149. _areTexturesDirty: boolean;
  52150. }
  52151. /**
  52152. * Define the code related to the Sheen parameters of the pbr material.
  52153. */
  52154. export class PBRSheenConfiguration {
  52155. private _isEnabled;
  52156. /**
  52157. * Defines if the material uses sheen.
  52158. */
  52159. isEnabled: boolean;
  52160. private _linkSheenWithAlbedo;
  52161. /**
  52162. * Defines if the sheen is linked to the sheen color.
  52163. */
  52164. linkSheenWithAlbedo: boolean;
  52165. /**
  52166. * Defines the sheen intensity.
  52167. */
  52168. intensity: number;
  52169. /**
  52170. * Defines the sheen color.
  52171. */
  52172. color: Color3;
  52173. private _texture;
  52174. /**
  52175. * Stores the sheen tint values in a texture.
  52176. * rgb is tint
  52177. * a is a intensity
  52178. */
  52179. texture: Nullable<BaseTexture>;
  52180. /** @hidden */
  52181. private _internalMarkAllSubMeshesAsTexturesDirty;
  52182. /** @hidden */
  52183. _markAllSubMeshesAsTexturesDirty(): void;
  52184. /**
  52185. * Instantiate a new istance of clear coat configuration.
  52186. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52187. */
  52188. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52189. /**
  52190. * Specifies that the submesh is ready to be used.
  52191. * @param defines the list of "defines" to update.
  52192. * @param scene defines the scene the material belongs to.
  52193. * @returns - boolean indicating that the submesh is ready or not.
  52194. */
  52195. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52196. /**
  52197. * Checks to see if a texture is used in the material.
  52198. * @param defines the list of "defines" to update.
  52199. * @param scene defines the scene the material belongs to.
  52200. */
  52201. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52202. /**
  52203. * Binds the material data.
  52204. * @param uniformBuffer defines the Uniform buffer to fill in.
  52205. * @param scene defines the scene the material belongs to.
  52206. * @param isFrozen defines wether the material is frozen or not.
  52207. */
  52208. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52209. /**
  52210. * Checks to see if a texture is used in the material.
  52211. * @param texture - Base texture to use.
  52212. * @returns - Boolean specifying if a texture is used in the material.
  52213. */
  52214. hasTexture(texture: BaseTexture): boolean;
  52215. /**
  52216. * Returns an array of the actively used textures.
  52217. * @param activeTextures Array of BaseTextures
  52218. */
  52219. getActiveTextures(activeTextures: BaseTexture[]): void;
  52220. /**
  52221. * Returns the animatable textures.
  52222. * @param animatables Array of animatable textures.
  52223. */
  52224. getAnimatables(animatables: IAnimatable[]): void;
  52225. /**
  52226. * Disposes the resources of the material.
  52227. * @param forceDisposeTextures - Forces the disposal of all textures.
  52228. */
  52229. dispose(forceDisposeTextures?: boolean): void;
  52230. /**
  52231. * Get the current class name of the texture useful for serialization or dynamic coding.
  52232. * @returns "PBRSheenConfiguration"
  52233. */
  52234. getClassName(): string;
  52235. /**
  52236. * Add fallbacks to the effect fallbacks list.
  52237. * @param defines defines the Base texture to use.
  52238. * @param fallbacks defines the current fallback list.
  52239. * @param currentRank defines the current fallback rank.
  52240. * @returns the new fallback rank.
  52241. */
  52242. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52243. /**
  52244. * Add the required uniforms to the current list.
  52245. * @param uniforms defines the current uniform list.
  52246. */
  52247. static AddUniforms(uniforms: string[]): void;
  52248. /**
  52249. * Add the required uniforms to the current buffer.
  52250. * @param uniformBuffer defines the current uniform buffer.
  52251. */
  52252. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52253. /**
  52254. * Add the required samplers to the current list.
  52255. * @param samplers defines the current sampler list.
  52256. */
  52257. static AddSamplers(samplers: string[]): void;
  52258. /**
  52259. * Makes a duplicate of the current configuration into another one.
  52260. * @param sheenConfiguration define the config where to copy the info
  52261. */
  52262. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52263. /**
  52264. * Serializes this BRDF configuration.
  52265. * @returns - An object with the serialized config.
  52266. */
  52267. serialize(): any;
  52268. /**
  52269. * Parses a anisotropy Configuration from a serialized object.
  52270. * @param source - Serialized object.
  52271. * @param scene Defines the scene we are parsing for
  52272. * @param rootUrl Defines the rootUrl to load from
  52273. */
  52274. parse(source: any, scene: Scene, rootUrl: string): void;
  52275. }
  52276. }
  52277. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52278. import { Nullable } from "babylonjs/types";
  52279. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52280. import { Color3 } from "babylonjs/Maths/math.color";
  52281. import { SmartArray } from "babylonjs/Misc/smartArray";
  52282. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52283. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52284. import { Effect } from "babylonjs/Materials/effect";
  52285. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52286. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52287. import { Engine } from "babylonjs/Engines/engine";
  52288. import { Scene } from "babylonjs/scene";
  52289. /**
  52290. * @hidden
  52291. */
  52292. export interface IMaterialSubSurfaceDefines {
  52293. SUBSURFACE: boolean;
  52294. SS_REFRACTION: boolean;
  52295. SS_TRANSLUCENCY: boolean;
  52296. SS_SCATERRING: boolean;
  52297. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52298. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52299. SS_REFRACTIONMAP_3D: boolean;
  52300. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52301. SS_LODINREFRACTIONALPHA: boolean;
  52302. SS_GAMMAREFRACTION: boolean;
  52303. SS_RGBDREFRACTION: boolean;
  52304. SS_LINEARSPECULARREFRACTION: boolean;
  52305. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52306. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52307. /** @hidden */
  52308. _areTexturesDirty: boolean;
  52309. }
  52310. /**
  52311. * Define the code related to the sub surface parameters of the pbr material.
  52312. */
  52313. export class PBRSubSurfaceConfiguration {
  52314. private _isRefractionEnabled;
  52315. /**
  52316. * Defines if the refraction is enabled in the material.
  52317. */
  52318. isRefractionEnabled: boolean;
  52319. private _isTranslucencyEnabled;
  52320. /**
  52321. * Defines if the translucency is enabled in the material.
  52322. */
  52323. isTranslucencyEnabled: boolean;
  52324. private _isScatteringEnabled;
  52325. /**
  52326. * Defines the refraction intensity of the material.
  52327. * The refraction when enabled replaces the Diffuse part of the material.
  52328. * The intensity helps transitionning between diffuse and refraction.
  52329. */
  52330. refractionIntensity: number;
  52331. /**
  52332. * Defines the translucency intensity of the material.
  52333. * When translucency has been enabled, this defines how much of the "translucency"
  52334. * is addded to the diffuse part of the material.
  52335. */
  52336. translucencyIntensity: number;
  52337. /**
  52338. * Defines the scattering intensity of the material.
  52339. * When scattering has been enabled, this defines how much of the "scattered light"
  52340. * is addded to the diffuse part of the material.
  52341. */
  52342. scatteringIntensity: number;
  52343. private _thicknessTexture;
  52344. /**
  52345. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52346. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52347. * 0 would mean minimumThickness
  52348. * 1 would mean maximumThickness
  52349. * The other channels might be use as a mask to vary the different effects intensity.
  52350. */
  52351. thicknessTexture: Nullable<BaseTexture>;
  52352. private _refractionTexture;
  52353. /**
  52354. * Defines the texture to use for refraction.
  52355. */
  52356. refractionTexture: Nullable<BaseTexture>;
  52357. private _indexOfRefraction;
  52358. /**
  52359. * Defines the index of refraction used in the material.
  52360. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52361. */
  52362. indexOfRefraction: number;
  52363. private _invertRefractionY;
  52364. /**
  52365. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52366. */
  52367. invertRefractionY: boolean;
  52368. private _linkRefractionWithTransparency;
  52369. /**
  52370. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52371. * Materials half opaque for instance using refraction could benefit from this control.
  52372. */
  52373. linkRefractionWithTransparency: boolean;
  52374. /**
  52375. * Defines the minimum thickness stored in the thickness map.
  52376. * If no thickness map is defined, this value will be used to simulate thickness.
  52377. */
  52378. minimumThickness: number;
  52379. /**
  52380. * Defines the maximum thickness stored in the thickness map.
  52381. */
  52382. maximumThickness: number;
  52383. /**
  52384. * Defines the volume tint of the material.
  52385. * This is used for both translucency and scattering.
  52386. */
  52387. tintColor: Color3;
  52388. /**
  52389. * Defines the distance at which the tint color should be found in the media.
  52390. * This is used for refraction only.
  52391. */
  52392. tintColorAtDistance: number;
  52393. /**
  52394. * Defines how far each channel transmit through the media.
  52395. * It is defined as a color to simplify it selection.
  52396. */
  52397. diffusionDistance: Color3;
  52398. private _useMaskFromThicknessTexture;
  52399. /**
  52400. * Stores the intensity of the different subsurface effects in the thickness texture.
  52401. * * the green channel is the translucency intensity.
  52402. * * the blue channel is the scattering intensity.
  52403. * * the alpha channel is the refraction intensity.
  52404. */
  52405. useMaskFromThicknessTexture: boolean;
  52406. /** @hidden */
  52407. private _internalMarkAllSubMeshesAsTexturesDirty;
  52408. /** @hidden */
  52409. _markAllSubMeshesAsTexturesDirty(): void;
  52410. /**
  52411. * Instantiate a new istance of sub surface configuration.
  52412. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52413. */
  52414. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52415. /**
  52416. * Gets wehter the submesh is ready to be used or not.
  52417. * @param defines the list of "defines" to update.
  52418. * @param scene defines the scene the material belongs to.
  52419. * @returns - boolean indicating that the submesh is ready or not.
  52420. */
  52421. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52422. /**
  52423. * Checks to see if a texture is used in the material.
  52424. * @param defines the list of "defines" to update.
  52425. * @param scene defines the scene to the material belongs to.
  52426. */
  52427. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52428. /**
  52429. * Binds the material data.
  52430. * @param uniformBuffer defines the Uniform buffer to fill in.
  52431. * @param scene defines the scene the material belongs to.
  52432. * @param engine defines the engine the material belongs to.
  52433. * @param isFrozen defines wether the material is frozen or not.
  52434. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52435. */
  52436. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52437. /**
  52438. * Unbinds the material from the mesh.
  52439. * @param activeEffect defines the effect that should be unbound from.
  52440. * @returns true if unbound, otherwise false
  52441. */
  52442. unbind(activeEffect: Effect): boolean;
  52443. /**
  52444. * Returns the texture used for refraction or null if none is used.
  52445. * @param scene defines the scene the material belongs to.
  52446. * @returns - Refraction texture if present. If no refraction texture and refraction
  52447. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52448. */
  52449. private _getRefractionTexture;
  52450. /**
  52451. * Returns true if alpha blending should be disabled.
  52452. */
  52453. get disableAlphaBlending(): boolean;
  52454. /**
  52455. * Fills the list of render target textures.
  52456. * @param renderTargets the list of render targets to update
  52457. */
  52458. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52459. /**
  52460. * Checks to see if a texture is used in the material.
  52461. * @param texture - Base texture to use.
  52462. * @returns - Boolean specifying if a texture is used in the material.
  52463. */
  52464. hasTexture(texture: BaseTexture): boolean;
  52465. /**
  52466. * Gets a boolean indicating that current material needs to register RTT
  52467. * @returns true if this uses a render target otherwise false.
  52468. */
  52469. hasRenderTargetTextures(): boolean;
  52470. /**
  52471. * Returns an array of the actively used textures.
  52472. * @param activeTextures Array of BaseTextures
  52473. */
  52474. getActiveTextures(activeTextures: BaseTexture[]): void;
  52475. /**
  52476. * Returns the animatable textures.
  52477. * @param animatables Array of animatable textures.
  52478. */
  52479. getAnimatables(animatables: IAnimatable[]): void;
  52480. /**
  52481. * Disposes the resources of the material.
  52482. * @param forceDisposeTextures - Forces the disposal of all textures.
  52483. */
  52484. dispose(forceDisposeTextures?: boolean): void;
  52485. /**
  52486. * Get the current class name of the texture useful for serialization or dynamic coding.
  52487. * @returns "PBRSubSurfaceConfiguration"
  52488. */
  52489. getClassName(): string;
  52490. /**
  52491. * Add fallbacks to the effect fallbacks list.
  52492. * @param defines defines the Base texture to use.
  52493. * @param fallbacks defines the current fallback list.
  52494. * @param currentRank defines the current fallback rank.
  52495. * @returns the new fallback rank.
  52496. */
  52497. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52498. /**
  52499. * Add the required uniforms to the current list.
  52500. * @param uniforms defines the current uniform list.
  52501. */
  52502. static AddUniforms(uniforms: string[]): void;
  52503. /**
  52504. * Add the required samplers to the current list.
  52505. * @param samplers defines the current sampler list.
  52506. */
  52507. static AddSamplers(samplers: string[]): void;
  52508. /**
  52509. * Add the required uniforms to the current buffer.
  52510. * @param uniformBuffer defines the current uniform buffer.
  52511. */
  52512. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52513. /**
  52514. * Makes a duplicate of the current configuration into another one.
  52515. * @param configuration define the config where to copy the info
  52516. */
  52517. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52518. /**
  52519. * Serializes this Sub Surface configuration.
  52520. * @returns - An object with the serialized config.
  52521. */
  52522. serialize(): any;
  52523. /**
  52524. * Parses a anisotropy Configuration from a serialized object.
  52525. * @param source - Serialized object.
  52526. * @param scene Defines the scene we are parsing for
  52527. * @param rootUrl Defines the rootUrl to load from
  52528. */
  52529. parse(source: any, scene: Scene, rootUrl: string): void;
  52530. }
  52531. }
  52532. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52533. /** @hidden */
  52534. export var pbrFragmentDeclaration: {
  52535. name: string;
  52536. shader: string;
  52537. };
  52538. }
  52539. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52540. /** @hidden */
  52541. export var pbrUboDeclaration: {
  52542. name: string;
  52543. shader: string;
  52544. };
  52545. }
  52546. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52547. /** @hidden */
  52548. export var pbrFragmentExtraDeclaration: {
  52549. name: string;
  52550. shader: string;
  52551. };
  52552. }
  52553. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52554. /** @hidden */
  52555. export var pbrFragmentSamplersDeclaration: {
  52556. name: string;
  52557. shader: string;
  52558. };
  52559. }
  52560. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52561. /** @hidden */
  52562. export var pbrHelperFunctions: {
  52563. name: string;
  52564. shader: string;
  52565. };
  52566. }
  52567. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52568. /** @hidden */
  52569. export var harmonicsFunctions: {
  52570. name: string;
  52571. shader: string;
  52572. };
  52573. }
  52574. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52575. /** @hidden */
  52576. export var pbrDirectLightingSetupFunctions: {
  52577. name: string;
  52578. shader: string;
  52579. };
  52580. }
  52581. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52582. /** @hidden */
  52583. export var pbrDirectLightingFalloffFunctions: {
  52584. name: string;
  52585. shader: string;
  52586. };
  52587. }
  52588. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52589. /** @hidden */
  52590. export var pbrBRDFFunctions: {
  52591. name: string;
  52592. shader: string;
  52593. };
  52594. }
  52595. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52596. /** @hidden */
  52597. export var pbrDirectLightingFunctions: {
  52598. name: string;
  52599. shader: string;
  52600. };
  52601. }
  52602. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52603. /** @hidden */
  52604. export var pbrIBLFunctions: {
  52605. name: string;
  52606. shader: string;
  52607. };
  52608. }
  52609. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52610. /** @hidden */
  52611. export var pbrDebug: {
  52612. name: string;
  52613. shader: string;
  52614. };
  52615. }
  52616. declare module "babylonjs/Shaders/pbr.fragment" {
  52617. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52618. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52619. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52620. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52621. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52622. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52623. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52624. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52625. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52626. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52627. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52628. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52629. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52630. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52631. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52632. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52633. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52634. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52635. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52636. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52637. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52638. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52639. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52640. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52641. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52642. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52643. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52644. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52645. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52646. /** @hidden */
  52647. export var pbrPixelShader: {
  52648. name: string;
  52649. shader: string;
  52650. };
  52651. }
  52652. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52653. /** @hidden */
  52654. export var pbrVertexDeclaration: {
  52655. name: string;
  52656. shader: string;
  52657. };
  52658. }
  52659. declare module "babylonjs/Shaders/pbr.vertex" {
  52660. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52661. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52662. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52663. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52664. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52665. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52666. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52667. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52668. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52669. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52670. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52671. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52672. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52673. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52674. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52675. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52676. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52677. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52678. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52679. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52680. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52681. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52682. /** @hidden */
  52683. export var pbrVertexShader: {
  52684. name: string;
  52685. shader: string;
  52686. };
  52687. }
  52688. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52689. import { Nullable } from "babylonjs/types";
  52690. import { Scene } from "babylonjs/scene";
  52691. import { Matrix } from "babylonjs/Maths/math.vector";
  52692. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52694. import { Mesh } from "babylonjs/Meshes/mesh";
  52695. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52696. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52697. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52698. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52699. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52700. import { Color3 } from "babylonjs/Maths/math.color";
  52701. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52702. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52703. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52704. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52706. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52707. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52708. import "babylonjs/Shaders/pbr.fragment";
  52709. import "babylonjs/Shaders/pbr.vertex";
  52710. /**
  52711. * Manages the defines for the PBR Material.
  52712. * @hidden
  52713. */
  52714. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52715. PBR: boolean;
  52716. MAINUV1: boolean;
  52717. MAINUV2: boolean;
  52718. UV1: boolean;
  52719. UV2: boolean;
  52720. ALBEDO: boolean;
  52721. ALBEDODIRECTUV: number;
  52722. VERTEXCOLOR: boolean;
  52723. AMBIENT: boolean;
  52724. AMBIENTDIRECTUV: number;
  52725. AMBIENTINGRAYSCALE: boolean;
  52726. OPACITY: boolean;
  52727. VERTEXALPHA: boolean;
  52728. OPACITYDIRECTUV: number;
  52729. OPACITYRGB: boolean;
  52730. ALPHATEST: boolean;
  52731. DEPTHPREPASS: boolean;
  52732. ALPHABLEND: boolean;
  52733. ALPHAFROMALBEDO: boolean;
  52734. ALPHATESTVALUE: string;
  52735. SPECULAROVERALPHA: boolean;
  52736. RADIANCEOVERALPHA: boolean;
  52737. ALPHAFRESNEL: boolean;
  52738. LINEARALPHAFRESNEL: boolean;
  52739. PREMULTIPLYALPHA: boolean;
  52740. EMISSIVE: boolean;
  52741. EMISSIVEDIRECTUV: number;
  52742. REFLECTIVITY: boolean;
  52743. REFLECTIVITYDIRECTUV: number;
  52744. SPECULARTERM: boolean;
  52745. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52746. MICROSURFACEAUTOMATIC: boolean;
  52747. LODBASEDMICROSFURACE: boolean;
  52748. MICROSURFACEMAP: boolean;
  52749. MICROSURFACEMAPDIRECTUV: number;
  52750. METALLICWORKFLOW: boolean;
  52751. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52752. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52753. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52754. AOSTOREINMETALMAPRED: boolean;
  52755. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52756. ENVIRONMENTBRDF: boolean;
  52757. ENVIRONMENTBRDF_RGBD: boolean;
  52758. NORMAL: boolean;
  52759. TANGENT: boolean;
  52760. BUMP: boolean;
  52761. BUMPDIRECTUV: number;
  52762. OBJECTSPACE_NORMALMAP: boolean;
  52763. PARALLAX: boolean;
  52764. PARALLAXOCCLUSION: boolean;
  52765. NORMALXYSCALE: boolean;
  52766. LIGHTMAP: boolean;
  52767. LIGHTMAPDIRECTUV: number;
  52768. USELIGHTMAPASSHADOWMAP: boolean;
  52769. GAMMALIGHTMAP: boolean;
  52770. RGBDLIGHTMAP: boolean;
  52771. REFLECTION: boolean;
  52772. REFLECTIONMAP_3D: boolean;
  52773. REFLECTIONMAP_SPHERICAL: boolean;
  52774. REFLECTIONMAP_PLANAR: boolean;
  52775. REFLECTIONMAP_CUBIC: boolean;
  52776. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  52777. REFLECTIONMAP_PROJECTION: boolean;
  52778. REFLECTIONMAP_SKYBOX: boolean;
  52779. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  52780. REFLECTIONMAP_EXPLICIT: boolean;
  52781. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  52782. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  52783. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  52784. INVERTCUBICMAP: boolean;
  52785. USESPHERICALFROMREFLECTIONMAP: boolean;
  52786. USEIRRADIANCEMAP: boolean;
  52787. SPHERICAL_HARMONICS: boolean;
  52788. USESPHERICALINVERTEX: boolean;
  52789. REFLECTIONMAP_OPPOSITEZ: boolean;
  52790. LODINREFLECTIONALPHA: boolean;
  52791. GAMMAREFLECTION: boolean;
  52792. RGBDREFLECTION: boolean;
  52793. LINEARSPECULARREFLECTION: boolean;
  52794. RADIANCEOCCLUSION: boolean;
  52795. HORIZONOCCLUSION: boolean;
  52796. INSTANCES: boolean;
  52797. NUM_BONE_INFLUENCERS: number;
  52798. BonesPerMesh: number;
  52799. BONETEXTURE: boolean;
  52800. NONUNIFORMSCALING: boolean;
  52801. MORPHTARGETS: boolean;
  52802. MORPHTARGETS_NORMAL: boolean;
  52803. MORPHTARGETS_TANGENT: boolean;
  52804. MORPHTARGETS_UV: boolean;
  52805. NUM_MORPH_INFLUENCERS: number;
  52806. IMAGEPROCESSING: boolean;
  52807. VIGNETTE: boolean;
  52808. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52809. VIGNETTEBLENDMODEOPAQUE: boolean;
  52810. TONEMAPPING: boolean;
  52811. TONEMAPPING_ACES: boolean;
  52812. CONTRAST: boolean;
  52813. COLORCURVES: boolean;
  52814. COLORGRADING: boolean;
  52815. COLORGRADING3D: boolean;
  52816. SAMPLER3DGREENDEPTH: boolean;
  52817. SAMPLER3DBGRMAP: boolean;
  52818. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52819. EXPOSURE: boolean;
  52820. MULTIVIEW: boolean;
  52821. USEPHYSICALLIGHTFALLOFF: boolean;
  52822. USEGLTFLIGHTFALLOFF: boolean;
  52823. TWOSIDEDLIGHTING: boolean;
  52824. SHADOWFLOAT: boolean;
  52825. CLIPPLANE: boolean;
  52826. CLIPPLANE2: boolean;
  52827. CLIPPLANE3: boolean;
  52828. CLIPPLANE4: boolean;
  52829. CLIPPLANE5: boolean;
  52830. CLIPPLANE6: boolean;
  52831. POINTSIZE: boolean;
  52832. FOG: boolean;
  52833. LOGARITHMICDEPTH: boolean;
  52834. FORCENORMALFORWARD: boolean;
  52835. SPECULARAA: boolean;
  52836. CLEARCOAT: boolean;
  52837. CLEARCOAT_DEFAULTIOR: boolean;
  52838. CLEARCOAT_TEXTURE: boolean;
  52839. CLEARCOAT_TEXTUREDIRECTUV: number;
  52840. CLEARCOAT_BUMP: boolean;
  52841. CLEARCOAT_BUMPDIRECTUV: number;
  52842. CLEARCOAT_TINT: boolean;
  52843. CLEARCOAT_TINT_TEXTURE: boolean;
  52844. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52845. ANISOTROPIC: boolean;
  52846. ANISOTROPIC_TEXTURE: boolean;
  52847. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52848. BRDF_V_HEIGHT_CORRELATED: boolean;
  52849. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52850. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52851. SHEEN: boolean;
  52852. SHEEN_TEXTURE: boolean;
  52853. SHEEN_TEXTUREDIRECTUV: number;
  52854. SHEEN_LINKWITHALBEDO: boolean;
  52855. SUBSURFACE: boolean;
  52856. SS_REFRACTION: boolean;
  52857. SS_TRANSLUCENCY: boolean;
  52858. SS_SCATERRING: boolean;
  52859. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52860. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52861. SS_REFRACTIONMAP_3D: boolean;
  52862. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52863. SS_LODINREFRACTIONALPHA: boolean;
  52864. SS_GAMMAREFRACTION: boolean;
  52865. SS_RGBDREFRACTION: boolean;
  52866. SS_LINEARSPECULARREFRACTION: boolean;
  52867. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52868. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52869. UNLIT: boolean;
  52870. DEBUGMODE: number;
  52871. /**
  52872. * Initializes the PBR Material defines.
  52873. */
  52874. constructor();
  52875. /**
  52876. * Resets the PBR Material defines.
  52877. */
  52878. reset(): void;
  52879. }
  52880. /**
  52881. * The Physically based material base class of BJS.
  52882. *
  52883. * This offers the main features of a standard PBR material.
  52884. * For more information, please refer to the documentation :
  52885. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52886. */
  52887. export abstract class PBRBaseMaterial extends PushMaterial {
  52888. /**
  52889. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52890. */
  52891. static readonly PBRMATERIAL_OPAQUE: number;
  52892. /**
  52893. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52894. */
  52895. static readonly PBRMATERIAL_ALPHATEST: number;
  52896. /**
  52897. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52898. */
  52899. static readonly PBRMATERIAL_ALPHABLEND: number;
  52900. /**
  52901. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52902. * They are also discarded below the alpha cutoff threshold to improve performances.
  52903. */
  52904. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52905. /**
  52906. * Defines the default value of how much AO map is occluding the analytical lights
  52907. * (point spot...).
  52908. */
  52909. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52910. /**
  52911. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52912. */
  52913. static readonly LIGHTFALLOFF_PHYSICAL: number;
  52914. /**
  52915. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52916. * to enhance interoperability with other engines.
  52917. */
  52918. static readonly LIGHTFALLOFF_GLTF: number;
  52919. /**
  52920. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52921. * to enhance interoperability with other materials.
  52922. */
  52923. static readonly LIGHTFALLOFF_STANDARD: number;
  52924. /**
  52925. * Intensity of the direct lights e.g. the four lights available in your scene.
  52926. * This impacts both the direct diffuse and specular highlights.
  52927. */
  52928. protected _directIntensity: number;
  52929. /**
  52930. * Intensity of the emissive part of the material.
  52931. * This helps controlling the emissive effect without modifying the emissive color.
  52932. */
  52933. protected _emissiveIntensity: number;
  52934. /**
  52935. * Intensity of the environment e.g. how much the environment will light the object
  52936. * either through harmonics for rough material or through the refelction for shiny ones.
  52937. */
  52938. protected _environmentIntensity: number;
  52939. /**
  52940. * This is a special control allowing the reduction of the specular highlights coming from the
  52941. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52942. */
  52943. protected _specularIntensity: number;
  52944. /**
  52945. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52946. */
  52947. private _lightingInfos;
  52948. /**
  52949. * Debug Control allowing disabling the bump map on this material.
  52950. */
  52951. protected _disableBumpMap: boolean;
  52952. /**
  52953. * AKA Diffuse Texture in standard nomenclature.
  52954. */
  52955. protected _albedoTexture: Nullable<BaseTexture>;
  52956. /**
  52957. * AKA Occlusion Texture in other nomenclature.
  52958. */
  52959. protected _ambientTexture: Nullable<BaseTexture>;
  52960. /**
  52961. * AKA Occlusion Texture Intensity in other nomenclature.
  52962. */
  52963. protected _ambientTextureStrength: number;
  52964. /**
  52965. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52966. * 1 means it completely occludes it
  52967. * 0 mean it has no impact
  52968. */
  52969. protected _ambientTextureImpactOnAnalyticalLights: number;
  52970. /**
  52971. * Stores the alpha values in a texture.
  52972. */
  52973. protected _opacityTexture: Nullable<BaseTexture>;
  52974. /**
  52975. * Stores the reflection values in a texture.
  52976. */
  52977. protected _reflectionTexture: Nullable<BaseTexture>;
  52978. /**
  52979. * Stores the emissive values in a texture.
  52980. */
  52981. protected _emissiveTexture: Nullable<BaseTexture>;
  52982. /**
  52983. * AKA Specular texture in other nomenclature.
  52984. */
  52985. protected _reflectivityTexture: Nullable<BaseTexture>;
  52986. /**
  52987. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52988. */
  52989. protected _metallicTexture: Nullable<BaseTexture>;
  52990. /**
  52991. * Specifies the metallic scalar of the metallic/roughness workflow.
  52992. * Can also be used to scale the metalness values of the metallic texture.
  52993. */
  52994. protected _metallic: Nullable<number>;
  52995. /**
  52996. * Specifies the roughness scalar of the metallic/roughness workflow.
  52997. * Can also be used to scale the roughness values of the metallic texture.
  52998. */
  52999. protected _roughness: Nullable<number>;
  53000. /**
  53001. * Specifies the an F0 factor to help configuring the material F0.
  53002. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53003. * to 0.5 the previously hard coded value stays the same.
  53004. * Can also be used to scale the F0 values of the metallic texture.
  53005. */
  53006. protected _metallicF0Factor: number;
  53007. /**
  53008. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53009. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53010. * your expectation as it multiplies with the texture data.
  53011. */
  53012. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53013. /**
  53014. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53015. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53016. */
  53017. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53018. /**
  53019. * Stores surface normal data used to displace a mesh in a texture.
  53020. */
  53021. protected _bumpTexture: Nullable<BaseTexture>;
  53022. /**
  53023. * Stores the pre-calculated light information of a mesh in a texture.
  53024. */
  53025. protected _lightmapTexture: Nullable<BaseTexture>;
  53026. /**
  53027. * The color of a material in ambient lighting.
  53028. */
  53029. protected _ambientColor: Color3;
  53030. /**
  53031. * AKA Diffuse Color in other nomenclature.
  53032. */
  53033. protected _albedoColor: Color3;
  53034. /**
  53035. * AKA Specular Color in other nomenclature.
  53036. */
  53037. protected _reflectivityColor: Color3;
  53038. /**
  53039. * The color applied when light is reflected from a material.
  53040. */
  53041. protected _reflectionColor: Color3;
  53042. /**
  53043. * The color applied when light is emitted from a material.
  53044. */
  53045. protected _emissiveColor: Color3;
  53046. /**
  53047. * AKA Glossiness in other nomenclature.
  53048. */
  53049. protected _microSurface: number;
  53050. /**
  53051. * Specifies that the material will use the light map as a show map.
  53052. */
  53053. protected _useLightmapAsShadowmap: boolean;
  53054. /**
  53055. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53056. * makes the reflect vector face the model (under horizon).
  53057. */
  53058. protected _useHorizonOcclusion: boolean;
  53059. /**
  53060. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53061. * too much the area relying on ambient texture to define their ambient occlusion.
  53062. */
  53063. protected _useRadianceOcclusion: boolean;
  53064. /**
  53065. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53066. */
  53067. protected _useAlphaFromAlbedoTexture: boolean;
  53068. /**
  53069. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53070. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53071. */
  53072. protected _useSpecularOverAlpha: boolean;
  53073. /**
  53074. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53075. */
  53076. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53077. /**
  53078. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53079. */
  53080. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53081. /**
  53082. * Specifies if the metallic texture contains the roughness information in its green channel.
  53083. */
  53084. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53085. /**
  53086. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53087. */
  53088. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53089. /**
  53090. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53091. */
  53092. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53093. /**
  53094. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53095. */
  53096. protected _useAmbientInGrayScale: boolean;
  53097. /**
  53098. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53099. * The material will try to infer what glossiness each pixel should be.
  53100. */
  53101. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53102. /**
  53103. * Defines the falloff type used in this material.
  53104. * It by default is Physical.
  53105. */
  53106. protected _lightFalloff: number;
  53107. /**
  53108. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53109. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53110. */
  53111. protected _useRadianceOverAlpha: boolean;
  53112. /**
  53113. * Allows using an object space normal map (instead of tangent space).
  53114. */
  53115. protected _useObjectSpaceNormalMap: boolean;
  53116. /**
  53117. * Allows using the bump map in parallax mode.
  53118. */
  53119. protected _useParallax: boolean;
  53120. /**
  53121. * Allows using the bump map in parallax occlusion mode.
  53122. */
  53123. protected _useParallaxOcclusion: boolean;
  53124. /**
  53125. * Controls the scale bias of the parallax mode.
  53126. */
  53127. protected _parallaxScaleBias: number;
  53128. /**
  53129. * If sets to true, disables all the lights affecting the material.
  53130. */
  53131. protected _disableLighting: boolean;
  53132. /**
  53133. * Number of Simultaneous lights allowed on the material.
  53134. */
  53135. protected _maxSimultaneousLights: number;
  53136. /**
  53137. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53138. */
  53139. protected _invertNormalMapX: boolean;
  53140. /**
  53141. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53142. */
  53143. protected _invertNormalMapY: boolean;
  53144. /**
  53145. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53146. */
  53147. protected _twoSidedLighting: boolean;
  53148. /**
  53149. * Defines the alpha limits in alpha test mode.
  53150. */
  53151. protected _alphaCutOff: number;
  53152. /**
  53153. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53154. */
  53155. protected _forceAlphaTest: boolean;
  53156. /**
  53157. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53158. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53159. */
  53160. protected _useAlphaFresnel: boolean;
  53161. /**
  53162. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53163. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53164. */
  53165. protected _useLinearAlphaFresnel: boolean;
  53166. /**
  53167. * The transparency mode of the material.
  53168. */
  53169. protected _transparencyMode: Nullable<number>;
  53170. /**
  53171. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53172. * from cos thetav and roughness:
  53173. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53174. */
  53175. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53176. /**
  53177. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53178. */
  53179. protected _forceIrradianceInFragment: boolean;
  53180. /**
  53181. * Force normal to face away from face.
  53182. */
  53183. protected _forceNormalForward: boolean;
  53184. /**
  53185. * Enables specular anti aliasing in the PBR shader.
  53186. * It will both interacts on the Geometry for analytical and IBL lighting.
  53187. * It also prefilter the roughness map based on the bump values.
  53188. */
  53189. protected _enableSpecularAntiAliasing: boolean;
  53190. /**
  53191. * Default configuration related to image processing available in the PBR Material.
  53192. */
  53193. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53194. /**
  53195. * Keep track of the image processing observer to allow dispose and replace.
  53196. */
  53197. private _imageProcessingObserver;
  53198. /**
  53199. * Attaches a new image processing configuration to the PBR Material.
  53200. * @param configuration
  53201. */
  53202. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53203. /**
  53204. * Stores the available render targets.
  53205. */
  53206. private _renderTargets;
  53207. /**
  53208. * Sets the global ambient color for the material used in lighting calculations.
  53209. */
  53210. private _globalAmbientColor;
  53211. /**
  53212. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53213. */
  53214. private _useLogarithmicDepth;
  53215. /**
  53216. * If set to true, no lighting calculations will be applied.
  53217. */
  53218. private _unlit;
  53219. private _debugMode;
  53220. /**
  53221. * @hidden
  53222. * This is reserved for the inspector.
  53223. * Defines the material debug mode.
  53224. * It helps seeing only some components of the material while troubleshooting.
  53225. */
  53226. debugMode: number;
  53227. /**
  53228. * @hidden
  53229. * This is reserved for the inspector.
  53230. * Specify from where on screen the debug mode should start.
  53231. * The value goes from -1 (full screen) to 1 (not visible)
  53232. * It helps with side by side comparison against the final render
  53233. * This defaults to -1
  53234. */
  53235. private debugLimit;
  53236. /**
  53237. * @hidden
  53238. * This is reserved for the inspector.
  53239. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53240. * You can use the factor to better multiply the final value.
  53241. */
  53242. private debugFactor;
  53243. /**
  53244. * Defines the clear coat layer parameters for the material.
  53245. */
  53246. readonly clearCoat: PBRClearCoatConfiguration;
  53247. /**
  53248. * Defines the anisotropic parameters for the material.
  53249. */
  53250. readonly anisotropy: PBRAnisotropicConfiguration;
  53251. /**
  53252. * Defines the BRDF parameters for the material.
  53253. */
  53254. readonly brdf: PBRBRDFConfiguration;
  53255. /**
  53256. * Defines the Sheen parameters for the material.
  53257. */
  53258. readonly sheen: PBRSheenConfiguration;
  53259. /**
  53260. * Defines the SubSurface parameters for the material.
  53261. */
  53262. readonly subSurface: PBRSubSurfaceConfiguration;
  53263. /**
  53264. * Custom callback helping to override the default shader used in the material.
  53265. */
  53266. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53267. protected _rebuildInParallel: boolean;
  53268. /**
  53269. * Instantiates a new PBRMaterial instance.
  53270. *
  53271. * @param name The material name
  53272. * @param scene The scene the material will be use in.
  53273. */
  53274. constructor(name: string, scene: Scene);
  53275. /**
  53276. * Gets a boolean indicating that current material needs to register RTT
  53277. */
  53278. get hasRenderTargetTextures(): boolean;
  53279. /**
  53280. * Gets the name of the material class.
  53281. */
  53282. getClassName(): string;
  53283. /**
  53284. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53285. */
  53286. get useLogarithmicDepth(): boolean;
  53287. /**
  53288. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53289. */
  53290. set useLogarithmicDepth(value: boolean);
  53291. /**
  53292. * Gets the current transparency mode.
  53293. */
  53294. get transparencyMode(): Nullable<number>;
  53295. /**
  53296. * Sets the transparency mode of the material.
  53297. *
  53298. * | Value | Type | Description |
  53299. * | ----- | ----------------------------------- | ----------- |
  53300. * | 0 | OPAQUE | |
  53301. * | 1 | ALPHATEST | |
  53302. * | 2 | ALPHABLEND | |
  53303. * | 3 | ALPHATESTANDBLEND | |
  53304. *
  53305. */
  53306. set transparencyMode(value: Nullable<number>);
  53307. /**
  53308. * Returns true if alpha blending should be disabled.
  53309. */
  53310. private get _disableAlphaBlending();
  53311. /**
  53312. * Specifies whether or not this material should be rendered in alpha blend mode.
  53313. */
  53314. needAlphaBlending(): boolean;
  53315. /**
  53316. * Specifies if the mesh will require alpha blending.
  53317. * @param mesh - BJS mesh.
  53318. */
  53319. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53320. /**
  53321. * Specifies whether or not this material should be rendered in alpha test mode.
  53322. */
  53323. needAlphaTesting(): boolean;
  53324. /**
  53325. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53326. */
  53327. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53328. /**
  53329. * Gets the texture used for the alpha test.
  53330. */
  53331. getAlphaTestTexture(): Nullable<BaseTexture>;
  53332. /**
  53333. * Specifies that the submesh is ready to be used.
  53334. * @param mesh - BJS mesh.
  53335. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53336. * @param useInstances - Specifies that instances should be used.
  53337. * @returns - boolean indicating that the submesh is ready or not.
  53338. */
  53339. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53340. /**
  53341. * Specifies if the material uses metallic roughness workflow.
  53342. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53343. */
  53344. isMetallicWorkflow(): boolean;
  53345. private _prepareEffect;
  53346. private _prepareDefines;
  53347. /**
  53348. * Force shader compilation
  53349. */
  53350. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53351. /**
  53352. * Initializes the uniform buffer layout for the shader.
  53353. */
  53354. buildUniformLayout(): void;
  53355. /**
  53356. * Unbinds the material from the mesh
  53357. */
  53358. unbind(): void;
  53359. /**
  53360. * Binds the submesh data.
  53361. * @param world - The world matrix.
  53362. * @param mesh - The BJS mesh.
  53363. * @param subMesh - A submesh of the BJS mesh.
  53364. */
  53365. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53366. /**
  53367. * Returns the animatable textures.
  53368. * @returns - Array of animatable textures.
  53369. */
  53370. getAnimatables(): IAnimatable[];
  53371. /**
  53372. * Returns the texture used for reflections.
  53373. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53374. */
  53375. private _getReflectionTexture;
  53376. /**
  53377. * Returns an array of the actively used textures.
  53378. * @returns - Array of BaseTextures
  53379. */
  53380. getActiveTextures(): BaseTexture[];
  53381. /**
  53382. * Checks to see if a texture is used in the material.
  53383. * @param texture - Base texture to use.
  53384. * @returns - Boolean specifying if a texture is used in the material.
  53385. */
  53386. hasTexture(texture: BaseTexture): boolean;
  53387. /**
  53388. * Disposes the resources of the material.
  53389. * @param forceDisposeEffect - Forces the disposal of effects.
  53390. * @param forceDisposeTextures - Forces the disposal of all textures.
  53391. */
  53392. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53393. }
  53394. }
  53395. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53396. import { Nullable } from "babylonjs/types";
  53397. import { Scene } from "babylonjs/scene";
  53398. import { Color3 } from "babylonjs/Maths/math.color";
  53399. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53400. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53401. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53402. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53403. /**
  53404. * The Physically based material of BJS.
  53405. *
  53406. * This offers the main features of a standard PBR material.
  53407. * For more information, please refer to the documentation :
  53408. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53409. */
  53410. export class PBRMaterial extends PBRBaseMaterial {
  53411. /**
  53412. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53413. */
  53414. static readonly PBRMATERIAL_OPAQUE: number;
  53415. /**
  53416. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53417. */
  53418. static readonly PBRMATERIAL_ALPHATEST: number;
  53419. /**
  53420. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53421. */
  53422. static readonly PBRMATERIAL_ALPHABLEND: number;
  53423. /**
  53424. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53425. * They are also discarded below the alpha cutoff threshold to improve performances.
  53426. */
  53427. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53428. /**
  53429. * Defines the default value of how much AO map is occluding the analytical lights
  53430. * (point spot...).
  53431. */
  53432. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53433. /**
  53434. * Intensity of the direct lights e.g. the four lights available in your scene.
  53435. * This impacts both the direct diffuse and specular highlights.
  53436. */
  53437. directIntensity: number;
  53438. /**
  53439. * Intensity of the emissive part of the material.
  53440. * This helps controlling the emissive effect without modifying the emissive color.
  53441. */
  53442. emissiveIntensity: number;
  53443. /**
  53444. * Intensity of the environment e.g. how much the environment will light the object
  53445. * either through harmonics for rough material or through the refelction for shiny ones.
  53446. */
  53447. environmentIntensity: number;
  53448. /**
  53449. * This is a special control allowing the reduction of the specular highlights coming from the
  53450. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53451. */
  53452. specularIntensity: number;
  53453. /**
  53454. * Debug Control allowing disabling the bump map on this material.
  53455. */
  53456. disableBumpMap: boolean;
  53457. /**
  53458. * AKA Diffuse Texture in standard nomenclature.
  53459. */
  53460. albedoTexture: BaseTexture;
  53461. /**
  53462. * AKA Occlusion Texture in other nomenclature.
  53463. */
  53464. ambientTexture: BaseTexture;
  53465. /**
  53466. * AKA Occlusion Texture Intensity in other nomenclature.
  53467. */
  53468. ambientTextureStrength: number;
  53469. /**
  53470. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53471. * 1 means it completely occludes it
  53472. * 0 mean it has no impact
  53473. */
  53474. ambientTextureImpactOnAnalyticalLights: number;
  53475. /**
  53476. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53477. */
  53478. opacityTexture: BaseTexture;
  53479. /**
  53480. * Stores the reflection values in a texture.
  53481. */
  53482. reflectionTexture: Nullable<BaseTexture>;
  53483. /**
  53484. * Stores the emissive values in a texture.
  53485. */
  53486. emissiveTexture: BaseTexture;
  53487. /**
  53488. * AKA Specular texture in other nomenclature.
  53489. */
  53490. reflectivityTexture: BaseTexture;
  53491. /**
  53492. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53493. */
  53494. metallicTexture: BaseTexture;
  53495. /**
  53496. * Specifies the metallic scalar of the metallic/roughness workflow.
  53497. * Can also be used to scale the metalness values of the metallic texture.
  53498. */
  53499. metallic: Nullable<number>;
  53500. /**
  53501. * Specifies the roughness scalar of the metallic/roughness workflow.
  53502. * Can also be used to scale the roughness values of the metallic texture.
  53503. */
  53504. roughness: Nullable<number>;
  53505. /**
  53506. * Specifies the an F0 factor to help configuring the material F0.
  53507. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53508. * to 0.5 the previously hard coded value stays the same.
  53509. * Can also be used to scale the F0 values of the metallic texture.
  53510. */
  53511. metallicF0Factor: number;
  53512. /**
  53513. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53514. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53515. * your expectation as it multiplies with the texture data.
  53516. */
  53517. useMetallicF0FactorFromMetallicTexture: boolean;
  53518. /**
  53519. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53520. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53521. */
  53522. microSurfaceTexture: BaseTexture;
  53523. /**
  53524. * Stores surface normal data used to displace a mesh in a texture.
  53525. */
  53526. bumpTexture: BaseTexture;
  53527. /**
  53528. * Stores the pre-calculated light information of a mesh in a texture.
  53529. */
  53530. lightmapTexture: BaseTexture;
  53531. /**
  53532. * Stores the refracted light information in a texture.
  53533. */
  53534. get refractionTexture(): Nullable<BaseTexture>;
  53535. set refractionTexture(value: Nullable<BaseTexture>);
  53536. /**
  53537. * The color of a material in ambient lighting.
  53538. */
  53539. ambientColor: Color3;
  53540. /**
  53541. * AKA Diffuse Color in other nomenclature.
  53542. */
  53543. albedoColor: Color3;
  53544. /**
  53545. * AKA Specular Color in other nomenclature.
  53546. */
  53547. reflectivityColor: Color3;
  53548. /**
  53549. * The color reflected from the material.
  53550. */
  53551. reflectionColor: Color3;
  53552. /**
  53553. * The color emitted from the material.
  53554. */
  53555. emissiveColor: Color3;
  53556. /**
  53557. * AKA Glossiness in other nomenclature.
  53558. */
  53559. microSurface: number;
  53560. /**
  53561. * source material index of refraction (IOR)' / 'destination material IOR.
  53562. */
  53563. get indexOfRefraction(): number;
  53564. set indexOfRefraction(value: number);
  53565. /**
  53566. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53567. */
  53568. get invertRefractionY(): boolean;
  53569. set invertRefractionY(value: boolean);
  53570. /**
  53571. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53572. * Materials half opaque for instance using refraction could benefit from this control.
  53573. */
  53574. get linkRefractionWithTransparency(): boolean;
  53575. set linkRefractionWithTransparency(value: boolean);
  53576. /**
  53577. * If true, the light map contains occlusion information instead of lighting info.
  53578. */
  53579. useLightmapAsShadowmap: boolean;
  53580. /**
  53581. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53582. */
  53583. useAlphaFromAlbedoTexture: boolean;
  53584. /**
  53585. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53586. */
  53587. forceAlphaTest: boolean;
  53588. /**
  53589. * Defines the alpha limits in alpha test mode.
  53590. */
  53591. alphaCutOff: number;
  53592. /**
  53593. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53594. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53595. */
  53596. useSpecularOverAlpha: boolean;
  53597. /**
  53598. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53599. */
  53600. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53601. /**
  53602. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53603. */
  53604. useRoughnessFromMetallicTextureAlpha: boolean;
  53605. /**
  53606. * Specifies if the metallic texture contains the roughness information in its green channel.
  53607. */
  53608. useRoughnessFromMetallicTextureGreen: boolean;
  53609. /**
  53610. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53611. */
  53612. useMetallnessFromMetallicTextureBlue: boolean;
  53613. /**
  53614. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53615. */
  53616. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53617. /**
  53618. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53619. */
  53620. useAmbientInGrayScale: boolean;
  53621. /**
  53622. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53623. * The material will try to infer what glossiness each pixel should be.
  53624. */
  53625. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53626. /**
  53627. * BJS is using an harcoded light falloff based on a manually sets up range.
  53628. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53629. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53630. */
  53631. get usePhysicalLightFalloff(): boolean;
  53632. /**
  53633. * BJS is using an harcoded light falloff based on a manually sets up range.
  53634. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53635. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53636. */
  53637. set usePhysicalLightFalloff(value: boolean);
  53638. /**
  53639. * In order to support the falloff compatibility with gltf, a special mode has been added
  53640. * to reproduce the gltf light falloff.
  53641. */
  53642. get useGLTFLightFalloff(): boolean;
  53643. /**
  53644. * In order to support the falloff compatibility with gltf, a special mode has been added
  53645. * to reproduce the gltf light falloff.
  53646. */
  53647. set useGLTFLightFalloff(value: boolean);
  53648. /**
  53649. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53650. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53651. */
  53652. useRadianceOverAlpha: boolean;
  53653. /**
  53654. * Allows using an object space normal map (instead of tangent space).
  53655. */
  53656. useObjectSpaceNormalMap: boolean;
  53657. /**
  53658. * Allows using the bump map in parallax mode.
  53659. */
  53660. useParallax: boolean;
  53661. /**
  53662. * Allows using the bump map in parallax occlusion mode.
  53663. */
  53664. useParallaxOcclusion: boolean;
  53665. /**
  53666. * Controls the scale bias of the parallax mode.
  53667. */
  53668. parallaxScaleBias: number;
  53669. /**
  53670. * If sets to true, disables all the lights affecting the material.
  53671. */
  53672. disableLighting: boolean;
  53673. /**
  53674. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53675. */
  53676. forceIrradianceInFragment: boolean;
  53677. /**
  53678. * Number of Simultaneous lights allowed on the material.
  53679. */
  53680. maxSimultaneousLights: number;
  53681. /**
  53682. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53683. */
  53684. invertNormalMapX: boolean;
  53685. /**
  53686. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53687. */
  53688. invertNormalMapY: boolean;
  53689. /**
  53690. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53691. */
  53692. twoSidedLighting: boolean;
  53693. /**
  53694. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53695. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53696. */
  53697. useAlphaFresnel: boolean;
  53698. /**
  53699. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53700. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53701. */
  53702. useLinearAlphaFresnel: boolean;
  53703. /**
  53704. * Let user defines the brdf lookup texture used for IBL.
  53705. * A default 8bit version is embedded but you could point at :
  53706. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53707. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53708. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53709. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53710. */
  53711. environmentBRDFTexture: Nullable<BaseTexture>;
  53712. /**
  53713. * Force normal to face away from face.
  53714. */
  53715. forceNormalForward: boolean;
  53716. /**
  53717. * Enables specular anti aliasing in the PBR shader.
  53718. * It will both interacts on the Geometry for analytical and IBL lighting.
  53719. * It also prefilter the roughness map based on the bump values.
  53720. */
  53721. enableSpecularAntiAliasing: boolean;
  53722. /**
  53723. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53724. * makes the reflect vector face the model (under horizon).
  53725. */
  53726. useHorizonOcclusion: boolean;
  53727. /**
  53728. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53729. * too much the area relying on ambient texture to define their ambient occlusion.
  53730. */
  53731. useRadianceOcclusion: boolean;
  53732. /**
  53733. * If set to true, no lighting calculations will be applied.
  53734. */
  53735. unlit: boolean;
  53736. /**
  53737. * Gets the image processing configuration used either in this material.
  53738. */
  53739. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53740. /**
  53741. * Sets the Default image processing configuration used either in the this material.
  53742. *
  53743. * If sets to null, the scene one is in use.
  53744. */
  53745. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53746. /**
  53747. * Gets wether the color curves effect is enabled.
  53748. */
  53749. get cameraColorCurvesEnabled(): boolean;
  53750. /**
  53751. * Sets wether the color curves effect is enabled.
  53752. */
  53753. set cameraColorCurvesEnabled(value: boolean);
  53754. /**
  53755. * Gets wether the color grading effect is enabled.
  53756. */
  53757. get cameraColorGradingEnabled(): boolean;
  53758. /**
  53759. * Gets wether the color grading effect is enabled.
  53760. */
  53761. set cameraColorGradingEnabled(value: boolean);
  53762. /**
  53763. * Gets wether tonemapping is enabled or not.
  53764. */
  53765. get cameraToneMappingEnabled(): boolean;
  53766. /**
  53767. * Sets wether tonemapping is enabled or not
  53768. */
  53769. set cameraToneMappingEnabled(value: boolean);
  53770. /**
  53771. * The camera exposure used on this material.
  53772. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53773. * This corresponds to a photographic exposure.
  53774. */
  53775. get cameraExposure(): number;
  53776. /**
  53777. * The camera exposure used on this material.
  53778. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53779. * This corresponds to a photographic exposure.
  53780. */
  53781. set cameraExposure(value: number);
  53782. /**
  53783. * Gets The camera contrast used on this material.
  53784. */
  53785. get cameraContrast(): number;
  53786. /**
  53787. * Sets The camera contrast used on this material.
  53788. */
  53789. set cameraContrast(value: number);
  53790. /**
  53791. * Gets the Color Grading 2D Lookup Texture.
  53792. */
  53793. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53794. /**
  53795. * Sets the Color Grading 2D Lookup Texture.
  53796. */
  53797. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53798. /**
  53799. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53800. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53801. * 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;
  53802. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53803. */
  53804. get cameraColorCurves(): Nullable<ColorCurves>;
  53805. /**
  53806. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53807. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53808. * 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;
  53809. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53810. */
  53811. set cameraColorCurves(value: Nullable<ColorCurves>);
  53812. /**
  53813. * Instantiates a new PBRMaterial instance.
  53814. *
  53815. * @param name The material name
  53816. * @param scene The scene the material will be use in.
  53817. */
  53818. constructor(name: string, scene: Scene);
  53819. /**
  53820. * Returns the name of this material class.
  53821. */
  53822. getClassName(): string;
  53823. /**
  53824. * Makes a duplicate of the current material.
  53825. * @param name - name to use for the new material.
  53826. */
  53827. clone(name: string): PBRMaterial;
  53828. /**
  53829. * Serializes this PBR Material.
  53830. * @returns - An object with the serialized material.
  53831. */
  53832. serialize(): any;
  53833. /**
  53834. * Parses a PBR Material from a serialized object.
  53835. * @param source - Serialized object.
  53836. * @param scene - BJS scene instance.
  53837. * @param rootUrl - url for the scene object
  53838. * @returns - PBRMaterial
  53839. */
  53840. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53841. }
  53842. }
  53843. declare module "babylonjs/Misc/dds" {
  53844. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53845. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53846. import { Nullable } from "babylonjs/types";
  53847. import { Scene } from "babylonjs/scene";
  53848. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53849. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53850. /**
  53851. * Direct draw surface info
  53852. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53853. */
  53854. export interface DDSInfo {
  53855. /**
  53856. * Width of the texture
  53857. */
  53858. width: number;
  53859. /**
  53860. * Width of the texture
  53861. */
  53862. height: number;
  53863. /**
  53864. * Number of Mipmaps for the texture
  53865. * @see https://en.wikipedia.org/wiki/Mipmap
  53866. */
  53867. mipmapCount: number;
  53868. /**
  53869. * If the textures format is a known fourCC format
  53870. * @see https://www.fourcc.org/
  53871. */
  53872. isFourCC: boolean;
  53873. /**
  53874. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53875. */
  53876. isRGB: boolean;
  53877. /**
  53878. * If the texture is a lumincance format
  53879. */
  53880. isLuminance: boolean;
  53881. /**
  53882. * If this is a cube texture
  53883. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53884. */
  53885. isCube: boolean;
  53886. /**
  53887. * If the texture is a compressed format eg. FOURCC_DXT1
  53888. */
  53889. isCompressed: boolean;
  53890. /**
  53891. * The dxgiFormat of the texture
  53892. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  53893. */
  53894. dxgiFormat: number;
  53895. /**
  53896. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  53897. */
  53898. textureType: number;
  53899. /**
  53900. * Sphericle polynomial created for the dds texture
  53901. */
  53902. sphericalPolynomial?: SphericalPolynomial;
  53903. }
  53904. /**
  53905. * Class used to provide DDS decompression tools
  53906. */
  53907. export class DDSTools {
  53908. /**
  53909. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  53910. */
  53911. static StoreLODInAlphaChannel: boolean;
  53912. /**
  53913. * Gets DDS information from an array buffer
  53914. * @param arrayBuffer defines the array buffer to read data from
  53915. * @returns the DDS information
  53916. */
  53917. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  53918. private static _FloatView;
  53919. private static _Int32View;
  53920. private static _ToHalfFloat;
  53921. private static _FromHalfFloat;
  53922. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  53923. private static _GetHalfFloatRGBAArrayBuffer;
  53924. private static _GetFloatRGBAArrayBuffer;
  53925. private static _GetFloatAsUIntRGBAArrayBuffer;
  53926. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  53927. private static _GetRGBAArrayBuffer;
  53928. private static _ExtractLongWordOrder;
  53929. private static _GetRGBArrayBuffer;
  53930. private static _GetLuminanceArrayBuffer;
  53931. /**
  53932. * Uploads DDS Levels to a Babylon Texture
  53933. * @hidden
  53934. */
  53935. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  53936. }
  53937. module "babylonjs/Engines/thinEngine" {
  53938. interface ThinEngine {
  53939. /**
  53940. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  53941. * @param rootUrl defines the url where the file to load is located
  53942. * @param scene defines the current scene
  53943. * @param lodScale defines scale to apply to the mip map selection
  53944. * @param lodOffset defines offset to apply to the mip map selection
  53945. * @param onLoad defines an optional callback raised when the texture is loaded
  53946. * @param onError defines an optional callback raised if there is an issue to load the texture
  53947. * @param format defines the format of the data
  53948. * @param forcedExtension defines the extension to use to pick the right loader
  53949. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  53950. * @returns the cube texture as an InternalTexture
  53951. */
  53952. 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;
  53953. }
  53954. }
  53955. }
  53956. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  53957. import { Nullable } from "babylonjs/types";
  53958. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53959. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53960. /**
  53961. * Implementation of the DDS Texture Loader.
  53962. * @hidden
  53963. */
  53964. export class _DDSTextureLoader implements IInternalTextureLoader {
  53965. /**
  53966. * Defines wether the loader supports cascade loading the different faces.
  53967. */
  53968. readonly supportCascades: boolean;
  53969. /**
  53970. * This returns if the loader support the current file information.
  53971. * @param extension defines the file extension of the file being loaded
  53972. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53973. * @param fallback defines the fallback internal texture if any
  53974. * @param isBase64 defines whether the texture is encoded as a base64
  53975. * @param isBuffer defines whether the texture data are stored as a buffer
  53976. * @returns true if the loader can load the specified file
  53977. */
  53978. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53979. /**
  53980. * Transform the url before loading if required.
  53981. * @param rootUrl the url of the texture
  53982. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53983. * @returns the transformed texture
  53984. */
  53985. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53986. /**
  53987. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53988. * @param rootUrl the url of the texture
  53989. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53990. * @returns the fallback texture
  53991. */
  53992. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53993. /**
  53994. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53995. * @param data contains the texture data
  53996. * @param texture defines the BabylonJS internal texture
  53997. * @param createPolynomials will be true if polynomials have been requested
  53998. * @param onLoad defines the callback to trigger once the texture is ready
  53999. * @param onError defines the callback to trigger in case of error
  54000. */
  54001. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54002. /**
  54003. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54004. * @param data contains the texture data
  54005. * @param texture defines the BabylonJS internal texture
  54006. * @param callback defines the method to call once ready to upload
  54007. */
  54008. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54009. }
  54010. }
  54011. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54012. import { Nullable } from "babylonjs/types";
  54013. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54014. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54015. /**
  54016. * Implementation of the ENV Texture Loader.
  54017. * @hidden
  54018. */
  54019. export class _ENVTextureLoader implements IInternalTextureLoader {
  54020. /**
  54021. * Defines wether the loader supports cascade loading the different faces.
  54022. */
  54023. readonly supportCascades: boolean;
  54024. /**
  54025. * This returns if the loader support the current file information.
  54026. * @param extension defines the file extension of the file being loaded
  54027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54028. * @param fallback defines the fallback internal texture if any
  54029. * @param isBase64 defines whether the texture is encoded as a base64
  54030. * @param isBuffer defines whether the texture data are stored as a buffer
  54031. * @returns true if the loader can load the specified file
  54032. */
  54033. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54034. /**
  54035. * Transform the url before loading if required.
  54036. * @param rootUrl the url of the texture
  54037. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54038. * @returns the transformed texture
  54039. */
  54040. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54041. /**
  54042. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54043. * @param rootUrl the url of the texture
  54044. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54045. * @returns the fallback texture
  54046. */
  54047. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54048. /**
  54049. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54050. * @param data contains the texture data
  54051. * @param texture defines the BabylonJS internal texture
  54052. * @param createPolynomials will be true if polynomials have been requested
  54053. * @param onLoad defines the callback to trigger once the texture is ready
  54054. * @param onError defines the callback to trigger in case of error
  54055. */
  54056. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54057. /**
  54058. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54059. * @param data contains the texture data
  54060. * @param texture defines the BabylonJS internal texture
  54061. * @param callback defines the method to call once ready to upload
  54062. */
  54063. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54064. }
  54065. }
  54066. declare module "babylonjs/Misc/khronosTextureContainer" {
  54067. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54068. /**
  54069. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54070. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54071. */
  54072. export class KhronosTextureContainer {
  54073. /** contents of the KTX container file */
  54074. arrayBuffer: any;
  54075. private static HEADER_LEN;
  54076. private static COMPRESSED_2D;
  54077. private static COMPRESSED_3D;
  54078. private static TEX_2D;
  54079. private static TEX_3D;
  54080. /**
  54081. * Gets the openGL type
  54082. */
  54083. glType: number;
  54084. /**
  54085. * Gets the openGL type size
  54086. */
  54087. glTypeSize: number;
  54088. /**
  54089. * Gets the openGL format
  54090. */
  54091. glFormat: number;
  54092. /**
  54093. * Gets the openGL internal format
  54094. */
  54095. glInternalFormat: number;
  54096. /**
  54097. * Gets the base internal format
  54098. */
  54099. glBaseInternalFormat: number;
  54100. /**
  54101. * Gets image width in pixel
  54102. */
  54103. pixelWidth: number;
  54104. /**
  54105. * Gets image height in pixel
  54106. */
  54107. pixelHeight: number;
  54108. /**
  54109. * Gets image depth in pixels
  54110. */
  54111. pixelDepth: number;
  54112. /**
  54113. * Gets the number of array elements
  54114. */
  54115. numberOfArrayElements: number;
  54116. /**
  54117. * Gets the number of faces
  54118. */
  54119. numberOfFaces: number;
  54120. /**
  54121. * Gets the number of mipmap levels
  54122. */
  54123. numberOfMipmapLevels: number;
  54124. /**
  54125. * Gets the bytes of key value data
  54126. */
  54127. bytesOfKeyValueData: number;
  54128. /**
  54129. * Gets the load type
  54130. */
  54131. loadType: number;
  54132. /**
  54133. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54134. */
  54135. isInvalid: boolean;
  54136. /**
  54137. * Creates a new KhronosTextureContainer
  54138. * @param arrayBuffer contents of the KTX container file
  54139. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54140. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54141. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54142. */
  54143. constructor(
  54144. /** contents of the KTX container file */
  54145. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54146. /**
  54147. * Uploads KTX content to a Babylon Texture.
  54148. * It is assumed that the texture has already been created & is currently bound
  54149. * @hidden
  54150. */
  54151. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54152. private _upload2DCompressedLevels;
  54153. }
  54154. }
  54155. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54156. import { Nullable } from "babylonjs/types";
  54157. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54158. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54159. /**
  54160. * Implementation of the KTX Texture Loader.
  54161. * @hidden
  54162. */
  54163. export class _KTXTextureLoader implements IInternalTextureLoader {
  54164. /**
  54165. * Defines wether the loader supports cascade loading the different faces.
  54166. */
  54167. readonly supportCascades: boolean;
  54168. /**
  54169. * This returns if the loader support the current file information.
  54170. * @param extension defines the file extension of the file being loaded
  54171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54172. * @param fallback defines the fallback internal texture if any
  54173. * @param isBase64 defines whether the texture is encoded as a base64
  54174. * @param isBuffer defines whether the texture data are stored as a buffer
  54175. * @returns true if the loader can load the specified file
  54176. */
  54177. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54178. /**
  54179. * Transform the url before loading if required.
  54180. * @param rootUrl the url of the texture
  54181. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54182. * @returns the transformed texture
  54183. */
  54184. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54185. /**
  54186. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54187. * @param rootUrl the url of the texture
  54188. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54189. * @returns the fallback texture
  54190. */
  54191. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54192. /**
  54193. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54194. * @param data contains the texture data
  54195. * @param texture defines the BabylonJS internal texture
  54196. * @param createPolynomials will be true if polynomials have been requested
  54197. * @param onLoad defines the callback to trigger once the texture is ready
  54198. * @param onError defines the callback to trigger in case of error
  54199. */
  54200. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54201. /**
  54202. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54203. * @param data contains the texture data
  54204. * @param texture defines the BabylonJS internal texture
  54205. * @param callback defines the method to call once ready to upload
  54206. */
  54207. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54208. }
  54209. }
  54210. declare module "babylonjs/Helpers/sceneHelpers" {
  54211. import { Nullable } from "babylonjs/types";
  54212. import { Mesh } from "babylonjs/Meshes/mesh";
  54213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54214. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54215. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54216. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54217. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54218. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54219. import "babylonjs/Meshes/Builders/boxBuilder";
  54220. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  54221. /** @hidden */
  54222. export var _forceSceneHelpersToBundle: boolean;
  54223. module "babylonjs/scene" {
  54224. interface Scene {
  54225. /**
  54226. * Creates a default light for the scene.
  54227. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54228. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54229. */
  54230. createDefaultLight(replace?: boolean): void;
  54231. /**
  54232. * Creates a default camera for the scene.
  54233. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54234. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54235. * @param replace has default false, when true replaces the active camera in the scene
  54236. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54237. */
  54238. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54239. /**
  54240. * Creates a default camera and a default light.
  54241. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54242. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54243. * @param replace has the default false, when true replaces the active camera/light in the scene
  54244. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54245. */
  54246. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54247. /**
  54248. * Creates a new sky box
  54249. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54250. * @param environmentTexture defines the texture to use as environment texture
  54251. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54252. * @param scale defines the overall scale of the skybox
  54253. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54254. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54255. * @returns a new mesh holding the sky box
  54256. */
  54257. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54258. /**
  54259. * Creates a new environment
  54260. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54261. * @param options defines the options you can use to configure the environment
  54262. * @returns the new EnvironmentHelper
  54263. */
  54264. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54265. /**
  54266. * Creates a new VREXperienceHelper
  54267. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54268. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54269. * @returns a new VREXperienceHelper
  54270. */
  54271. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54272. /**
  54273. * Creates a new WebXRDefaultExperience
  54274. * @see http://doc.babylonjs.com/how_to/webxr
  54275. * @param options experience options
  54276. * @returns a promise for a new WebXRDefaultExperience
  54277. */
  54278. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54279. }
  54280. }
  54281. }
  54282. declare module "babylonjs/Helpers/videoDome" {
  54283. import { Scene } from "babylonjs/scene";
  54284. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54285. import { Mesh } from "babylonjs/Meshes/mesh";
  54286. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54287. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54288. import "babylonjs/Meshes/Builders/sphereBuilder";
  54289. /**
  54290. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54291. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54292. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54293. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54294. */
  54295. export class VideoDome extends TransformNode {
  54296. /**
  54297. * Define the video source as a Monoscopic panoramic 360 video.
  54298. */
  54299. static readonly MODE_MONOSCOPIC: number;
  54300. /**
  54301. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54302. */
  54303. static readonly MODE_TOPBOTTOM: number;
  54304. /**
  54305. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54306. */
  54307. static readonly MODE_SIDEBYSIDE: number;
  54308. private _halfDome;
  54309. private _useDirectMapping;
  54310. /**
  54311. * The video texture being displayed on the sphere
  54312. */
  54313. protected _videoTexture: VideoTexture;
  54314. /**
  54315. * Gets the video texture being displayed on the sphere
  54316. */
  54317. get videoTexture(): VideoTexture;
  54318. /**
  54319. * The skybox material
  54320. */
  54321. protected _material: BackgroundMaterial;
  54322. /**
  54323. * The surface used for the skybox
  54324. */
  54325. protected _mesh: Mesh;
  54326. /**
  54327. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54328. */
  54329. private _halfDomeMask;
  54330. /**
  54331. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54332. * Also see the options.resolution property.
  54333. */
  54334. get fovMultiplier(): number;
  54335. set fovMultiplier(value: number);
  54336. private _videoMode;
  54337. /**
  54338. * Gets or set the current video mode for the video. It can be:
  54339. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54340. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54341. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54342. */
  54343. get videoMode(): number;
  54344. set videoMode(value: number);
  54345. /**
  54346. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54347. *
  54348. */
  54349. get halfDome(): boolean;
  54350. /**
  54351. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54352. */
  54353. set halfDome(enabled: boolean);
  54354. /**
  54355. * Oberserver used in Stereoscopic VR Mode.
  54356. */
  54357. private _onBeforeCameraRenderObserver;
  54358. /**
  54359. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54360. * @param name Element's name, child elements will append suffixes for their own names.
  54361. * @param urlsOrVideo defines the url(s) or the video element to use
  54362. * @param options An object containing optional or exposed sub element properties
  54363. */
  54364. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54365. resolution?: number;
  54366. clickToPlay?: boolean;
  54367. autoPlay?: boolean;
  54368. loop?: boolean;
  54369. size?: number;
  54370. poster?: string;
  54371. faceForward?: boolean;
  54372. useDirectMapping?: boolean;
  54373. halfDomeMode?: boolean;
  54374. }, scene: Scene);
  54375. private _changeVideoMode;
  54376. /**
  54377. * Releases resources associated with this node.
  54378. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54379. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54380. */
  54381. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54382. }
  54383. }
  54384. declare module "babylonjs/Helpers/index" {
  54385. export * from "babylonjs/Helpers/environmentHelper";
  54386. export * from "babylonjs/Helpers/photoDome";
  54387. export * from "babylonjs/Helpers/sceneHelpers";
  54388. export * from "babylonjs/Helpers/videoDome";
  54389. }
  54390. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54391. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54392. import { IDisposable } from "babylonjs/scene";
  54393. import { Engine } from "babylonjs/Engines/engine";
  54394. /**
  54395. * This class can be used to get instrumentation data from a Babylon engine
  54396. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54397. */
  54398. export class EngineInstrumentation implements IDisposable {
  54399. /**
  54400. * Define the instrumented engine.
  54401. */
  54402. engine: Engine;
  54403. private _captureGPUFrameTime;
  54404. private _gpuFrameTimeToken;
  54405. private _gpuFrameTime;
  54406. private _captureShaderCompilationTime;
  54407. private _shaderCompilationTime;
  54408. private _onBeginFrameObserver;
  54409. private _onEndFrameObserver;
  54410. private _onBeforeShaderCompilationObserver;
  54411. private _onAfterShaderCompilationObserver;
  54412. /**
  54413. * Gets the perf counter used for GPU frame time
  54414. */
  54415. get gpuFrameTimeCounter(): PerfCounter;
  54416. /**
  54417. * Gets the GPU frame time capture status
  54418. */
  54419. get captureGPUFrameTime(): boolean;
  54420. /**
  54421. * Enable or disable the GPU frame time capture
  54422. */
  54423. set captureGPUFrameTime(value: boolean);
  54424. /**
  54425. * Gets the perf counter used for shader compilation time
  54426. */
  54427. get shaderCompilationTimeCounter(): PerfCounter;
  54428. /**
  54429. * Gets the shader compilation time capture status
  54430. */
  54431. get captureShaderCompilationTime(): boolean;
  54432. /**
  54433. * Enable or disable the shader compilation time capture
  54434. */
  54435. set captureShaderCompilationTime(value: boolean);
  54436. /**
  54437. * Instantiates a new engine instrumentation.
  54438. * This class can be used to get instrumentation data from a Babylon engine
  54439. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54440. * @param engine Defines the engine to instrument
  54441. */
  54442. constructor(
  54443. /**
  54444. * Define the instrumented engine.
  54445. */
  54446. engine: Engine);
  54447. /**
  54448. * Dispose and release associated resources.
  54449. */
  54450. dispose(): void;
  54451. }
  54452. }
  54453. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54454. import { Scene, IDisposable } from "babylonjs/scene";
  54455. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54456. /**
  54457. * This class can be used to get instrumentation data from a Babylon engine
  54458. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54459. */
  54460. export class SceneInstrumentation implements IDisposable {
  54461. /**
  54462. * Defines the scene to instrument
  54463. */
  54464. scene: Scene;
  54465. private _captureActiveMeshesEvaluationTime;
  54466. private _activeMeshesEvaluationTime;
  54467. private _captureRenderTargetsRenderTime;
  54468. private _renderTargetsRenderTime;
  54469. private _captureFrameTime;
  54470. private _frameTime;
  54471. private _captureRenderTime;
  54472. private _renderTime;
  54473. private _captureInterFrameTime;
  54474. private _interFrameTime;
  54475. private _captureParticlesRenderTime;
  54476. private _particlesRenderTime;
  54477. private _captureSpritesRenderTime;
  54478. private _spritesRenderTime;
  54479. private _capturePhysicsTime;
  54480. private _physicsTime;
  54481. private _captureAnimationsTime;
  54482. private _animationsTime;
  54483. private _captureCameraRenderTime;
  54484. private _cameraRenderTime;
  54485. private _onBeforeActiveMeshesEvaluationObserver;
  54486. private _onAfterActiveMeshesEvaluationObserver;
  54487. private _onBeforeRenderTargetsRenderObserver;
  54488. private _onAfterRenderTargetsRenderObserver;
  54489. private _onAfterRenderObserver;
  54490. private _onBeforeDrawPhaseObserver;
  54491. private _onAfterDrawPhaseObserver;
  54492. private _onBeforeAnimationsObserver;
  54493. private _onBeforeParticlesRenderingObserver;
  54494. private _onAfterParticlesRenderingObserver;
  54495. private _onBeforeSpritesRenderingObserver;
  54496. private _onAfterSpritesRenderingObserver;
  54497. private _onBeforePhysicsObserver;
  54498. private _onAfterPhysicsObserver;
  54499. private _onAfterAnimationsObserver;
  54500. private _onBeforeCameraRenderObserver;
  54501. private _onAfterCameraRenderObserver;
  54502. /**
  54503. * Gets the perf counter used for active meshes evaluation time
  54504. */
  54505. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54506. /**
  54507. * Gets the active meshes evaluation time capture status
  54508. */
  54509. get captureActiveMeshesEvaluationTime(): boolean;
  54510. /**
  54511. * Enable or disable the active meshes evaluation time capture
  54512. */
  54513. set captureActiveMeshesEvaluationTime(value: boolean);
  54514. /**
  54515. * Gets the perf counter used for render targets render time
  54516. */
  54517. get renderTargetsRenderTimeCounter(): PerfCounter;
  54518. /**
  54519. * Gets the render targets render time capture status
  54520. */
  54521. get captureRenderTargetsRenderTime(): boolean;
  54522. /**
  54523. * Enable or disable the render targets render time capture
  54524. */
  54525. set captureRenderTargetsRenderTime(value: boolean);
  54526. /**
  54527. * Gets the perf counter used for particles render time
  54528. */
  54529. get particlesRenderTimeCounter(): PerfCounter;
  54530. /**
  54531. * Gets the particles render time capture status
  54532. */
  54533. get captureParticlesRenderTime(): boolean;
  54534. /**
  54535. * Enable or disable the particles render time capture
  54536. */
  54537. set captureParticlesRenderTime(value: boolean);
  54538. /**
  54539. * Gets the perf counter used for sprites render time
  54540. */
  54541. get spritesRenderTimeCounter(): PerfCounter;
  54542. /**
  54543. * Gets the sprites render time capture status
  54544. */
  54545. get captureSpritesRenderTime(): boolean;
  54546. /**
  54547. * Enable or disable the sprites render time capture
  54548. */
  54549. set captureSpritesRenderTime(value: boolean);
  54550. /**
  54551. * Gets the perf counter used for physics time
  54552. */
  54553. get physicsTimeCounter(): PerfCounter;
  54554. /**
  54555. * Gets the physics time capture status
  54556. */
  54557. get capturePhysicsTime(): boolean;
  54558. /**
  54559. * Enable or disable the physics time capture
  54560. */
  54561. set capturePhysicsTime(value: boolean);
  54562. /**
  54563. * Gets the perf counter used for animations time
  54564. */
  54565. get animationsTimeCounter(): PerfCounter;
  54566. /**
  54567. * Gets the animations time capture status
  54568. */
  54569. get captureAnimationsTime(): boolean;
  54570. /**
  54571. * Enable or disable the animations time capture
  54572. */
  54573. set captureAnimationsTime(value: boolean);
  54574. /**
  54575. * Gets the perf counter used for frame time capture
  54576. */
  54577. get frameTimeCounter(): PerfCounter;
  54578. /**
  54579. * Gets the frame time capture status
  54580. */
  54581. get captureFrameTime(): boolean;
  54582. /**
  54583. * Enable or disable the frame time capture
  54584. */
  54585. set captureFrameTime(value: boolean);
  54586. /**
  54587. * Gets the perf counter used for inter-frames time capture
  54588. */
  54589. get interFrameTimeCounter(): PerfCounter;
  54590. /**
  54591. * Gets the inter-frames time capture status
  54592. */
  54593. get captureInterFrameTime(): boolean;
  54594. /**
  54595. * Enable or disable the inter-frames time capture
  54596. */
  54597. set captureInterFrameTime(value: boolean);
  54598. /**
  54599. * Gets the perf counter used for render time capture
  54600. */
  54601. get renderTimeCounter(): PerfCounter;
  54602. /**
  54603. * Gets the render time capture status
  54604. */
  54605. get captureRenderTime(): boolean;
  54606. /**
  54607. * Enable or disable the render time capture
  54608. */
  54609. set captureRenderTime(value: boolean);
  54610. /**
  54611. * Gets the perf counter used for camera render time capture
  54612. */
  54613. get cameraRenderTimeCounter(): PerfCounter;
  54614. /**
  54615. * Gets the camera render time capture status
  54616. */
  54617. get captureCameraRenderTime(): boolean;
  54618. /**
  54619. * Enable or disable the camera render time capture
  54620. */
  54621. set captureCameraRenderTime(value: boolean);
  54622. /**
  54623. * Gets the perf counter used for draw calls
  54624. */
  54625. get drawCallsCounter(): PerfCounter;
  54626. /**
  54627. * Instantiates a new scene instrumentation.
  54628. * This class can be used to get instrumentation data from a Babylon engine
  54629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54630. * @param scene Defines the scene to instrument
  54631. */
  54632. constructor(
  54633. /**
  54634. * Defines the scene to instrument
  54635. */
  54636. scene: Scene);
  54637. /**
  54638. * Dispose and release associated resources.
  54639. */
  54640. dispose(): void;
  54641. }
  54642. }
  54643. declare module "babylonjs/Instrumentation/index" {
  54644. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54645. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54646. export * from "babylonjs/Instrumentation/timeToken";
  54647. }
  54648. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54649. /** @hidden */
  54650. export var glowMapGenerationPixelShader: {
  54651. name: string;
  54652. shader: string;
  54653. };
  54654. }
  54655. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54656. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54657. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54658. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54659. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54660. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54661. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54662. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54663. /** @hidden */
  54664. export var glowMapGenerationVertexShader: {
  54665. name: string;
  54666. shader: string;
  54667. };
  54668. }
  54669. declare module "babylonjs/Layers/effectLayer" {
  54670. import { Observable } from "babylonjs/Misc/observable";
  54671. import { Nullable } from "babylonjs/types";
  54672. import { Camera } from "babylonjs/Cameras/camera";
  54673. import { Scene } from "babylonjs/scene";
  54674. import { ISize } from "babylonjs/Maths/math.size";
  54675. import { Color4 } from "babylonjs/Maths/math.color";
  54676. import { Engine } from "babylonjs/Engines/engine";
  54677. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54679. import { Mesh } from "babylonjs/Meshes/mesh";
  54680. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54681. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54682. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54683. import { Effect } from "babylonjs/Materials/effect";
  54684. import { Material } from "babylonjs/Materials/material";
  54685. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54686. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54687. /**
  54688. * Effect layer options. This helps customizing the behaviour
  54689. * of the effect layer.
  54690. */
  54691. export interface IEffectLayerOptions {
  54692. /**
  54693. * Multiplication factor apply to the canvas size to compute the render target size
  54694. * used to generated the objects (the smaller the faster).
  54695. */
  54696. mainTextureRatio: number;
  54697. /**
  54698. * Enforces a fixed size texture to ensure effect stability across devices.
  54699. */
  54700. mainTextureFixedSize?: number;
  54701. /**
  54702. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54703. */
  54704. alphaBlendingMode: number;
  54705. /**
  54706. * The camera attached to the layer.
  54707. */
  54708. camera: Nullable<Camera>;
  54709. /**
  54710. * The rendering group to draw the layer in.
  54711. */
  54712. renderingGroupId: number;
  54713. }
  54714. /**
  54715. * The effect layer Helps adding post process effect blended with the main pass.
  54716. *
  54717. * This can be for instance use to generate glow or higlight effects on the scene.
  54718. *
  54719. * The effect layer class can not be used directly and is intented to inherited from to be
  54720. * customized per effects.
  54721. */
  54722. export abstract class EffectLayer {
  54723. private _vertexBuffers;
  54724. private _indexBuffer;
  54725. private _cachedDefines;
  54726. private _effectLayerMapGenerationEffect;
  54727. private _effectLayerOptions;
  54728. private _mergeEffect;
  54729. protected _scene: Scene;
  54730. protected _engine: Engine;
  54731. protected _maxSize: number;
  54732. protected _mainTextureDesiredSize: ISize;
  54733. protected _mainTexture: RenderTargetTexture;
  54734. protected _shouldRender: boolean;
  54735. protected _postProcesses: PostProcess[];
  54736. protected _textures: BaseTexture[];
  54737. protected _emissiveTextureAndColor: {
  54738. texture: Nullable<BaseTexture>;
  54739. color: Color4;
  54740. };
  54741. /**
  54742. * The name of the layer
  54743. */
  54744. name: string;
  54745. /**
  54746. * The clear color of the texture used to generate the glow map.
  54747. */
  54748. neutralColor: Color4;
  54749. /**
  54750. * Specifies wether the highlight layer is enabled or not.
  54751. */
  54752. isEnabled: boolean;
  54753. /**
  54754. * Gets the camera attached to the layer.
  54755. */
  54756. get camera(): Nullable<Camera>;
  54757. /**
  54758. * Gets the rendering group id the layer should render in.
  54759. */
  54760. get renderingGroupId(): number;
  54761. set renderingGroupId(renderingGroupId: number);
  54762. /**
  54763. * An event triggered when the effect layer has been disposed.
  54764. */
  54765. onDisposeObservable: Observable<EffectLayer>;
  54766. /**
  54767. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54768. */
  54769. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54770. /**
  54771. * An event triggered when the generated texture is being merged in the scene.
  54772. */
  54773. onBeforeComposeObservable: Observable<EffectLayer>;
  54774. /**
  54775. * An event triggered when the mesh is rendered into the effect render target.
  54776. */
  54777. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  54778. /**
  54779. * An event triggered after the mesh has been rendered into the effect render target.
  54780. */
  54781. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  54782. /**
  54783. * An event triggered when the generated texture has been merged in the scene.
  54784. */
  54785. onAfterComposeObservable: Observable<EffectLayer>;
  54786. /**
  54787. * An event triggered when the efffect layer changes its size.
  54788. */
  54789. onSizeChangedObservable: Observable<EffectLayer>;
  54790. /** @hidden */
  54791. static _SceneComponentInitialization: (scene: Scene) => void;
  54792. /**
  54793. * Instantiates a new effect Layer and references it in the scene.
  54794. * @param name The name of the layer
  54795. * @param scene The scene to use the layer in
  54796. */
  54797. constructor(
  54798. /** The Friendly of the effect in the scene */
  54799. name: string, scene: Scene);
  54800. /**
  54801. * Get the effect name of the layer.
  54802. * @return The effect name
  54803. */
  54804. abstract getEffectName(): string;
  54805. /**
  54806. * Checks for the readiness of the element composing the layer.
  54807. * @param subMesh the mesh to check for
  54808. * @param useInstances specify wether or not to use instances to render the mesh
  54809. * @return true if ready otherwise, false
  54810. */
  54811. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54812. /**
  54813. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54814. * @returns true if the effect requires stencil during the main canvas render pass.
  54815. */
  54816. abstract needStencil(): boolean;
  54817. /**
  54818. * Create the merge effect. This is the shader use to blit the information back
  54819. * to the main canvas at the end of the scene rendering.
  54820. * @returns The effect containing the shader used to merge the effect on the main canvas
  54821. */
  54822. protected abstract _createMergeEffect(): Effect;
  54823. /**
  54824. * Creates the render target textures and post processes used in the effect layer.
  54825. */
  54826. protected abstract _createTextureAndPostProcesses(): void;
  54827. /**
  54828. * Implementation specific of rendering the generating effect on the main canvas.
  54829. * @param effect The effect used to render through
  54830. */
  54831. protected abstract _internalRender(effect: Effect): void;
  54832. /**
  54833. * Sets the required values for both the emissive texture and and the main color.
  54834. */
  54835. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54836. /**
  54837. * Free any resources and references associated to a mesh.
  54838. * Internal use
  54839. * @param mesh The mesh to free.
  54840. */
  54841. abstract _disposeMesh(mesh: Mesh): void;
  54842. /**
  54843. * Serializes this layer (Glow or Highlight for example)
  54844. * @returns a serialized layer object
  54845. */
  54846. abstract serialize?(): any;
  54847. /**
  54848. * Initializes the effect layer with the required options.
  54849. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54850. */
  54851. protected _init(options: Partial<IEffectLayerOptions>): void;
  54852. /**
  54853. * Generates the index buffer of the full screen quad blending to the main canvas.
  54854. */
  54855. private _generateIndexBuffer;
  54856. /**
  54857. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54858. */
  54859. private _generateVertexBuffer;
  54860. /**
  54861. * Sets the main texture desired size which is the closest power of two
  54862. * of the engine canvas size.
  54863. */
  54864. private _setMainTextureSize;
  54865. /**
  54866. * Creates the main texture for the effect layer.
  54867. */
  54868. protected _createMainTexture(): void;
  54869. /**
  54870. * Adds specific effects defines.
  54871. * @param defines The defines to add specifics to.
  54872. */
  54873. protected _addCustomEffectDefines(defines: string[]): void;
  54874. /**
  54875. * Checks for the readiness of the element composing the layer.
  54876. * @param subMesh the mesh to check for
  54877. * @param useInstances specify wether or not to use instances to render the mesh
  54878. * @param emissiveTexture the associated emissive texture used to generate the glow
  54879. * @return true if ready otherwise, false
  54880. */
  54881. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54882. /**
  54883. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54884. */
  54885. render(): void;
  54886. /**
  54887. * Determine if a given mesh will be used in the current effect.
  54888. * @param mesh mesh to test
  54889. * @returns true if the mesh will be used
  54890. */
  54891. hasMesh(mesh: AbstractMesh): boolean;
  54892. /**
  54893. * Returns true if the layer contains information to display, otherwise false.
  54894. * @returns true if the glow layer should be rendered
  54895. */
  54896. shouldRender(): boolean;
  54897. /**
  54898. * Returns true if the mesh should render, otherwise false.
  54899. * @param mesh The mesh to render
  54900. * @returns true if it should render otherwise false
  54901. */
  54902. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  54903. /**
  54904. * Returns true if the mesh can be rendered, otherwise false.
  54905. * @param mesh The mesh to render
  54906. * @param material The material used on the mesh
  54907. * @returns true if it can be rendered otherwise false
  54908. */
  54909. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54910. /**
  54911. * Returns true if the mesh should render, otherwise false.
  54912. * @param mesh The mesh to render
  54913. * @returns true if it should render otherwise false
  54914. */
  54915. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  54916. /**
  54917. * Renders the submesh passed in parameter to the generation map.
  54918. */
  54919. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  54920. /**
  54921. * Defines wether the current material of the mesh should be use to render the effect.
  54922. * @param mesh defines the current mesh to render
  54923. */
  54924. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54925. /**
  54926. * Rebuild the required buffers.
  54927. * @hidden Internal use only.
  54928. */
  54929. _rebuild(): void;
  54930. /**
  54931. * Dispose only the render target textures and post process.
  54932. */
  54933. private _disposeTextureAndPostProcesses;
  54934. /**
  54935. * Dispose the highlight layer and free resources.
  54936. */
  54937. dispose(): void;
  54938. /**
  54939. * Gets the class name of the effect layer
  54940. * @returns the string with the class name of the effect layer
  54941. */
  54942. getClassName(): string;
  54943. /**
  54944. * Creates an effect layer from parsed effect layer data
  54945. * @param parsedEffectLayer defines effect layer data
  54946. * @param scene defines the current scene
  54947. * @param rootUrl defines the root URL containing the effect layer information
  54948. * @returns a parsed effect Layer
  54949. */
  54950. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  54951. }
  54952. }
  54953. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  54954. import { Scene } from "babylonjs/scene";
  54955. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54956. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54957. import { AbstractScene } from "babylonjs/abstractScene";
  54958. module "babylonjs/abstractScene" {
  54959. interface AbstractScene {
  54960. /**
  54961. * The list of effect layers (highlights/glow) added to the scene
  54962. * @see http://doc.babylonjs.com/how_to/highlight_layer
  54963. * @see http://doc.babylonjs.com/how_to/glow_layer
  54964. */
  54965. effectLayers: Array<EffectLayer>;
  54966. /**
  54967. * Removes the given effect layer from this scene.
  54968. * @param toRemove defines the effect layer to remove
  54969. * @returns the index of the removed effect layer
  54970. */
  54971. removeEffectLayer(toRemove: EffectLayer): number;
  54972. /**
  54973. * Adds the given effect layer to this scene
  54974. * @param newEffectLayer defines the effect layer to add
  54975. */
  54976. addEffectLayer(newEffectLayer: EffectLayer): void;
  54977. }
  54978. }
  54979. /**
  54980. * Defines the layer scene component responsible to manage any effect layers
  54981. * in a given scene.
  54982. */
  54983. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  54984. /**
  54985. * The component name helpfull to identify the component in the list of scene components.
  54986. */
  54987. readonly name: string;
  54988. /**
  54989. * The scene the component belongs to.
  54990. */
  54991. scene: Scene;
  54992. private _engine;
  54993. private _renderEffects;
  54994. private _needStencil;
  54995. private _previousStencilState;
  54996. /**
  54997. * Creates a new instance of the component for the given scene
  54998. * @param scene Defines the scene to register the component in
  54999. */
  55000. constructor(scene: Scene);
  55001. /**
  55002. * Registers the component in a given scene
  55003. */
  55004. register(): void;
  55005. /**
  55006. * Rebuilds the elements related to this component in case of
  55007. * context lost for instance.
  55008. */
  55009. rebuild(): void;
  55010. /**
  55011. * Serializes the component data to the specified json object
  55012. * @param serializationObject The object to serialize to
  55013. */
  55014. serialize(serializationObject: any): void;
  55015. /**
  55016. * Adds all the elements from the container to the scene
  55017. * @param container the container holding the elements
  55018. */
  55019. addFromContainer(container: AbstractScene): void;
  55020. /**
  55021. * Removes all the elements in the container from the scene
  55022. * @param container contains the elements to remove
  55023. * @param dispose if the removed element should be disposed (default: false)
  55024. */
  55025. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55026. /**
  55027. * Disposes the component and the associated ressources.
  55028. */
  55029. dispose(): void;
  55030. private _isReadyForMesh;
  55031. private _renderMainTexture;
  55032. private _setStencil;
  55033. private _setStencilBack;
  55034. private _draw;
  55035. private _drawCamera;
  55036. private _drawRenderingGroup;
  55037. }
  55038. }
  55039. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55040. /** @hidden */
  55041. export var glowMapMergePixelShader: {
  55042. name: string;
  55043. shader: string;
  55044. };
  55045. }
  55046. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55047. /** @hidden */
  55048. export var glowMapMergeVertexShader: {
  55049. name: string;
  55050. shader: string;
  55051. };
  55052. }
  55053. declare module "babylonjs/Layers/glowLayer" {
  55054. import { Nullable } from "babylonjs/types";
  55055. import { Camera } from "babylonjs/Cameras/camera";
  55056. import { Scene } from "babylonjs/scene";
  55057. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55059. import { Mesh } from "babylonjs/Meshes/mesh";
  55060. import { Texture } from "babylonjs/Materials/Textures/texture";
  55061. import { Effect } from "babylonjs/Materials/effect";
  55062. import { Material } from "babylonjs/Materials/material";
  55063. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55064. import { Color4 } from "babylonjs/Maths/math.color";
  55065. import "babylonjs/Shaders/glowMapMerge.fragment";
  55066. import "babylonjs/Shaders/glowMapMerge.vertex";
  55067. import "babylonjs/Layers/effectLayerSceneComponent";
  55068. module "babylonjs/abstractScene" {
  55069. interface AbstractScene {
  55070. /**
  55071. * Return a the first highlight layer of the scene with a given name.
  55072. * @param name The name of the highlight layer to look for.
  55073. * @return The highlight layer if found otherwise null.
  55074. */
  55075. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55076. }
  55077. }
  55078. /**
  55079. * Glow layer options. This helps customizing the behaviour
  55080. * of the glow layer.
  55081. */
  55082. export interface IGlowLayerOptions {
  55083. /**
  55084. * Multiplication factor apply to the canvas size to compute the render target size
  55085. * used to generated the glowing objects (the smaller the faster).
  55086. */
  55087. mainTextureRatio: number;
  55088. /**
  55089. * Enforces a fixed size texture to ensure resize independant blur.
  55090. */
  55091. mainTextureFixedSize?: number;
  55092. /**
  55093. * How big is the kernel of the blur texture.
  55094. */
  55095. blurKernelSize: number;
  55096. /**
  55097. * The camera attached to the layer.
  55098. */
  55099. camera: Nullable<Camera>;
  55100. /**
  55101. * Enable MSAA by chosing the number of samples.
  55102. */
  55103. mainTextureSamples?: number;
  55104. /**
  55105. * The rendering group to draw the layer in.
  55106. */
  55107. renderingGroupId: number;
  55108. }
  55109. /**
  55110. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55111. *
  55112. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55113. *
  55114. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55115. */
  55116. export class GlowLayer extends EffectLayer {
  55117. /**
  55118. * Effect Name of the layer.
  55119. */
  55120. static readonly EffectName: string;
  55121. /**
  55122. * The default blur kernel size used for the glow.
  55123. */
  55124. static DefaultBlurKernelSize: number;
  55125. /**
  55126. * The default texture size ratio used for the glow.
  55127. */
  55128. static DefaultTextureRatio: number;
  55129. /**
  55130. * Sets the kernel size of the blur.
  55131. */
  55132. set blurKernelSize(value: number);
  55133. /**
  55134. * Gets the kernel size of the blur.
  55135. */
  55136. get blurKernelSize(): number;
  55137. /**
  55138. * Sets the glow intensity.
  55139. */
  55140. set intensity(value: number);
  55141. /**
  55142. * Gets the glow intensity.
  55143. */
  55144. get intensity(): number;
  55145. private _options;
  55146. private _intensity;
  55147. private _horizontalBlurPostprocess1;
  55148. private _verticalBlurPostprocess1;
  55149. private _horizontalBlurPostprocess2;
  55150. private _verticalBlurPostprocess2;
  55151. private _blurTexture1;
  55152. private _blurTexture2;
  55153. private _postProcesses1;
  55154. private _postProcesses2;
  55155. private _includedOnlyMeshes;
  55156. private _excludedMeshes;
  55157. private _meshesUsingTheirOwnMaterials;
  55158. /**
  55159. * Callback used to let the user override the color selection on a per mesh basis
  55160. */
  55161. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55162. /**
  55163. * Callback used to let the user override the texture selection on a per mesh basis
  55164. */
  55165. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55166. /**
  55167. * Instantiates a new glow Layer and references it to the scene.
  55168. * @param name The name of the layer
  55169. * @param scene The scene to use the layer in
  55170. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55171. */
  55172. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55173. /**
  55174. * Get the effect name of the layer.
  55175. * @return The effect name
  55176. */
  55177. getEffectName(): string;
  55178. /**
  55179. * Create the merge effect. This is the shader use to blit the information back
  55180. * to the main canvas at the end of the scene rendering.
  55181. */
  55182. protected _createMergeEffect(): Effect;
  55183. /**
  55184. * Creates the render target textures and post processes used in the glow layer.
  55185. */
  55186. protected _createTextureAndPostProcesses(): void;
  55187. /**
  55188. * Checks for the readiness of the element composing the layer.
  55189. * @param subMesh the mesh to check for
  55190. * @param useInstances specify wether or not to use instances to render the mesh
  55191. * @param emissiveTexture the associated emissive texture used to generate the glow
  55192. * @return true if ready otherwise, false
  55193. */
  55194. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55195. /**
  55196. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55197. */
  55198. needStencil(): boolean;
  55199. /**
  55200. * Returns true if the mesh can be rendered, otherwise false.
  55201. * @param mesh The mesh to render
  55202. * @param material The material used on the mesh
  55203. * @returns true if it can be rendered otherwise false
  55204. */
  55205. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55206. /**
  55207. * Implementation specific of rendering the generating effect on the main canvas.
  55208. * @param effect The effect used to render through
  55209. */
  55210. protected _internalRender(effect: Effect): void;
  55211. /**
  55212. * Sets the required values for both the emissive texture and and the main color.
  55213. */
  55214. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55215. /**
  55216. * Returns true if the mesh should render, otherwise false.
  55217. * @param mesh The mesh to render
  55218. * @returns true if it should render otherwise false
  55219. */
  55220. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55221. /**
  55222. * Adds specific effects defines.
  55223. * @param defines The defines to add specifics to.
  55224. */
  55225. protected _addCustomEffectDefines(defines: string[]): void;
  55226. /**
  55227. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55228. * @param mesh The mesh to exclude from the glow layer
  55229. */
  55230. addExcludedMesh(mesh: Mesh): void;
  55231. /**
  55232. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55233. * @param mesh The mesh to remove
  55234. */
  55235. removeExcludedMesh(mesh: Mesh): void;
  55236. /**
  55237. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55238. * @param mesh The mesh to include in the glow layer
  55239. */
  55240. addIncludedOnlyMesh(mesh: Mesh): void;
  55241. /**
  55242. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55243. * @param mesh The mesh to remove
  55244. */
  55245. removeIncludedOnlyMesh(mesh: Mesh): void;
  55246. /**
  55247. * Determine if a given mesh will be used in the glow layer
  55248. * @param mesh The mesh to test
  55249. * @returns true if the mesh will be highlighted by the current glow layer
  55250. */
  55251. hasMesh(mesh: AbstractMesh): boolean;
  55252. /**
  55253. * Defines wether the current material of the mesh should be use to render the effect.
  55254. * @param mesh defines the current mesh to render
  55255. */
  55256. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55257. /**
  55258. * Add a mesh to be rendered through its own material and not with emissive only.
  55259. * @param mesh The mesh for which we need to use its material
  55260. */
  55261. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55262. /**
  55263. * Remove a mesh from being rendered through its own material and not with emissive only.
  55264. * @param mesh The mesh for which we need to not use its material
  55265. */
  55266. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55267. /**
  55268. * Free any resources and references associated to a mesh.
  55269. * Internal use
  55270. * @param mesh The mesh to free.
  55271. * @hidden
  55272. */
  55273. _disposeMesh(mesh: Mesh): void;
  55274. /**
  55275. * Gets the class name of the effect layer
  55276. * @returns the string with the class name of the effect layer
  55277. */
  55278. getClassName(): string;
  55279. /**
  55280. * Serializes this glow layer
  55281. * @returns a serialized glow layer object
  55282. */
  55283. serialize(): any;
  55284. /**
  55285. * Creates a Glow Layer from parsed glow layer data
  55286. * @param parsedGlowLayer defines glow layer data
  55287. * @param scene defines the current scene
  55288. * @param rootUrl defines the root URL containing the glow layer information
  55289. * @returns a parsed Glow Layer
  55290. */
  55291. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55292. }
  55293. }
  55294. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55295. /** @hidden */
  55296. export var glowBlurPostProcessPixelShader: {
  55297. name: string;
  55298. shader: string;
  55299. };
  55300. }
  55301. declare module "babylonjs/Layers/highlightLayer" {
  55302. import { Observable } from "babylonjs/Misc/observable";
  55303. import { Nullable } from "babylonjs/types";
  55304. import { Camera } from "babylonjs/Cameras/camera";
  55305. import { Scene } from "babylonjs/scene";
  55306. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55308. import { Mesh } from "babylonjs/Meshes/mesh";
  55309. import { Effect } from "babylonjs/Materials/effect";
  55310. import { Material } from "babylonjs/Materials/material";
  55311. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55312. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55313. import "babylonjs/Shaders/glowMapMerge.fragment";
  55314. import "babylonjs/Shaders/glowMapMerge.vertex";
  55315. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55316. module "babylonjs/abstractScene" {
  55317. interface AbstractScene {
  55318. /**
  55319. * Return a the first highlight layer of the scene with a given name.
  55320. * @param name The name of the highlight layer to look for.
  55321. * @return The highlight layer if found otherwise null.
  55322. */
  55323. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55324. }
  55325. }
  55326. /**
  55327. * Highlight layer options. This helps customizing the behaviour
  55328. * of the highlight layer.
  55329. */
  55330. export interface IHighlightLayerOptions {
  55331. /**
  55332. * Multiplication factor apply to the canvas size to compute the render target size
  55333. * used to generated the glowing objects (the smaller the faster).
  55334. */
  55335. mainTextureRatio: number;
  55336. /**
  55337. * Enforces a fixed size texture to ensure resize independant blur.
  55338. */
  55339. mainTextureFixedSize?: number;
  55340. /**
  55341. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55342. * of the picture to blur (the smaller the faster).
  55343. */
  55344. blurTextureSizeRatio: number;
  55345. /**
  55346. * How big in texel of the blur texture is the vertical blur.
  55347. */
  55348. blurVerticalSize: number;
  55349. /**
  55350. * How big in texel of the blur texture is the horizontal blur.
  55351. */
  55352. blurHorizontalSize: number;
  55353. /**
  55354. * Alpha blending mode used to apply the blur. Default is combine.
  55355. */
  55356. alphaBlendingMode: number;
  55357. /**
  55358. * The camera attached to the layer.
  55359. */
  55360. camera: Nullable<Camera>;
  55361. /**
  55362. * Should we display highlight as a solid stroke?
  55363. */
  55364. isStroke?: boolean;
  55365. /**
  55366. * The rendering group to draw the layer in.
  55367. */
  55368. renderingGroupId: number;
  55369. }
  55370. /**
  55371. * The highlight layer Helps adding a glow effect around a mesh.
  55372. *
  55373. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55374. * glowy meshes to your scene.
  55375. *
  55376. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55377. */
  55378. export class HighlightLayer extends EffectLayer {
  55379. name: string;
  55380. /**
  55381. * Effect Name of the highlight layer.
  55382. */
  55383. static readonly EffectName: string;
  55384. /**
  55385. * The neutral color used during the preparation of the glow effect.
  55386. * This is black by default as the blend operation is a blend operation.
  55387. */
  55388. static NeutralColor: Color4;
  55389. /**
  55390. * Stencil value used for glowing meshes.
  55391. */
  55392. static GlowingMeshStencilReference: number;
  55393. /**
  55394. * Stencil value used for the other meshes in the scene.
  55395. */
  55396. static NormalMeshStencilReference: number;
  55397. /**
  55398. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55399. */
  55400. innerGlow: boolean;
  55401. /**
  55402. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55403. */
  55404. outerGlow: boolean;
  55405. /**
  55406. * Specifies the horizontal size of the blur.
  55407. */
  55408. set blurHorizontalSize(value: number);
  55409. /**
  55410. * Specifies the vertical size of the blur.
  55411. */
  55412. set blurVerticalSize(value: number);
  55413. /**
  55414. * Gets the horizontal size of the blur.
  55415. */
  55416. get blurHorizontalSize(): number;
  55417. /**
  55418. * Gets the vertical size of the blur.
  55419. */
  55420. get blurVerticalSize(): number;
  55421. /**
  55422. * An event triggered when the highlight layer is being blurred.
  55423. */
  55424. onBeforeBlurObservable: Observable<HighlightLayer>;
  55425. /**
  55426. * An event triggered when the highlight layer has been blurred.
  55427. */
  55428. onAfterBlurObservable: Observable<HighlightLayer>;
  55429. private _instanceGlowingMeshStencilReference;
  55430. private _options;
  55431. private _downSamplePostprocess;
  55432. private _horizontalBlurPostprocess;
  55433. private _verticalBlurPostprocess;
  55434. private _blurTexture;
  55435. private _meshes;
  55436. private _excludedMeshes;
  55437. /**
  55438. * Instantiates a new highlight Layer and references it to the scene..
  55439. * @param name The name of the layer
  55440. * @param scene The scene to use the layer in
  55441. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55442. */
  55443. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55444. /**
  55445. * Get the effect name of the layer.
  55446. * @return The effect name
  55447. */
  55448. getEffectName(): string;
  55449. /**
  55450. * Create the merge effect. This is the shader use to blit the information back
  55451. * to the main canvas at the end of the scene rendering.
  55452. */
  55453. protected _createMergeEffect(): Effect;
  55454. /**
  55455. * Creates the render target textures and post processes used in the highlight layer.
  55456. */
  55457. protected _createTextureAndPostProcesses(): void;
  55458. /**
  55459. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55460. */
  55461. needStencil(): boolean;
  55462. /**
  55463. * Checks for the readiness of the element composing the layer.
  55464. * @param subMesh the mesh to check for
  55465. * @param useInstances specify wether or not to use instances to render the mesh
  55466. * @param emissiveTexture the associated emissive texture used to generate the glow
  55467. * @return true if ready otherwise, false
  55468. */
  55469. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55470. /**
  55471. * Implementation specific of rendering the generating effect on the main canvas.
  55472. * @param effect The effect used to render through
  55473. */
  55474. protected _internalRender(effect: Effect): void;
  55475. /**
  55476. * Returns true if the layer contains information to display, otherwise false.
  55477. */
  55478. shouldRender(): boolean;
  55479. /**
  55480. * Returns true if the mesh should render, otherwise false.
  55481. * @param mesh The mesh to render
  55482. * @returns true if it should render otherwise false
  55483. */
  55484. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55485. /**
  55486. * Sets the required values for both the emissive texture and and the main color.
  55487. */
  55488. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55489. /**
  55490. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55491. * @param mesh The mesh to exclude from the highlight layer
  55492. */
  55493. addExcludedMesh(mesh: Mesh): void;
  55494. /**
  55495. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55496. * @param mesh The mesh to highlight
  55497. */
  55498. removeExcludedMesh(mesh: Mesh): void;
  55499. /**
  55500. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55501. * @param mesh mesh to test
  55502. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55503. */
  55504. hasMesh(mesh: AbstractMesh): boolean;
  55505. /**
  55506. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55507. * @param mesh The mesh to highlight
  55508. * @param color The color of the highlight
  55509. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55510. */
  55511. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55512. /**
  55513. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55514. * @param mesh The mesh to highlight
  55515. */
  55516. removeMesh(mesh: Mesh): void;
  55517. /**
  55518. * Force the stencil to the normal expected value for none glowing parts
  55519. */
  55520. private _defaultStencilReference;
  55521. /**
  55522. * Free any resources and references associated to a mesh.
  55523. * Internal use
  55524. * @param mesh The mesh to free.
  55525. * @hidden
  55526. */
  55527. _disposeMesh(mesh: Mesh): void;
  55528. /**
  55529. * Dispose the highlight layer and free resources.
  55530. */
  55531. dispose(): void;
  55532. /**
  55533. * Gets the class name of the effect layer
  55534. * @returns the string with the class name of the effect layer
  55535. */
  55536. getClassName(): string;
  55537. /**
  55538. * Serializes this Highlight layer
  55539. * @returns a serialized Highlight layer object
  55540. */
  55541. serialize(): any;
  55542. /**
  55543. * Creates a Highlight layer from parsed Highlight layer data
  55544. * @param parsedHightlightLayer defines the Highlight layer data
  55545. * @param scene defines the current scene
  55546. * @param rootUrl defines the root URL containing the Highlight layer information
  55547. * @returns a parsed Highlight layer
  55548. */
  55549. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55550. }
  55551. }
  55552. declare module "babylonjs/Layers/layerSceneComponent" {
  55553. import { Scene } from "babylonjs/scene";
  55554. import { ISceneComponent } from "babylonjs/sceneComponent";
  55555. import { Layer } from "babylonjs/Layers/layer";
  55556. import { AbstractScene } from "babylonjs/abstractScene";
  55557. module "babylonjs/abstractScene" {
  55558. interface AbstractScene {
  55559. /**
  55560. * The list of layers (background and foreground) of the scene
  55561. */
  55562. layers: Array<Layer>;
  55563. }
  55564. }
  55565. /**
  55566. * Defines the layer scene component responsible to manage any layers
  55567. * in a given scene.
  55568. */
  55569. export class LayerSceneComponent implements ISceneComponent {
  55570. /**
  55571. * The component name helpfull to identify the component in the list of scene components.
  55572. */
  55573. readonly name: string;
  55574. /**
  55575. * The scene the component belongs to.
  55576. */
  55577. scene: Scene;
  55578. private _engine;
  55579. /**
  55580. * Creates a new instance of the component for the given scene
  55581. * @param scene Defines the scene to register the component in
  55582. */
  55583. constructor(scene: Scene);
  55584. /**
  55585. * Registers the component in a given scene
  55586. */
  55587. register(): void;
  55588. /**
  55589. * Rebuilds the elements related to this component in case of
  55590. * context lost for instance.
  55591. */
  55592. rebuild(): void;
  55593. /**
  55594. * Disposes the component and the associated ressources.
  55595. */
  55596. dispose(): void;
  55597. private _draw;
  55598. private _drawCameraPredicate;
  55599. private _drawCameraBackground;
  55600. private _drawCameraForeground;
  55601. private _drawRenderTargetPredicate;
  55602. private _drawRenderTargetBackground;
  55603. private _drawRenderTargetForeground;
  55604. /**
  55605. * Adds all the elements from the container to the scene
  55606. * @param container the container holding the elements
  55607. */
  55608. addFromContainer(container: AbstractScene): void;
  55609. /**
  55610. * Removes all the elements in the container from the scene
  55611. * @param container contains the elements to remove
  55612. * @param dispose if the removed element should be disposed (default: false)
  55613. */
  55614. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55615. }
  55616. }
  55617. declare module "babylonjs/Shaders/layer.fragment" {
  55618. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55619. /** @hidden */
  55620. export var layerPixelShader: {
  55621. name: string;
  55622. shader: string;
  55623. };
  55624. }
  55625. declare module "babylonjs/Shaders/layer.vertex" {
  55626. /** @hidden */
  55627. export var layerVertexShader: {
  55628. name: string;
  55629. shader: string;
  55630. };
  55631. }
  55632. declare module "babylonjs/Layers/layer" {
  55633. import { Observable } from "babylonjs/Misc/observable";
  55634. import { Nullable } from "babylonjs/types";
  55635. import { Scene } from "babylonjs/scene";
  55636. import { Vector2 } from "babylonjs/Maths/math.vector";
  55637. import { Color4 } from "babylonjs/Maths/math.color";
  55638. import { Texture } from "babylonjs/Materials/Textures/texture";
  55639. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55640. import "babylonjs/Shaders/layer.fragment";
  55641. import "babylonjs/Shaders/layer.vertex";
  55642. /**
  55643. * This represents a full screen 2d layer.
  55644. * This can be useful to display a picture in the background of your scene for instance.
  55645. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55646. */
  55647. export class Layer {
  55648. /**
  55649. * Define the name of the layer.
  55650. */
  55651. name: string;
  55652. /**
  55653. * Define the texture the layer should display.
  55654. */
  55655. texture: Nullable<Texture>;
  55656. /**
  55657. * Is the layer in background or foreground.
  55658. */
  55659. isBackground: boolean;
  55660. /**
  55661. * Define the color of the layer (instead of texture).
  55662. */
  55663. color: Color4;
  55664. /**
  55665. * Define the scale of the layer in order to zoom in out of the texture.
  55666. */
  55667. scale: Vector2;
  55668. /**
  55669. * Define an offset for the layer in order to shift the texture.
  55670. */
  55671. offset: Vector2;
  55672. /**
  55673. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55674. */
  55675. alphaBlendingMode: number;
  55676. /**
  55677. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55678. * Alpha test will not mix with the background color in case of transparency.
  55679. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55680. */
  55681. alphaTest: boolean;
  55682. /**
  55683. * Define a mask to restrict the layer to only some of the scene cameras.
  55684. */
  55685. layerMask: number;
  55686. /**
  55687. * Define the list of render target the layer is visible into.
  55688. */
  55689. renderTargetTextures: RenderTargetTexture[];
  55690. /**
  55691. * Define if the layer is only used in renderTarget or if it also
  55692. * renders in the main frame buffer of the canvas.
  55693. */
  55694. renderOnlyInRenderTargetTextures: boolean;
  55695. private _scene;
  55696. private _vertexBuffers;
  55697. private _indexBuffer;
  55698. private _effect;
  55699. private _previousDefines;
  55700. /**
  55701. * An event triggered when the layer is disposed.
  55702. */
  55703. onDisposeObservable: Observable<Layer>;
  55704. private _onDisposeObserver;
  55705. /**
  55706. * Back compatibility with callback before the onDisposeObservable existed.
  55707. * The set callback will be triggered when the layer has been disposed.
  55708. */
  55709. set onDispose(callback: () => void);
  55710. /**
  55711. * An event triggered before rendering the scene
  55712. */
  55713. onBeforeRenderObservable: Observable<Layer>;
  55714. private _onBeforeRenderObserver;
  55715. /**
  55716. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55717. * The set callback will be triggered just before rendering the layer.
  55718. */
  55719. set onBeforeRender(callback: () => void);
  55720. /**
  55721. * An event triggered after rendering the scene
  55722. */
  55723. onAfterRenderObservable: Observable<Layer>;
  55724. private _onAfterRenderObserver;
  55725. /**
  55726. * Back compatibility with callback before the onAfterRenderObservable existed.
  55727. * The set callback will be triggered just after rendering the layer.
  55728. */
  55729. set onAfterRender(callback: () => void);
  55730. /**
  55731. * Instantiates a new layer.
  55732. * This represents a full screen 2d layer.
  55733. * This can be useful to display a picture in the background of your scene for instance.
  55734. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55735. * @param name Define the name of the layer in the scene
  55736. * @param imgUrl Define the url of the texture to display in the layer
  55737. * @param scene Define the scene the layer belongs to
  55738. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55739. * @param color Defines a color for the layer
  55740. */
  55741. constructor(
  55742. /**
  55743. * Define the name of the layer.
  55744. */
  55745. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55746. private _createIndexBuffer;
  55747. /** @hidden */
  55748. _rebuild(): void;
  55749. /**
  55750. * Renders the layer in the scene.
  55751. */
  55752. render(): void;
  55753. /**
  55754. * Disposes and releases the associated ressources.
  55755. */
  55756. dispose(): void;
  55757. }
  55758. }
  55759. declare module "babylonjs/Layers/index" {
  55760. export * from "babylonjs/Layers/effectLayer";
  55761. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55762. export * from "babylonjs/Layers/glowLayer";
  55763. export * from "babylonjs/Layers/highlightLayer";
  55764. export * from "babylonjs/Layers/layer";
  55765. export * from "babylonjs/Layers/layerSceneComponent";
  55766. }
  55767. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55768. /** @hidden */
  55769. export var lensFlarePixelShader: {
  55770. name: string;
  55771. shader: string;
  55772. };
  55773. }
  55774. declare module "babylonjs/Shaders/lensFlare.vertex" {
  55775. /** @hidden */
  55776. export var lensFlareVertexShader: {
  55777. name: string;
  55778. shader: string;
  55779. };
  55780. }
  55781. declare module "babylonjs/LensFlares/lensFlareSystem" {
  55782. import { Scene } from "babylonjs/scene";
  55783. import { Vector3 } from "babylonjs/Maths/math.vector";
  55784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55785. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  55786. import "babylonjs/Shaders/lensFlare.fragment";
  55787. import "babylonjs/Shaders/lensFlare.vertex";
  55788. import { Viewport } from "babylonjs/Maths/math.viewport";
  55789. /**
  55790. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55791. * It is usually composed of several `lensFlare`.
  55792. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55793. */
  55794. export class LensFlareSystem {
  55795. /**
  55796. * Define the name of the lens flare system
  55797. */
  55798. name: string;
  55799. /**
  55800. * List of lens flares used in this system.
  55801. */
  55802. lensFlares: LensFlare[];
  55803. /**
  55804. * Define a limit from the border the lens flare can be visible.
  55805. */
  55806. borderLimit: number;
  55807. /**
  55808. * Define a viewport border we do not want to see the lens flare in.
  55809. */
  55810. viewportBorder: number;
  55811. /**
  55812. * Define a predicate which could limit the list of meshes able to occlude the effect.
  55813. */
  55814. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55815. /**
  55816. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  55817. */
  55818. layerMask: number;
  55819. /**
  55820. * Define the id of the lens flare system in the scene.
  55821. * (equal to name by default)
  55822. */
  55823. id: string;
  55824. private _scene;
  55825. private _emitter;
  55826. private _vertexBuffers;
  55827. private _indexBuffer;
  55828. private _effect;
  55829. private _positionX;
  55830. private _positionY;
  55831. private _isEnabled;
  55832. /** @hidden */
  55833. static _SceneComponentInitialization: (scene: Scene) => void;
  55834. /**
  55835. * Instantiates a lens flare system.
  55836. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55837. * It is usually composed of several `lensFlare`.
  55838. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55839. * @param name Define the name of the lens flare system in the scene
  55840. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55841. * @param scene Define the scene the lens flare system belongs to
  55842. */
  55843. constructor(
  55844. /**
  55845. * Define the name of the lens flare system
  55846. */
  55847. name: string, emitter: any, scene: Scene);
  55848. /**
  55849. * Define if the lens flare system is enabled.
  55850. */
  55851. get isEnabled(): boolean;
  55852. set isEnabled(value: boolean);
  55853. /**
  55854. * Get the scene the effects belongs to.
  55855. * @returns the scene holding the lens flare system
  55856. */
  55857. getScene(): Scene;
  55858. /**
  55859. * Get the emitter of the lens flare system.
  55860. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55861. * @returns the emitter of the lens flare system
  55862. */
  55863. getEmitter(): any;
  55864. /**
  55865. * Set the emitter of the lens flare system.
  55866. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55867. * @param newEmitter Define the new emitter of the system
  55868. */
  55869. setEmitter(newEmitter: any): void;
  55870. /**
  55871. * Get the lens flare system emitter position.
  55872. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55873. * @returns the position
  55874. */
  55875. getEmitterPosition(): Vector3;
  55876. /**
  55877. * @hidden
  55878. */
  55879. computeEffectivePosition(globalViewport: Viewport): boolean;
  55880. /** @hidden */
  55881. _isVisible(): boolean;
  55882. /**
  55883. * @hidden
  55884. */
  55885. render(): boolean;
  55886. /**
  55887. * Dispose and release the lens flare with its associated resources.
  55888. */
  55889. dispose(): void;
  55890. /**
  55891. * Parse a lens flare system from a JSON repressentation
  55892. * @param parsedLensFlareSystem Define the JSON to parse
  55893. * @param scene Define the scene the parsed system should be instantiated in
  55894. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  55895. * @returns the parsed system
  55896. */
  55897. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  55898. /**
  55899. * Serialize the current Lens Flare System into a JSON representation.
  55900. * @returns the serialized JSON
  55901. */
  55902. serialize(): any;
  55903. }
  55904. }
  55905. declare module "babylonjs/LensFlares/lensFlare" {
  55906. import { Nullable } from "babylonjs/types";
  55907. import { Color3 } from "babylonjs/Maths/math.color";
  55908. import { Texture } from "babylonjs/Materials/Textures/texture";
  55909. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55910. /**
  55911. * This represents one of the lens effect in a `lensFlareSystem`.
  55912. * It controls one of the indiviual texture used in the effect.
  55913. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55914. */
  55915. export class LensFlare {
  55916. /**
  55917. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55918. */
  55919. size: number;
  55920. /**
  55921. * 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.
  55922. */
  55923. position: number;
  55924. /**
  55925. * Define the lens color.
  55926. */
  55927. color: Color3;
  55928. /**
  55929. * Define the lens texture.
  55930. */
  55931. texture: Nullable<Texture>;
  55932. /**
  55933. * Define the alpha mode to render this particular lens.
  55934. */
  55935. alphaMode: number;
  55936. private _system;
  55937. /**
  55938. * Creates a new Lens Flare.
  55939. * This represents one of the lens effect in a `lensFlareSystem`.
  55940. * It controls one of the indiviual texture used in the effect.
  55941. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55942. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  55943. * @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.
  55944. * @param color Define the lens color
  55945. * @param imgUrl Define the lens texture url
  55946. * @param system Define the `lensFlareSystem` this flare is part of
  55947. * @returns The newly created Lens Flare
  55948. */
  55949. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  55950. /**
  55951. * Instantiates a new Lens Flare.
  55952. * This represents one of the lens effect in a `lensFlareSystem`.
  55953. * It controls one of the indiviual texture used in the effect.
  55954. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55955. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  55956. * @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.
  55957. * @param color Define the lens color
  55958. * @param imgUrl Define the lens texture url
  55959. * @param system Define the `lensFlareSystem` this flare is part of
  55960. */
  55961. constructor(
  55962. /**
  55963. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55964. */
  55965. size: number,
  55966. /**
  55967. * 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.
  55968. */
  55969. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  55970. /**
  55971. * Dispose and release the lens flare with its associated resources.
  55972. */
  55973. dispose(): void;
  55974. }
  55975. }
  55976. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  55977. import { Nullable } from "babylonjs/types";
  55978. import { Scene } from "babylonjs/scene";
  55979. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55980. import { AbstractScene } from "babylonjs/abstractScene";
  55981. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55982. module "babylonjs/abstractScene" {
  55983. interface AbstractScene {
  55984. /**
  55985. * The list of lens flare system added to the scene
  55986. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55987. */
  55988. lensFlareSystems: Array<LensFlareSystem>;
  55989. /**
  55990. * Removes the given lens flare system from this scene.
  55991. * @param toRemove The lens flare system to remove
  55992. * @returns The index of the removed lens flare system
  55993. */
  55994. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  55995. /**
  55996. * Adds the given lens flare system to this scene
  55997. * @param newLensFlareSystem The lens flare system to add
  55998. */
  55999. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56000. /**
  56001. * Gets a lens flare system using its name
  56002. * @param name defines the name to look for
  56003. * @returns the lens flare system or null if not found
  56004. */
  56005. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56006. /**
  56007. * Gets a lens flare system using its id
  56008. * @param id defines the id to look for
  56009. * @returns the lens flare system or null if not found
  56010. */
  56011. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56012. }
  56013. }
  56014. /**
  56015. * Defines the lens flare scene component responsible to manage any lens flares
  56016. * in a given scene.
  56017. */
  56018. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56019. /**
  56020. * The component name helpfull to identify the component in the list of scene components.
  56021. */
  56022. readonly name: string;
  56023. /**
  56024. * The scene the component belongs to.
  56025. */
  56026. scene: Scene;
  56027. /**
  56028. * Creates a new instance of the component for the given scene
  56029. * @param scene Defines the scene to register the component in
  56030. */
  56031. constructor(scene: Scene);
  56032. /**
  56033. * Registers the component in a given scene
  56034. */
  56035. register(): void;
  56036. /**
  56037. * Rebuilds the elements related to this component in case of
  56038. * context lost for instance.
  56039. */
  56040. rebuild(): void;
  56041. /**
  56042. * Adds all the elements from the container to the scene
  56043. * @param container the container holding the elements
  56044. */
  56045. addFromContainer(container: AbstractScene): void;
  56046. /**
  56047. * Removes all the elements in the container from the scene
  56048. * @param container contains the elements to remove
  56049. * @param dispose if the removed element should be disposed (default: false)
  56050. */
  56051. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56052. /**
  56053. * Serializes the component data to the specified json object
  56054. * @param serializationObject The object to serialize to
  56055. */
  56056. serialize(serializationObject: any): void;
  56057. /**
  56058. * Disposes the component and the associated ressources.
  56059. */
  56060. dispose(): void;
  56061. private _draw;
  56062. }
  56063. }
  56064. declare module "babylonjs/LensFlares/index" {
  56065. export * from "babylonjs/LensFlares/lensFlare";
  56066. export * from "babylonjs/LensFlares/lensFlareSystem";
  56067. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56068. }
  56069. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56070. import { Scene } from "babylonjs/scene";
  56071. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56072. import { AbstractScene } from "babylonjs/abstractScene";
  56073. /**
  56074. * Defines the shadow generator component responsible to manage any shadow generators
  56075. * in a given scene.
  56076. */
  56077. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56078. /**
  56079. * The component name helpfull to identify the component in the list of scene components.
  56080. */
  56081. readonly name: string;
  56082. /**
  56083. * The scene the component belongs to.
  56084. */
  56085. scene: Scene;
  56086. /**
  56087. * Creates a new instance of the component for the given scene
  56088. * @param scene Defines the scene to register the component in
  56089. */
  56090. constructor(scene: Scene);
  56091. /**
  56092. * Registers the component in a given scene
  56093. */
  56094. register(): void;
  56095. /**
  56096. * Rebuilds the elements related to this component in case of
  56097. * context lost for instance.
  56098. */
  56099. rebuild(): void;
  56100. /**
  56101. * Serializes the component data to the specified json object
  56102. * @param serializationObject The object to serialize to
  56103. */
  56104. serialize(serializationObject: any): void;
  56105. /**
  56106. * Adds all the elements from the container to the scene
  56107. * @param container the container holding the elements
  56108. */
  56109. addFromContainer(container: AbstractScene): void;
  56110. /**
  56111. * Removes all the elements in the container from the scene
  56112. * @param container contains the elements to remove
  56113. * @param dispose if the removed element should be disposed (default: false)
  56114. */
  56115. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56116. /**
  56117. * Rebuilds the elements related to this component in case of
  56118. * context lost for instance.
  56119. */
  56120. dispose(): void;
  56121. private _gatherRenderTargets;
  56122. }
  56123. }
  56124. declare module "babylonjs/Lights/Shadows/index" {
  56125. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56126. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56127. }
  56128. declare module "babylonjs/Lights/pointLight" {
  56129. import { Scene } from "babylonjs/scene";
  56130. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56132. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56133. import { Effect } from "babylonjs/Materials/effect";
  56134. /**
  56135. * A point light is a light defined by an unique point in world space.
  56136. * The light is emitted in every direction from this point.
  56137. * A good example of a point light is a standard light bulb.
  56138. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56139. */
  56140. export class PointLight extends ShadowLight {
  56141. private _shadowAngle;
  56142. /**
  56143. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56144. * This specifies what angle the shadow will use to be created.
  56145. *
  56146. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56147. */
  56148. get shadowAngle(): number;
  56149. /**
  56150. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56151. * This specifies what angle the shadow will use to be created.
  56152. *
  56153. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56154. */
  56155. set shadowAngle(value: number);
  56156. /**
  56157. * Gets the direction if it has been set.
  56158. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56159. */
  56160. get direction(): Vector3;
  56161. /**
  56162. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56163. */
  56164. set direction(value: Vector3);
  56165. /**
  56166. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56167. * A PointLight emits the light in every direction.
  56168. * It can cast shadows.
  56169. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56170. * ```javascript
  56171. * var pointLight = new PointLight("pl", camera.position, scene);
  56172. * ```
  56173. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56174. * @param name The light friendly name
  56175. * @param position The position of the point light in the scene
  56176. * @param scene The scene the lights belongs to
  56177. */
  56178. constructor(name: string, position: Vector3, scene: Scene);
  56179. /**
  56180. * Returns the string "PointLight"
  56181. * @returns the class name
  56182. */
  56183. getClassName(): string;
  56184. /**
  56185. * Returns the integer 0.
  56186. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56187. */
  56188. getTypeID(): number;
  56189. /**
  56190. * Specifies wether or not the shadowmap should be a cube texture.
  56191. * @returns true if the shadowmap needs to be a cube texture.
  56192. */
  56193. needCube(): boolean;
  56194. /**
  56195. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56196. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56197. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56198. */
  56199. getShadowDirection(faceIndex?: number): Vector3;
  56200. /**
  56201. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56202. * - fov = PI / 2
  56203. * - aspect ratio : 1.0
  56204. * - z-near and far equal to the active camera minZ and maxZ.
  56205. * Returns the PointLight.
  56206. */
  56207. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56208. protected _buildUniformLayout(): void;
  56209. /**
  56210. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56211. * @param effect The effect to update
  56212. * @param lightIndex The index of the light in the effect to update
  56213. * @returns The point light
  56214. */
  56215. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56216. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56217. /**
  56218. * Prepares the list of defines specific to the light type.
  56219. * @param defines the list of defines
  56220. * @param lightIndex defines the index of the light for the effect
  56221. */
  56222. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56223. }
  56224. }
  56225. declare module "babylonjs/Lights/index" {
  56226. export * from "babylonjs/Lights/light";
  56227. export * from "babylonjs/Lights/shadowLight";
  56228. export * from "babylonjs/Lights/Shadows/index";
  56229. export * from "babylonjs/Lights/directionalLight";
  56230. export * from "babylonjs/Lights/hemisphericLight";
  56231. export * from "babylonjs/Lights/pointLight";
  56232. export * from "babylonjs/Lights/spotLight";
  56233. }
  56234. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56235. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56236. /**
  56237. * Header information of HDR texture files.
  56238. */
  56239. export interface HDRInfo {
  56240. /**
  56241. * The height of the texture in pixels.
  56242. */
  56243. height: number;
  56244. /**
  56245. * The width of the texture in pixels.
  56246. */
  56247. width: number;
  56248. /**
  56249. * The index of the beginning of the data in the binary file.
  56250. */
  56251. dataPosition: number;
  56252. }
  56253. /**
  56254. * This groups tools to convert HDR texture to native colors array.
  56255. */
  56256. export class HDRTools {
  56257. private static Ldexp;
  56258. private static Rgbe2float;
  56259. private static readStringLine;
  56260. /**
  56261. * Reads header information from an RGBE texture stored in a native array.
  56262. * More information on this format are available here:
  56263. * https://en.wikipedia.org/wiki/RGBE_image_format
  56264. *
  56265. * @param uint8array The binary file stored in native array.
  56266. * @return The header information.
  56267. */
  56268. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  56269. /**
  56270. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  56271. * This RGBE texture needs to store the information as a panorama.
  56272. *
  56273. * More information on this format are available here:
  56274. * https://en.wikipedia.org/wiki/RGBE_image_format
  56275. *
  56276. * @param buffer The binary file stored in an array buffer.
  56277. * @param size The expected size of the extracted cubemap.
  56278. * @return The Cube Map information.
  56279. */
  56280. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  56281. /**
  56282. * Returns the pixels data extracted from an RGBE texture.
  56283. * This pixels will be stored left to right up to down in the R G B order in one array.
  56284. *
  56285. * More information on this format are available here:
  56286. * https://en.wikipedia.org/wiki/RGBE_image_format
  56287. *
  56288. * @param uint8array The binary file stored in an array buffer.
  56289. * @param hdrInfo The header information of the file.
  56290. * @return The pixels data in RGB right to left up to down order.
  56291. */
  56292. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  56293. private static RGBE_ReadPixels_RLE;
  56294. }
  56295. }
  56296. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  56297. import { Nullable } from "babylonjs/types";
  56298. import { Scene } from "babylonjs/scene";
  56299. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56300. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56301. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56302. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  56303. /**
  56304. * This represents a texture coming from an HDR input.
  56305. *
  56306. * The only supported format is currently panorama picture stored in RGBE format.
  56307. * Example of such files can be found on HDRLib: http://hdrlib.com/
  56308. */
  56309. export class HDRCubeTexture extends BaseTexture {
  56310. private static _facesMapping;
  56311. private _generateHarmonics;
  56312. private _noMipmap;
  56313. private _textureMatrix;
  56314. private _size;
  56315. private _onLoad;
  56316. private _onError;
  56317. /**
  56318. * The texture URL.
  56319. */
  56320. url: string;
  56321. /**
  56322. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  56323. */
  56324. coordinatesMode: number;
  56325. protected _isBlocking: boolean;
  56326. /**
  56327. * Sets wether or not the texture is blocking during loading.
  56328. */
  56329. set isBlocking(value: boolean);
  56330. /**
  56331. * Gets wether or not the texture is blocking during loading.
  56332. */
  56333. get isBlocking(): boolean;
  56334. protected _rotationY: number;
  56335. /**
  56336. * Sets texture matrix rotation angle around Y axis in radians.
  56337. */
  56338. set rotationY(value: number);
  56339. /**
  56340. * Gets texture matrix rotation angle around Y axis radians.
  56341. */
  56342. get rotationY(): number;
  56343. /**
  56344. * Gets or sets the center of the bounding box associated with the cube texture
  56345. * It must define where the camera used to render the texture was set
  56346. */
  56347. boundingBoxPosition: Vector3;
  56348. private _boundingBoxSize;
  56349. /**
  56350. * Gets or sets the size of the bounding box associated with the cube texture
  56351. * When defined, the cubemap will switch to local mode
  56352. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56353. * @example https://www.babylonjs-playground.com/#RNASML
  56354. */
  56355. set boundingBoxSize(value: Vector3);
  56356. get boundingBoxSize(): Vector3;
  56357. /**
  56358. * Instantiates an HDRTexture from the following parameters.
  56359. *
  56360. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  56361. * @param scene The scene the texture will be used in
  56362. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56363. * @param noMipmap Forces to not generate the mipmap if true
  56364. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  56365. * @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)
  56366. * @param reserved Reserved flag for internal use.
  56367. */
  56368. 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>);
  56369. /**
  56370. * Get the current class name of the texture useful for serialization or dynamic coding.
  56371. * @returns "HDRCubeTexture"
  56372. */
  56373. getClassName(): string;
  56374. /**
  56375. * Occurs when the file is raw .hdr file.
  56376. */
  56377. private loadTexture;
  56378. clone(): HDRCubeTexture;
  56379. delayLoad(): void;
  56380. /**
  56381. * Get the texture reflection matrix used to rotate/transform the reflection.
  56382. * @returns the reflection matrix
  56383. */
  56384. getReflectionTextureMatrix(): Matrix;
  56385. /**
  56386. * Set the texture reflection matrix used to rotate/transform the reflection.
  56387. * @param value Define the reflection matrix to set
  56388. */
  56389. setReflectionTextureMatrix(value: Matrix): void;
  56390. /**
  56391. * Parses a JSON representation of an HDR Texture in order to create the texture
  56392. * @param parsedTexture Define the JSON representation
  56393. * @param scene Define the scene the texture should be created in
  56394. * @param rootUrl Define the root url in case we need to load relative dependencies
  56395. * @returns the newly created texture after parsing
  56396. */
  56397. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  56398. serialize(): any;
  56399. }
  56400. }
  56401. declare module "babylonjs/Physics/physicsEngine" {
  56402. import { Nullable } from "babylonjs/types";
  56403. import { Vector3 } from "babylonjs/Maths/math.vector";
  56404. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56405. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  56406. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  56407. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56408. /**
  56409. * Class used to control physics engine
  56410. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56411. */
  56412. export class PhysicsEngine implements IPhysicsEngine {
  56413. private _physicsPlugin;
  56414. /**
  56415. * Global value used to control the smallest number supported by the simulation
  56416. */
  56417. static Epsilon: number;
  56418. private _impostors;
  56419. private _joints;
  56420. private _subTimeStep;
  56421. /**
  56422. * Gets the gravity vector used by the simulation
  56423. */
  56424. gravity: Vector3;
  56425. /**
  56426. * Factory used to create the default physics plugin.
  56427. * @returns The default physics plugin
  56428. */
  56429. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  56430. /**
  56431. * Creates a new Physics Engine
  56432. * @param gravity defines the gravity vector used by the simulation
  56433. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  56434. */
  56435. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  56436. /**
  56437. * Sets the gravity vector used by the simulation
  56438. * @param gravity defines the gravity vector to use
  56439. */
  56440. setGravity(gravity: Vector3): void;
  56441. /**
  56442. * Set the time step of the physics engine.
  56443. * Default is 1/60.
  56444. * To slow it down, enter 1/600 for example.
  56445. * To speed it up, 1/30
  56446. * @param newTimeStep defines the new timestep to apply to this world.
  56447. */
  56448. setTimeStep(newTimeStep?: number): void;
  56449. /**
  56450. * Get the time step of the physics engine.
  56451. * @returns the current time step
  56452. */
  56453. getTimeStep(): number;
  56454. /**
  56455. * Set the sub time step of the physics engine.
  56456. * Default is 0 meaning there is no sub steps
  56457. * To increase physics resolution precision, set a small value (like 1 ms)
  56458. * @param subTimeStep defines the new sub timestep used for physics resolution.
  56459. */
  56460. setSubTimeStep(subTimeStep?: number): void;
  56461. /**
  56462. * Get the sub time step of the physics engine.
  56463. * @returns the current sub time step
  56464. */
  56465. getSubTimeStep(): number;
  56466. /**
  56467. * Release all resources
  56468. */
  56469. dispose(): void;
  56470. /**
  56471. * Gets the name of the current physics plugin
  56472. * @returns the name of the plugin
  56473. */
  56474. getPhysicsPluginName(): string;
  56475. /**
  56476. * Adding a new impostor for the impostor tracking.
  56477. * This will be done by the impostor itself.
  56478. * @param impostor the impostor to add
  56479. */
  56480. addImpostor(impostor: PhysicsImpostor): void;
  56481. /**
  56482. * Remove an impostor from the engine.
  56483. * This impostor and its mesh will not longer be updated by the physics engine.
  56484. * @param impostor the impostor to remove
  56485. */
  56486. removeImpostor(impostor: PhysicsImpostor): void;
  56487. /**
  56488. * Add a joint to the physics engine
  56489. * @param mainImpostor defines the main impostor to which the joint is added.
  56490. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  56491. * @param joint defines the joint that will connect both impostors.
  56492. */
  56493. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  56494. /**
  56495. * Removes a joint from the simulation
  56496. * @param mainImpostor defines the impostor used with the joint
  56497. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  56498. * @param joint defines the joint to remove
  56499. */
  56500. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  56501. /**
  56502. * Called by the scene. No need to call it.
  56503. * @param delta defines the timespam between frames
  56504. */
  56505. _step(delta: number): void;
  56506. /**
  56507. * Gets the current plugin used to run the simulation
  56508. * @returns current plugin
  56509. */
  56510. getPhysicsPlugin(): IPhysicsEnginePlugin;
  56511. /**
  56512. * Gets the list of physic impostors
  56513. * @returns an array of PhysicsImpostor
  56514. */
  56515. getImpostors(): Array<PhysicsImpostor>;
  56516. /**
  56517. * Gets the impostor for a physics enabled object
  56518. * @param object defines the object impersonated by the impostor
  56519. * @returns the PhysicsImpostor or null if not found
  56520. */
  56521. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  56522. /**
  56523. * Gets the impostor for a physics body object
  56524. * @param body defines physics body used by the impostor
  56525. * @returns the PhysicsImpostor or null if not found
  56526. */
  56527. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  56528. /**
  56529. * Does a raycast in the physics world
  56530. * @param from when should the ray start?
  56531. * @param to when should the ray end?
  56532. * @returns PhysicsRaycastResult
  56533. */
  56534. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56535. }
  56536. }
  56537. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  56538. import { Nullable } from "babylonjs/types";
  56539. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  56540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56541. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56542. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56543. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56544. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56545. /** @hidden */
  56546. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  56547. private _useDeltaForWorldStep;
  56548. world: any;
  56549. name: string;
  56550. private _physicsMaterials;
  56551. private _fixedTimeStep;
  56552. private _cannonRaycastResult;
  56553. private _raycastResult;
  56554. private _physicsBodysToRemoveAfterStep;
  56555. BJSCANNON: any;
  56556. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  56557. setGravity(gravity: Vector3): void;
  56558. setTimeStep(timeStep: number): void;
  56559. getTimeStep(): number;
  56560. executeStep(delta: number): void;
  56561. private _removeMarkedPhysicsBodiesFromWorld;
  56562. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56563. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56564. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56565. private _processChildMeshes;
  56566. removePhysicsBody(impostor: PhysicsImpostor): void;
  56567. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56568. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56569. private _addMaterial;
  56570. private _checkWithEpsilon;
  56571. private _createShape;
  56572. private _createHeightmap;
  56573. private _minus90X;
  56574. private _plus90X;
  56575. private _tmpPosition;
  56576. private _tmpDeltaPosition;
  56577. private _tmpUnityRotation;
  56578. private _updatePhysicsBodyTransformation;
  56579. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56580. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56581. isSupported(): boolean;
  56582. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56583. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56584. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56585. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56586. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56587. getBodyMass(impostor: PhysicsImpostor): number;
  56588. getBodyFriction(impostor: PhysicsImpostor): number;
  56589. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56590. getBodyRestitution(impostor: PhysicsImpostor): number;
  56591. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56592. sleepBody(impostor: PhysicsImpostor): void;
  56593. wakeUpBody(impostor: PhysicsImpostor): void;
  56594. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  56595. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56596. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56597. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56598. getRadius(impostor: PhysicsImpostor): number;
  56599. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56600. dispose(): void;
  56601. private _extendNamespace;
  56602. /**
  56603. * Does a raycast in the physics world
  56604. * @param from when should the ray start?
  56605. * @param to when should the ray end?
  56606. * @returns PhysicsRaycastResult
  56607. */
  56608. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56609. }
  56610. }
  56611. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  56612. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56613. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56614. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56616. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  56617. import { Nullable } from "babylonjs/types";
  56618. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56619. /** @hidden */
  56620. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  56621. world: any;
  56622. name: string;
  56623. BJSOIMO: any;
  56624. private _raycastResult;
  56625. constructor(iterations?: number, oimoInjection?: any);
  56626. setGravity(gravity: Vector3): void;
  56627. setTimeStep(timeStep: number): void;
  56628. getTimeStep(): number;
  56629. private _tmpImpostorsArray;
  56630. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56631. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56632. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56633. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56634. private _tmpPositionVector;
  56635. removePhysicsBody(impostor: PhysicsImpostor): void;
  56636. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56637. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56638. isSupported(): boolean;
  56639. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56640. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56641. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56642. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56643. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56644. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56645. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56646. getBodyMass(impostor: PhysicsImpostor): number;
  56647. getBodyFriction(impostor: PhysicsImpostor): number;
  56648. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56649. getBodyRestitution(impostor: PhysicsImpostor): number;
  56650. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56651. sleepBody(impostor: PhysicsImpostor): void;
  56652. wakeUpBody(impostor: PhysicsImpostor): void;
  56653. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56654. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  56655. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  56656. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56657. getRadius(impostor: PhysicsImpostor): number;
  56658. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56659. dispose(): void;
  56660. /**
  56661. * Does a raycast in the physics world
  56662. * @param from when should the ray start?
  56663. * @param to when should the ray end?
  56664. * @returns PhysicsRaycastResult
  56665. */
  56666. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56667. }
  56668. }
  56669. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56670. import { Nullable } from "babylonjs/types";
  56671. import { Scene } from "babylonjs/scene";
  56672. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56673. import { Color4 } from "babylonjs/Maths/math.color";
  56674. import { Mesh } from "babylonjs/Meshes/mesh";
  56675. /**
  56676. * Class containing static functions to help procedurally build meshes
  56677. */
  56678. export class RibbonBuilder {
  56679. /**
  56680. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56681. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56682. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56683. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56684. * * 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
  56685. * * 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
  56686. * * 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
  56687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56689. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56690. * * 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
  56691. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56692. * * 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
  56693. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56695. * @param name defines the name of the mesh
  56696. * @param options defines the options used to create the mesh
  56697. * @param scene defines the hosting scene
  56698. * @returns the ribbon mesh
  56699. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56700. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56701. */
  56702. static CreateRibbon(name: string, options: {
  56703. pathArray: Vector3[][];
  56704. closeArray?: boolean;
  56705. closePath?: boolean;
  56706. offset?: number;
  56707. updatable?: boolean;
  56708. sideOrientation?: number;
  56709. frontUVs?: Vector4;
  56710. backUVs?: Vector4;
  56711. instance?: Mesh;
  56712. invertUV?: boolean;
  56713. uvs?: Vector2[];
  56714. colors?: Color4[];
  56715. }, scene?: Nullable<Scene>): Mesh;
  56716. }
  56717. }
  56718. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56719. import { Nullable } from "babylonjs/types";
  56720. import { Scene } from "babylonjs/scene";
  56721. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56722. import { Mesh } from "babylonjs/Meshes/mesh";
  56723. /**
  56724. * Class containing static functions to help procedurally build meshes
  56725. */
  56726. export class ShapeBuilder {
  56727. /**
  56728. * 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.
  56729. * * 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.
  56730. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56731. * * 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.
  56732. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56733. * * 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
  56734. * * 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
  56735. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56738. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56740. * @param name defines the name of the mesh
  56741. * @param options defines the options used to create the mesh
  56742. * @param scene defines the hosting scene
  56743. * @returns the extruded shape mesh
  56744. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56746. */
  56747. static ExtrudeShape(name: string, options: {
  56748. shape: Vector3[];
  56749. path: Vector3[];
  56750. scale?: number;
  56751. rotation?: number;
  56752. cap?: number;
  56753. updatable?: boolean;
  56754. sideOrientation?: number;
  56755. frontUVs?: Vector4;
  56756. backUVs?: Vector4;
  56757. instance?: Mesh;
  56758. invertUV?: boolean;
  56759. }, scene?: Nullable<Scene>): Mesh;
  56760. /**
  56761. * Creates an custom extruded shape mesh.
  56762. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56763. * * 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.
  56764. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56765. * * 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
  56766. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56767. * * 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
  56768. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56769. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56770. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56771. * * 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
  56772. * * 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
  56773. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56776. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56778. * @param name defines the name of the mesh
  56779. * @param options defines the options used to create the mesh
  56780. * @param scene defines the hosting scene
  56781. * @returns the custom extruded shape mesh
  56782. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56783. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56784. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56785. */
  56786. static ExtrudeShapeCustom(name: string, options: {
  56787. shape: Vector3[];
  56788. path: Vector3[];
  56789. scaleFunction?: any;
  56790. rotationFunction?: any;
  56791. ribbonCloseArray?: boolean;
  56792. ribbonClosePath?: boolean;
  56793. cap?: number;
  56794. updatable?: boolean;
  56795. sideOrientation?: number;
  56796. frontUVs?: Vector4;
  56797. backUVs?: Vector4;
  56798. instance?: Mesh;
  56799. invertUV?: boolean;
  56800. }, scene?: Nullable<Scene>): Mesh;
  56801. private static _ExtrudeShapeGeneric;
  56802. }
  56803. }
  56804. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  56805. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  56806. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56807. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56808. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56809. import { Nullable } from "babylonjs/types";
  56810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56811. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56812. /**
  56813. * AmmoJS Physics plugin
  56814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  56815. * @see https://github.com/kripken/ammo.js/
  56816. */
  56817. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  56818. private _useDeltaForWorldStep;
  56819. /**
  56820. * Reference to the Ammo library
  56821. */
  56822. bjsAMMO: any;
  56823. /**
  56824. * Created ammoJS world which physics bodies are added to
  56825. */
  56826. world: any;
  56827. /**
  56828. * Name of the plugin
  56829. */
  56830. name: string;
  56831. private _timeStep;
  56832. private _fixedTimeStep;
  56833. private _maxSteps;
  56834. private _tmpQuaternion;
  56835. private _tmpAmmoTransform;
  56836. private _tmpAmmoQuaternion;
  56837. private _tmpAmmoConcreteContactResultCallback;
  56838. private _collisionConfiguration;
  56839. private _dispatcher;
  56840. private _overlappingPairCache;
  56841. private _solver;
  56842. private _softBodySolver;
  56843. private _tmpAmmoVectorA;
  56844. private _tmpAmmoVectorB;
  56845. private _tmpAmmoVectorC;
  56846. private _tmpAmmoVectorD;
  56847. private _tmpContactCallbackResult;
  56848. private _tmpAmmoVectorRCA;
  56849. private _tmpAmmoVectorRCB;
  56850. private _raycastResult;
  56851. private static readonly DISABLE_COLLISION_FLAG;
  56852. private static readonly KINEMATIC_FLAG;
  56853. private static readonly DISABLE_DEACTIVATION_FLAG;
  56854. /**
  56855. * Initializes the ammoJS plugin
  56856. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56857. * @param ammoInjection can be used to inject your own ammo reference
  56858. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56859. */
  56860. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56861. /**
  56862. * Sets the gravity of the physics world (m/(s^2))
  56863. * @param gravity Gravity to set
  56864. */
  56865. setGravity(gravity: Vector3): void;
  56866. /**
  56867. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56868. * @param timeStep timestep to use in seconds
  56869. */
  56870. setTimeStep(timeStep: number): void;
  56871. /**
  56872. * 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)
  56873. * @param fixedTimeStep fixedTimeStep to use in seconds
  56874. */
  56875. setFixedTimeStep(fixedTimeStep: number): void;
  56876. /**
  56877. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56878. * @param maxSteps the maximum number of steps by the physics engine per frame
  56879. */
  56880. setMaxSteps(maxSteps: number): void;
  56881. /**
  56882. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56883. * @returns the current timestep in seconds
  56884. */
  56885. getTimeStep(): number;
  56886. /**
  56887. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56888. */
  56889. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56890. private _isImpostorInContact;
  56891. private _isImpostorPairInContact;
  56892. private _stepSimulation;
  56893. /**
  56894. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56895. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56896. * After the step the babylon meshes are set to the position of the physics imposters
  56897. * @param delta amount of time to step forward
  56898. * @param impostors array of imposters to update before/after the step
  56899. */
  56900. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56901. /**
  56902. * Update babylon mesh to match physics world object
  56903. * @param impostor imposter to match
  56904. */
  56905. private _afterSoftStep;
  56906. /**
  56907. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56908. * @param impostor imposter to match
  56909. */
  56910. private _ropeStep;
  56911. /**
  56912. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56913. * @param impostor imposter to match
  56914. */
  56915. private _softbodyOrClothStep;
  56916. private _tmpVector;
  56917. private _tmpMatrix;
  56918. /**
  56919. * Applies an impulse on the imposter
  56920. * @param impostor imposter to apply impulse to
  56921. * @param force amount of force to be applied to the imposter
  56922. * @param contactPoint the location to apply the impulse on the imposter
  56923. */
  56924. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56925. /**
  56926. * Applies a force on the imposter
  56927. * @param impostor imposter to apply force
  56928. * @param force amount of force to be applied to the imposter
  56929. * @param contactPoint the location to apply the force on the imposter
  56930. */
  56931. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56932. /**
  56933. * Creates a physics body using the plugin
  56934. * @param impostor the imposter to create the physics body on
  56935. */
  56936. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56937. /**
  56938. * Removes the physics body from the imposter and disposes of the body's memory
  56939. * @param impostor imposter to remove the physics body from
  56940. */
  56941. removePhysicsBody(impostor: PhysicsImpostor): void;
  56942. /**
  56943. * Generates a joint
  56944. * @param impostorJoint the imposter joint to create the joint with
  56945. */
  56946. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56947. /**
  56948. * Removes a joint
  56949. * @param impostorJoint the imposter joint to remove the joint from
  56950. */
  56951. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56952. private _addMeshVerts;
  56953. /**
  56954. * Initialise the soft body vertices to match its object's (mesh) vertices
  56955. * Softbody vertices (nodes) are in world space and to match this
  56956. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56957. * @param impostor to create the softbody for
  56958. */
  56959. private _softVertexData;
  56960. /**
  56961. * Create an impostor's soft body
  56962. * @param impostor to create the softbody for
  56963. */
  56964. private _createSoftbody;
  56965. /**
  56966. * Create cloth for an impostor
  56967. * @param impostor to create the softbody for
  56968. */
  56969. private _createCloth;
  56970. /**
  56971. * Create rope for an impostor
  56972. * @param impostor to create the softbody for
  56973. */
  56974. private _createRope;
  56975. /**
  56976. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56977. * @param impostor to create the custom physics shape for
  56978. */
  56979. private _createCustom;
  56980. private _addHullVerts;
  56981. private _createShape;
  56982. /**
  56983. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56984. * @param impostor imposter containing the physics body and babylon object
  56985. */
  56986. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56987. /**
  56988. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56989. * @param impostor imposter containing the physics body and babylon object
  56990. * @param newPosition new position
  56991. * @param newRotation new rotation
  56992. */
  56993. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56994. /**
  56995. * If this plugin is supported
  56996. * @returns true if its supported
  56997. */
  56998. isSupported(): boolean;
  56999. /**
  57000. * Sets the linear velocity of the physics body
  57001. * @param impostor imposter to set the velocity on
  57002. * @param velocity velocity to set
  57003. */
  57004. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57005. /**
  57006. * Sets the angular velocity of the physics body
  57007. * @param impostor imposter to set the velocity on
  57008. * @param velocity velocity to set
  57009. */
  57010. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57011. /**
  57012. * gets the linear velocity
  57013. * @param impostor imposter to get linear velocity from
  57014. * @returns linear velocity
  57015. */
  57016. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57017. /**
  57018. * gets the angular velocity
  57019. * @param impostor imposter to get angular velocity from
  57020. * @returns angular velocity
  57021. */
  57022. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57023. /**
  57024. * Sets the mass of physics body
  57025. * @param impostor imposter to set the mass on
  57026. * @param mass mass to set
  57027. */
  57028. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57029. /**
  57030. * Gets the mass of the physics body
  57031. * @param impostor imposter to get the mass from
  57032. * @returns mass
  57033. */
  57034. getBodyMass(impostor: PhysicsImpostor): number;
  57035. /**
  57036. * Gets friction of the impostor
  57037. * @param impostor impostor to get friction from
  57038. * @returns friction value
  57039. */
  57040. getBodyFriction(impostor: PhysicsImpostor): number;
  57041. /**
  57042. * Sets friction of the impostor
  57043. * @param impostor impostor to set friction on
  57044. * @param friction friction value
  57045. */
  57046. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57047. /**
  57048. * Gets restitution of the impostor
  57049. * @param impostor impostor to get restitution from
  57050. * @returns restitution value
  57051. */
  57052. getBodyRestitution(impostor: PhysicsImpostor): number;
  57053. /**
  57054. * Sets resitution of the impostor
  57055. * @param impostor impostor to set resitution on
  57056. * @param restitution resitution value
  57057. */
  57058. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57059. /**
  57060. * Gets pressure inside the impostor
  57061. * @param impostor impostor to get pressure from
  57062. * @returns pressure value
  57063. */
  57064. getBodyPressure(impostor: PhysicsImpostor): number;
  57065. /**
  57066. * Sets pressure inside a soft body impostor
  57067. * Cloth and rope must remain 0 pressure
  57068. * @param impostor impostor to set pressure on
  57069. * @param pressure pressure value
  57070. */
  57071. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57072. /**
  57073. * Gets stiffness of the impostor
  57074. * @param impostor impostor to get stiffness from
  57075. * @returns pressure value
  57076. */
  57077. getBodyStiffness(impostor: PhysicsImpostor): number;
  57078. /**
  57079. * Sets stiffness of the impostor
  57080. * @param impostor impostor to set stiffness on
  57081. * @param stiffness stiffness value from 0 to 1
  57082. */
  57083. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57084. /**
  57085. * Gets velocityIterations of the impostor
  57086. * @param impostor impostor to get velocity iterations from
  57087. * @returns velocityIterations value
  57088. */
  57089. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57090. /**
  57091. * Sets velocityIterations of the impostor
  57092. * @param impostor impostor to set velocity iterations on
  57093. * @param velocityIterations velocityIterations value
  57094. */
  57095. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57096. /**
  57097. * Gets positionIterations of the impostor
  57098. * @param impostor impostor to get position iterations from
  57099. * @returns positionIterations value
  57100. */
  57101. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57102. /**
  57103. * Sets positionIterations of the impostor
  57104. * @param impostor impostor to set position on
  57105. * @param positionIterations positionIterations value
  57106. */
  57107. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57108. /**
  57109. * Append an anchor to a cloth object
  57110. * @param impostor is the cloth impostor to add anchor to
  57111. * @param otherImpostor is the rigid impostor to anchor to
  57112. * @param width ratio across width from 0 to 1
  57113. * @param height ratio up height from 0 to 1
  57114. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57115. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57116. */
  57117. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57118. /**
  57119. * Append an hook to a rope object
  57120. * @param impostor is the rope impostor to add hook to
  57121. * @param otherImpostor is the rigid impostor to hook to
  57122. * @param length ratio along the rope from 0 to 1
  57123. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57124. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57125. */
  57126. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57127. /**
  57128. * Sleeps the physics body and stops it from being active
  57129. * @param impostor impostor to sleep
  57130. */
  57131. sleepBody(impostor: PhysicsImpostor): void;
  57132. /**
  57133. * Activates the physics body
  57134. * @param impostor impostor to activate
  57135. */
  57136. wakeUpBody(impostor: PhysicsImpostor): void;
  57137. /**
  57138. * Updates the distance parameters of the joint
  57139. * @param joint joint to update
  57140. * @param maxDistance maximum distance of the joint
  57141. * @param minDistance minimum distance of the joint
  57142. */
  57143. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57144. /**
  57145. * Sets a motor on the joint
  57146. * @param joint joint to set motor on
  57147. * @param speed speed of the motor
  57148. * @param maxForce maximum force of the motor
  57149. * @param motorIndex index of the motor
  57150. */
  57151. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57152. /**
  57153. * Sets the motors limit
  57154. * @param joint joint to set limit on
  57155. * @param upperLimit upper limit
  57156. * @param lowerLimit lower limit
  57157. */
  57158. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57159. /**
  57160. * Syncs the position and rotation of a mesh with the impostor
  57161. * @param mesh mesh to sync
  57162. * @param impostor impostor to update the mesh with
  57163. */
  57164. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57165. /**
  57166. * Gets the radius of the impostor
  57167. * @param impostor impostor to get radius from
  57168. * @returns the radius
  57169. */
  57170. getRadius(impostor: PhysicsImpostor): number;
  57171. /**
  57172. * Gets the box size of the impostor
  57173. * @param impostor impostor to get box size from
  57174. * @param result the resulting box size
  57175. */
  57176. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57177. /**
  57178. * Disposes of the impostor
  57179. */
  57180. dispose(): void;
  57181. /**
  57182. * Does a raycast in the physics world
  57183. * @param from when should the ray start?
  57184. * @param to when should the ray end?
  57185. * @returns PhysicsRaycastResult
  57186. */
  57187. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57188. }
  57189. }
  57190. declare module "babylonjs/Probes/reflectionProbe" {
  57191. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57192. import { Vector3 } from "babylonjs/Maths/math.vector";
  57193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57194. import { Nullable } from "babylonjs/types";
  57195. import { Scene } from "babylonjs/scene";
  57196. module "babylonjs/abstractScene" {
  57197. interface AbstractScene {
  57198. /**
  57199. * The list of reflection probes added to the scene
  57200. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57201. */
  57202. reflectionProbes: Array<ReflectionProbe>;
  57203. /**
  57204. * Removes the given reflection probe from this scene.
  57205. * @param toRemove The reflection probe to remove
  57206. * @returns The index of the removed reflection probe
  57207. */
  57208. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57209. /**
  57210. * Adds the given reflection probe to this scene.
  57211. * @param newReflectionProbe The reflection probe to add
  57212. */
  57213. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57214. }
  57215. }
  57216. /**
  57217. * Class used to generate realtime reflection / refraction cube textures
  57218. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57219. */
  57220. export class ReflectionProbe {
  57221. /** defines the name of the probe */
  57222. name: string;
  57223. private _scene;
  57224. private _renderTargetTexture;
  57225. private _projectionMatrix;
  57226. private _viewMatrix;
  57227. private _target;
  57228. private _add;
  57229. private _attachedMesh;
  57230. private _invertYAxis;
  57231. /** Gets or sets probe position (center of the cube map) */
  57232. position: Vector3;
  57233. /**
  57234. * Creates a new reflection probe
  57235. * @param name defines the name of the probe
  57236. * @param size defines the texture resolution (for each face)
  57237. * @param scene defines the hosting scene
  57238. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57239. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57240. */
  57241. constructor(
  57242. /** defines the name of the probe */
  57243. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57244. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57245. get samples(): number;
  57246. set samples(value: number);
  57247. /** Gets or sets the refresh rate to use (on every frame by default) */
  57248. get refreshRate(): number;
  57249. set refreshRate(value: number);
  57250. /**
  57251. * Gets the hosting scene
  57252. * @returns a Scene
  57253. */
  57254. getScene(): Scene;
  57255. /** Gets the internal CubeTexture used to render to */
  57256. get cubeTexture(): RenderTargetTexture;
  57257. /** Gets the list of meshes to render */
  57258. get renderList(): Nullable<AbstractMesh[]>;
  57259. /**
  57260. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57261. * @param mesh defines the mesh to attach to
  57262. */
  57263. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57264. /**
  57265. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  57266. * @param renderingGroupId The rendering group id corresponding to its index
  57267. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57268. */
  57269. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  57270. /**
  57271. * Clean all associated resources
  57272. */
  57273. dispose(): void;
  57274. /**
  57275. * Converts the reflection probe information to a readable string for debug purpose.
  57276. * @param fullDetails Supports for multiple levels of logging within scene loading
  57277. * @returns the human readable reflection probe info
  57278. */
  57279. toString(fullDetails?: boolean): string;
  57280. /**
  57281. * Get the class name of the relfection probe.
  57282. * @returns "ReflectionProbe"
  57283. */
  57284. getClassName(): string;
  57285. /**
  57286. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  57287. * @returns The JSON representation of the texture
  57288. */
  57289. serialize(): any;
  57290. /**
  57291. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  57292. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  57293. * @param scene Define the scene the parsed reflection probe should be instantiated in
  57294. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  57295. * @returns The parsed reflection probe if successful
  57296. */
  57297. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  57298. }
  57299. }
  57300. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  57301. /** @hidden */
  57302. export var _BabylonLoaderRegistered: boolean;
  57303. /**
  57304. * Helps setting up some configuration for the babylon file loader.
  57305. */
  57306. export class BabylonFileLoaderConfiguration {
  57307. /**
  57308. * The loader does not allow injecting custom physix engine into the plugins.
  57309. * Unfortunately in ES6, we need to manually inject them into the plugin.
  57310. * So you could set this variable to your engine import to make it work.
  57311. */
  57312. static LoaderInjectedPhysicsEngine: any;
  57313. }
  57314. }
  57315. declare module "babylonjs/Loading/Plugins/index" {
  57316. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  57317. }
  57318. declare module "babylonjs/Loading/index" {
  57319. export * from "babylonjs/Loading/loadingScreen";
  57320. export * from "babylonjs/Loading/Plugins/index";
  57321. export * from "babylonjs/Loading/sceneLoader";
  57322. export * from "babylonjs/Loading/sceneLoaderFlags";
  57323. }
  57324. declare module "babylonjs/Materials/Background/index" {
  57325. export * from "babylonjs/Materials/Background/backgroundMaterial";
  57326. }
  57327. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  57328. import { Scene } from "babylonjs/scene";
  57329. import { Color3 } from "babylonjs/Maths/math.color";
  57330. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57332. /**
  57333. * The Physically based simple base material of BJS.
  57334. *
  57335. * This enables better naming and convention enforcements on top of the pbrMaterial.
  57336. * It is used as the base class for both the specGloss and metalRough conventions.
  57337. */
  57338. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  57339. /**
  57340. * Number of Simultaneous lights allowed on the material.
  57341. */
  57342. maxSimultaneousLights: number;
  57343. /**
  57344. * If sets to true, disables all the lights affecting the material.
  57345. */
  57346. disableLighting: boolean;
  57347. /**
  57348. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  57349. */
  57350. environmentTexture: BaseTexture;
  57351. /**
  57352. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57353. */
  57354. invertNormalMapX: boolean;
  57355. /**
  57356. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57357. */
  57358. invertNormalMapY: boolean;
  57359. /**
  57360. * Normal map used in the model.
  57361. */
  57362. normalTexture: BaseTexture;
  57363. /**
  57364. * Emissivie color used to self-illuminate the model.
  57365. */
  57366. emissiveColor: Color3;
  57367. /**
  57368. * Emissivie texture used to self-illuminate the model.
  57369. */
  57370. emissiveTexture: BaseTexture;
  57371. /**
  57372. * Occlusion Channel Strenght.
  57373. */
  57374. occlusionStrength: number;
  57375. /**
  57376. * Occlusion Texture of the material (adding extra occlusion effects).
  57377. */
  57378. occlusionTexture: BaseTexture;
  57379. /**
  57380. * Defines the alpha limits in alpha test mode.
  57381. */
  57382. alphaCutOff: number;
  57383. /**
  57384. * Gets the current double sided mode.
  57385. */
  57386. get doubleSided(): boolean;
  57387. /**
  57388. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57389. */
  57390. set doubleSided(value: boolean);
  57391. /**
  57392. * Stores the pre-calculated light information of a mesh in a texture.
  57393. */
  57394. lightmapTexture: BaseTexture;
  57395. /**
  57396. * If true, the light map contains occlusion information instead of lighting info.
  57397. */
  57398. useLightmapAsShadowmap: boolean;
  57399. /**
  57400. * Instantiates a new PBRMaterial instance.
  57401. *
  57402. * @param name The material name
  57403. * @param scene The scene the material will be use in.
  57404. */
  57405. constructor(name: string, scene: Scene);
  57406. getClassName(): string;
  57407. }
  57408. }
  57409. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  57410. import { Scene } from "babylonjs/scene";
  57411. import { Color3 } from "babylonjs/Maths/math.color";
  57412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57413. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  57414. /**
  57415. * The PBR material of BJS following the metal roughness convention.
  57416. *
  57417. * This fits to the PBR convention in the GLTF definition:
  57418. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  57419. */
  57420. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  57421. /**
  57422. * The base color has two different interpretations depending on the value of metalness.
  57423. * When the material is a metal, the base color is the specific measured reflectance value
  57424. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  57425. * of the material.
  57426. */
  57427. baseColor: Color3;
  57428. /**
  57429. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  57430. * well as opacity information in the alpha channel.
  57431. */
  57432. baseTexture: BaseTexture;
  57433. /**
  57434. * Specifies the metallic scalar value of the material.
  57435. * Can also be used to scale the metalness values of the metallic texture.
  57436. */
  57437. metallic: number;
  57438. /**
  57439. * Specifies the roughness scalar value of the material.
  57440. * Can also be used to scale the roughness values of the metallic texture.
  57441. */
  57442. roughness: number;
  57443. /**
  57444. * Texture containing both the metallic value in the B channel and the
  57445. * roughness value in the G channel to keep better precision.
  57446. */
  57447. metallicRoughnessTexture: BaseTexture;
  57448. /**
  57449. * Instantiates a new PBRMetalRoughnessMaterial instance.
  57450. *
  57451. * @param name The material name
  57452. * @param scene The scene the material will be use in.
  57453. */
  57454. constructor(name: string, scene: Scene);
  57455. /**
  57456. * Return the currrent class name of the material.
  57457. */
  57458. getClassName(): string;
  57459. /**
  57460. * Makes a duplicate of the current material.
  57461. * @param name - name to use for the new material.
  57462. */
  57463. clone(name: string): PBRMetallicRoughnessMaterial;
  57464. /**
  57465. * Serialize the material to a parsable JSON object.
  57466. */
  57467. serialize(): any;
  57468. /**
  57469. * Parses a JSON object correponding to the serialize function.
  57470. */
  57471. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  57472. }
  57473. }
  57474. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  57475. import { Scene } from "babylonjs/scene";
  57476. import { Color3 } from "babylonjs/Maths/math.color";
  57477. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57478. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  57479. /**
  57480. * The PBR material of BJS following the specular glossiness convention.
  57481. *
  57482. * This fits to the PBR convention in the GLTF definition:
  57483. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  57484. */
  57485. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  57486. /**
  57487. * Specifies the diffuse color of the material.
  57488. */
  57489. diffuseColor: Color3;
  57490. /**
  57491. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  57492. * channel.
  57493. */
  57494. diffuseTexture: BaseTexture;
  57495. /**
  57496. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  57497. */
  57498. specularColor: Color3;
  57499. /**
  57500. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  57501. */
  57502. glossiness: number;
  57503. /**
  57504. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  57505. */
  57506. specularGlossinessTexture: BaseTexture;
  57507. /**
  57508. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  57509. *
  57510. * @param name The material name
  57511. * @param scene The scene the material will be use in.
  57512. */
  57513. constructor(name: string, scene: Scene);
  57514. /**
  57515. * Return the currrent class name of the material.
  57516. */
  57517. getClassName(): string;
  57518. /**
  57519. * Makes a duplicate of the current material.
  57520. * @param name - name to use for the new material.
  57521. */
  57522. clone(name: string): PBRSpecularGlossinessMaterial;
  57523. /**
  57524. * Serialize the material to a parsable JSON object.
  57525. */
  57526. serialize(): any;
  57527. /**
  57528. * Parses a JSON object correponding to the serialize function.
  57529. */
  57530. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  57531. }
  57532. }
  57533. declare module "babylonjs/Materials/PBR/index" {
  57534. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57535. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  57536. export * from "babylonjs/Materials/PBR/pbrMaterial";
  57537. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  57538. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  57539. }
  57540. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  57541. import { Nullable } from "babylonjs/types";
  57542. import { Scene } from "babylonjs/scene";
  57543. import { Matrix } from "babylonjs/Maths/math.vector";
  57544. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57545. /**
  57546. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  57547. * It can help converting any input color in a desired output one. This can then be used to create effects
  57548. * from sepia, black and white to sixties or futuristic rendering...
  57549. *
  57550. * The only supported format is currently 3dl.
  57551. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  57552. */
  57553. export class ColorGradingTexture extends BaseTexture {
  57554. /**
  57555. * The current texture matrix. (will always be identity in color grading texture)
  57556. */
  57557. private _textureMatrix;
  57558. /**
  57559. * The texture URL.
  57560. */
  57561. url: string;
  57562. /**
  57563. * Empty line regex stored for GC.
  57564. */
  57565. private static _noneEmptyLineRegex;
  57566. private _engine;
  57567. /**
  57568. * Instantiates a ColorGradingTexture from the following parameters.
  57569. *
  57570. * @param url The location of the color gradind data (currently only supporting 3dl)
  57571. * @param scene The scene the texture will be used in
  57572. */
  57573. constructor(url: string, scene: Scene);
  57574. /**
  57575. * Returns the texture matrix used in most of the material.
  57576. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  57577. */
  57578. getTextureMatrix(): Matrix;
  57579. /**
  57580. * Occurs when the file being loaded is a .3dl LUT file.
  57581. */
  57582. private load3dlTexture;
  57583. /**
  57584. * Starts the loading process of the texture.
  57585. */
  57586. private loadTexture;
  57587. /**
  57588. * Clones the color gradind texture.
  57589. */
  57590. clone(): ColorGradingTexture;
  57591. /**
  57592. * Called during delayed load for textures.
  57593. */
  57594. delayLoad(): void;
  57595. /**
  57596. * Parses a color grading texture serialized by Babylon.
  57597. * @param parsedTexture The texture information being parsedTexture
  57598. * @param scene The scene to load the texture in
  57599. * @param rootUrl The root url of the data assets to load
  57600. * @return A color gradind texture
  57601. */
  57602. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  57603. /**
  57604. * Serializes the LUT texture to json format.
  57605. */
  57606. serialize(): any;
  57607. }
  57608. }
  57609. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  57610. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57611. import { Scene } from "babylonjs/scene";
  57612. import { Nullable } from "babylonjs/types";
  57613. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57614. /**
  57615. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  57616. */
  57617. export class EquiRectangularCubeTexture extends BaseTexture {
  57618. /** The six faces of the cube. */
  57619. private static _FacesMapping;
  57620. private _noMipmap;
  57621. private _onLoad;
  57622. private _onError;
  57623. /** The size of the cubemap. */
  57624. private _size;
  57625. /** The buffer of the image. */
  57626. private _buffer;
  57627. /** The width of the input image. */
  57628. private _width;
  57629. /** The height of the input image. */
  57630. private _height;
  57631. /** The URL to the image. */
  57632. url: string;
  57633. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  57634. coordinatesMode: number;
  57635. /**
  57636. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  57637. * @param url The location of the image
  57638. * @param scene The scene the texture will be used in
  57639. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57640. * @param noMipmap Forces to not generate the mipmap if true
  57641. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57642. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57643. * @param onLoad — defines a callback called when texture is loaded
  57644. * @param onError — defines a callback called if there is an error
  57645. */
  57646. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  57647. /**
  57648. * Load the image data, by putting the image on a canvas and extracting its buffer.
  57649. */
  57650. private loadImage;
  57651. /**
  57652. * Convert the image buffer into a cubemap and create a CubeTexture.
  57653. */
  57654. private loadTexture;
  57655. /**
  57656. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  57657. * @param buffer The ArrayBuffer that should be converted.
  57658. * @returns The buffer as Float32Array.
  57659. */
  57660. private getFloat32ArrayFromArrayBuffer;
  57661. /**
  57662. * Get the current class name of the texture useful for serialization or dynamic coding.
  57663. * @returns "EquiRectangularCubeTexture"
  57664. */
  57665. getClassName(): string;
  57666. /**
  57667. * Create a clone of the current EquiRectangularCubeTexture and return it.
  57668. * @returns A clone of the current EquiRectangularCubeTexture.
  57669. */
  57670. clone(): EquiRectangularCubeTexture;
  57671. }
  57672. }
  57673. declare module "babylonjs/Misc/tga" {
  57674. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57675. /**
  57676. * Based on jsTGALoader - Javascript loader for TGA file
  57677. * By Vincent Thibault
  57678. * @see http://blog.robrowser.com/javascript-tga-loader.html
  57679. */
  57680. export class TGATools {
  57681. private static _TYPE_INDEXED;
  57682. private static _TYPE_RGB;
  57683. private static _TYPE_GREY;
  57684. private static _TYPE_RLE_INDEXED;
  57685. private static _TYPE_RLE_RGB;
  57686. private static _TYPE_RLE_GREY;
  57687. private static _ORIGIN_MASK;
  57688. private static _ORIGIN_SHIFT;
  57689. private static _ORIGIN_BL;
  57690. private static _ORIGIN_BR;
  57691. private static _ORIGIN_UL;
  57692. private static _ORIGIN_UR;
  57693. /**
  57694. * Gets the header of a TGA file
  57695. * @param data defines the TGA data
  57696. * @returns the header
  57697. */
  57698. static GetTGAHeader(data: Uint8Array): any;
  57699. /**
  57700. * Uploads TGA content to a Babylon Texture
  57701. * @hidden
  57702. */
  57703. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  57704. /** @hidden */
  57705. 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;
  57706. /** @hidden */
  57707. 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;
  57708. /** @hidden */
  57709. 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;
  57710. /** @hidden */
  57711. 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;
  57712. /** @hidden */
  57713. 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;
  57714. /** @hidden */
  57715. 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;
  57716. }
  57717. }
  57718. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  57719. import { Nullable } from "babylonjs/types";
  57720. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57721. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57722. /**
  57723. * Implementation of the TGA Texture Loader.
  57724. * @hidden
  57725. */
  57726. export class _TGATextureLoader implements IInternalTextureLoader {
  57727. /**
  57728. * Defines wether the loader supports cascade loading the different faces.
  57729. */
  57730. readonly supportCascades: boolean;
  57731. /**
  57732. * This returns if the loader support the current file information.
  57733. * @param extension defines the file extension of the file being loaded
  57734. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57735. * @param fallback defines the fallback internal texture if any
  57736. * @param isBase64 defines whether the texture is encoded as a base64
  57737. * @param isBuffer defines whether the texture data are stored as a buffer
  57738. * @returns true if the loader can load the specified file
  57739. */
  57740. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57741. /**
  57742. * Transform the url before loading if required.
  57743. * @param rootUrl the url of the texture
  57744. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57745. * @returns the transformed texture
  57746. */
  57747. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57748. /**
  57749. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57750. * @param rootUrl the url of the texture
  57751. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57752. * @returns the fallback texture
  57753. */
  57754. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57755. /**
  57756. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  57757. * @param data contains the texture data
  57758. * @param texture defines the BabylonJS internal texture
  57759. * @param createPolynomials will be true if polynomials have been requested
  57760. * @param onLoad defines the callback to trigger once the texture is ready
  57761. * @param onError defines the callback to trigger in case of error
  57762. */
  57763. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57764. /**
  57765. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57766. * @param data contains the texture data
  57767. * @param texture defines the BabylonJS internal texture
  57768. * @param callback defines the method to call once ready to upload
  57769. */
  57770. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57771. }
  57772. }
  57773. declare module "babylonjs/Misc/basis" {
  57774. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57775. /**
  57776. * Info about the .basis files
  57777. */
  57778. class BasisFileInfo {
  57779. /**
  57780. * If the file has alpha
  57781. */
  57782. hasAlpha: boolean;
  57783. /**
  57784. * Info about each image of the basis file
  57785. */
  57786. images: Array<{
  57787. levels: Array<{
  57788. width: number;
  57789. height: number;
  57790. transcodedPixels: ArrayBufferView;
  57791. }>;
  57792. }>;
  57793. }
  57794. /**
  57795. * Result of transcoding a basis file
  57796. */
  57797. class TranscodeResult {
  57798. /**
  57799. * Info about the .basis file
  57800. */
  57801. fileInfo: BasisFileInfo;
  57802. /**
  57803. * Format to use when loading the file
  57804. */
  57805. format: number;
  57806. }
  57807. /**
  57808. * Configuration options for the Basis transcoder
  57809. */
  57810. export class BasisTranscodeConfiguration {
  57811. /**
  57812. * Supported compression formats used to determine the supported output format of the transcoder
  57813. */
  57814. supportedCompressionFormats?: {
  57815. /**
  57816. * etc1 compression format
  57817. */
  57818. etc1?: boolean;
  57819. /**
  57820. * s3tc compression format
  57821. */
  57822. s3tc?: boolean;
  57823. /**
  57824. * pvrtc compression format
  57825. */
  57826. pvrtc?: boolean;
  57827. /**
  57828. * etc2 compression format
  57829. */
  57830. etc2?: boolean;
  57831. };
  57832. /**
  57833. * If mipmap levels should be loaded for transcoded images (Default: true)
  57834. */
  57835. loadMipmapLevels?: boolean;
  57836. /**
  57837. * Index of a single image to load (Default: all images)
  57838. */
  57839. loadSingleImage?: number;
  57840. }
  57841. /**
  57842. * Used to load .Basis files
  57843. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  57844. */
  57845. export class BasisTools {
  57846. private static _IgnoreSupportedFormats;
  57847. /**
  57848. * URL to use when loading the basis transcoder
  57849. */
  57850. static JSModuleURL: string;
  57851. /**
  57852. * URL to use when loading the wasm module for the transcoder
  57853. */
  57854. static WasmModuleURL: string;
  57855. /**
  57856. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  57857. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  57858. * @returns internal format corresponding to the Basis format
  57859. */
  57860. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  57861. private static _WorkerPromise;
  57862. private static _Worker;
  57863. private static _actionId;
  57864. private static _CreateWorkerAsync;
  57865. /**
  57866. * Transcodes a loaded image file to compressed pixel data
  57867. * @param imageData image data to transcode
  57868. * @param config configuration options for the transcoding
  57869. * @returns a promise resulting in the transcoded image
  57870. */
  57871. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57872. /**
  57873. * Loads a texture from the transcode result
  57874. * @param texture texture load to
  57875. * @param transcodeResult the result of transcoding the basis file to load from
  57876. */
  57877. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57878. }
  57879. }
  57880. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  57881. import { Nullable } from "babylonjs/types";
  57882. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57883. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57884. /**
  57885. * Loader for .basis file format
  57886. */
  57887. export class _BasisTextureLoader implements IInternalTextureLoader {
  57888. /**
  57889. * Defines whether the loader supports cascade loading the different faces.
  57890. */
  57891. readonly supportCascades: boolean;
  57892. /**
  57893. * This returns if the loader support the current file information.
  57894. * @param extension defines the file extension of the file being loaded
  57895. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57896. * @param fallback defines the fallback internal texture if any
  57897. * @param isBase64 defines whether the texture is encoded as a base64
  57898. * @param isBuffer defines whether the texture data are stored as a buffer
  57899. * @returns true if the loader can load the specified file
  57900. */
  57901. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57902. /**
  57903. * Transform the url before loading if required.
  57904. * @param rootUrl the url of the texture
  57905. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57906. * @returns the transformed texture
  57907. */
  57908. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57909. /**
  57910. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57911. * @param rootUrl the url of the texture
  57912. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57913. * @returns the fallback texture
  57914. */
  57915. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57916. /**
  57917. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  57918. * @param data contains the texture data
  57919. * @param texture defines the BabylonJS internal texture
  57920. * @param createPolynomials will be true if polynomials have been requested
  57921. * @param onLoad defines the callback to trigger once the texture is ready
  57922. * @param onError defines the callback to trigger in case of error
  57923. */
  57924. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57925. /**
  57926. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57927. * @param data contains the texture data
  57928. * @param texture defines the BabylonJS internal texture
  57929. * @param callback defines the method to call once ready to upload
  57930. */
  57931. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57932. }
  57933. }
  57934. declare module "babylonjs/Materials/Textures/Loaders/index" {
  57935. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  57936. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  57937. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  57938. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  57939. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  57940. }
  57941. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  57942. import { Scene } from "babylonjs/scene";
  57943. import { Texture } from "babylonjs/Materials/Textures/texture";
  57944. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57945. /**
  57946. * 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.
  57947. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57948. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57949. */
  57950. export class CustomProceduralTexture extends ProceduralTexture {
  57951. private _animate;
  57952. private _time;
  57953. private _config;
  57954. private _texturePath;
  57955. /**
  57956. * Instantiates a new Custom Procedural Texture.
  57957. * 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.
  57958. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57959. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57960. * @param name Define the name of the texture
  57961. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57962. * @param size Define the size of the texture to create
  57963. * @param scene Define the scene the texture belongs to
  57964. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57965. * @param generateMipMaps Define if the texture should creates mip maps or not
  57966. */
  57967. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57968. private _loadJson;
  57969. /**
  57970. * Is the texture ready to be used ? (rendered at least once)
  57971. * @returns true if ready, otherwise, false.
  57972. */
  57973. isReady(): boolean;
  57974. /**
  57975. * Render the texture to its associated render target.
  57976. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57977. */
  57978. render(useCameraPostProcess?: boolean): void;
  57979. /**
  57980. * Update the list of dependant textures samplers in the shader.
  57981. */
  57982. updateTextures(): void;
  57983. /**
  57984. * Update the uniform values of the procedural texture in the shader.
  57985. */
  57986. updateShaderUniforms(): void;
  57987. /**
  57988. * Define if the texture animates or not.
  57989. */
  57990. get animate(): boolean;
  57991. set animate(value: boolean);
  57992. }
  57993. }
  57994. declare module "babylonjs/Shaders/noise.fragment" {
  57995. /** @hidden */
  57996. export var noisePixelShader: {
  57997. name: string;
  57998. shader: string;
  57999. };
  58000. }
  58001. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58002. import { Nullable } from "babylonjs/types";
  58003. import { Scene } from "babylonjs/scene";
  58004. import { Texture } from "babylonjs/Materials/Textures/texture";
  58005. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58006. import "babylonjs/Shaders/noise.fragment";
  58007. /**
  58008. * Class used to generate noise procedural textures
  58009. */
  58010. export class NoiseProceduralTexture extends ProceduralTexture {
  58011. private _time;
  58012. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58013. brightness: number;
  58014. /** Defines the number of octaves to process */
  58015. octaves: number;
  58016. /** Defines the level of persistence (0.8 by default) */
  58017. persistence: number;
  58018. /** Gets or sets animation speed factor (default is 1) */
  58019. animationSpeedFactor: number;
  58020. /**
  58021. * Creates a new NoiseProceduralTexture
  58022. * @param name defines the name fo the texture
  58023. * @param size defines the size of the texture (default is 256)
  58024. * @param scene defines the hosting scene
  58025. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58026. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58027. */
  58028. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58029. private _updateShaderUniforms;
  58030. protected _getDefines(): string;
  58031. /** Generate the current state of the procedural texture */
  58032. render(useCameraPostProcess?: boolean): void;
  58033. /**
  58034. * Serializes this noise procedural texture
  58035. * @returns a serialized noise procedural texture object
  58036. */
  58037. serialize(): any;
  58038. /**
  58039. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58040. * @param parsedTexture defines parsed texture data
  58041. * @param scene defines the current scene
  58042. * @param rootUrl defines the root URL containing noise procedural texture information
  58043. * @returns a parsed NoiseProceduralTexture
  58044. */
  58045. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58046. }
  58047. }
  58048. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58049. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58050. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58051. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58052. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58053. }
  58054. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58055. import { Nullable } from "babylonjs/types";
  58056. import { Scene } from "babylonjs/scene";
  58057. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58058. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58059. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58060. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58061. /**
  58062. * Raw cube texture where the raw buffers are passed in
  58063. */
  58064. export class RawCubeTexture extends CubeTexture {
  58065. /**
  58066. * Creates a cube texture where the raw buffers are passed in.
  58067. * @param scene defines the scene the texture is attached to
  58068. * @param data defines the array of data to use to create each face
  58069. * @param size defines the size of the textures
  58070. * @param format defines the format of the data
  58071. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58072. * @param generateMipMaps defines if the engine should generate the mip levels
  58073. * @param invertY defines if data must be stored with Y axis inverted
  58074. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58075. * @param compression defines the compression used (null by default)
  58076. */
  58077. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58078. /**
  58079. * Updates the raw cube texture.
  58080. * @param data defines the data to store
  58081. * @param format defines the data format
  58082. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58083. * @param invertY defines if data must be stored with Y axis inverted
  58084. * @param compression defines the compression used (null by default)
  58085. * @param level defines which level of the texture to update
  58086. */
  58087. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58088. /**
  58089. * Updates a raw cube texture with RGBD encoded data.
  58090. * @param data defines the array of data [mipmap][face] to use to create each face
  58091. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58092. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58093. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58094. * @returns a promsie that resolves when the operation is complete
  58095. */
  58096. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58097. /**
  58098. * Clones the raw cube texture.
  58099. * @return a new cube texture
  58100. */
  58101. clone(): CubeTexture;
  58102. /** @hidden */
  58103. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58104. }
  58105. }
  58106. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58107. import { Scene } from "babylonjs/scene";
  58108. import { Texture } from "babylonjs/Materials/Textures/texture";
  58109. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58110. /**
  58111. * Class used to store 3D textures containing user data
  58112. */
  58113. export class RawTexture3D extends Texture {
  58114. /** Gets or sets the texture format to use */
  58115. format: number;
  58116. private _engine;
  58117. /**
  58118. * Create a new RawTexture3D
  58119. * @param data defines the data of the texture
  58120. * @param width defines the width of the texture
  58121. * @param height defines the height of the texture
  58122. * @param depth defines the depth of the texture
  58123. * @param format defines the texture format to use
  58124. * @param scene defines the hosting scene
  58125. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58126. * @param invertY defines if texture must be stored with Y axis inverted
  58127. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58128. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58129. */
  58130. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58131. /** Gets or sets the texture format to use */
  58132. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58133. /**
  58134. * Update the texture with new data
  58135. * @param data defines the data to store in the texture
  58136. */
  58137. update(data: ArrayBufferView): void;
  58138. }
  58139. }
  58140. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58141. import { Scene } from "babylonjs/scene";
  58142. import { Texture } from "babylonjs/Materials/Textures/texture";
  58143. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58144. /**
  58145. * Class used to store 2D array textures containing user data
  58146. */
  58147. export class RawTexture2DArray extends Texture {
  58148. /** Gets or sets the texture format to use */
  58149. format: number;
  58150. private _engine;
  58151. /**
  58152. * Create a new RawTexture2DArray
  58153. * @param data defines the data of the texture
  58154. * @param width defines the width of the texture
  58155. * @param height defines the height of the texture
  58156. * @param depth defines the number of layers of the texture
  58157. * @param format defines the texture format to use
  58158. * @param scene defines the hosting scene
  58159. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58160. * @param invertY defines if texture must be stored with Y axis inverted
  58161. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58162. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58163. */
  58164. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58165. /** Gets or sets the texture format to use */
  58166. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58167. /**
  58168. * Update the texture with new data
  58169. * @param data defines the data to store in the texture
  58170. */
  58171. update(data: ArrayBufferView): void;
  58172. }
  58173. }
  58174. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58175. import { Scene } from "babylonjs/scene";
  58176. import { Plane } from "babylonjs/Maths/math.plane";
  58177. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58178. /**
  58179. * Creates a refraction texture used by refraction channel of the standard material.
  58180. * It is like a mirror but to see through a material.
  58181. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58182. */
  58183. export class RefractionTexture extends RenderTargetTexture {
  58184. /**
  58185. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58186. * 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.
  58187. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58188. */
  58189. refractionPlane: Plane;
  58190. /**
  58191. * Define how deep under the surface we should see.
  58192. */
  58193. depth: number;
  58194. /**
  58195. * Creates a refraction texture used by refraction channel of the standard material.
  58196. * It is like a mirror but to see through a material.
  58197. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58198. * @param name Define the texture name
  58199. * @param size Define the size of the underlying texture
  58200. * @param scene Define the scene the refraction belongs to
  58201. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58202. */
  58203. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58204. /**
  58205. * Clone the refraction texture.
  58206. * @returns the cloned texture
  58207. */
  58208. clone(): RefractionTexture;
  58209. /**
  58210. * Serialize the texture to a JSON representation you could use in Parse later on
  58211. * @returns the serialized JSON representation
  58212. */
  58213. serialize(): any;
  58214. }
  58215. }
  58216. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58217. import { Nullable } from "babylonjs/types";
  58218. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58219. import { Matrix } from "babylonjs/Maths/math.vector";
  58220. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58221. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58222. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58223. import { Scene } from "babylonjs/scene";
  58224. /**
  58225. * Defines the options related to the creation of an HtmlElementTexture
  58226. */
  58227. export interface IHtmlElementTextureOptions {
  58228. /**
  58229. * Defines wether mip maps should be created or not.
  58230. */
  58231. generateMipMaps?: boolean;
  58232. /**
  58233. * Defines the sampling mode of the texture.
  58234. */
  58235. samplingMode?: number;
  58236. /**
  58237. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58238. */
  58239. engine: Nullable<ThinEngine>;
  58240. /**
  58241. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58242. */
  58243. scene: Nullable<Scene>;
  58244. }
  58245. /**
  58246. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58247. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58248. * is automatically managed.
  58249. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58250. * in your application.
  58251. *
  58252. * As the update is not automatic, you need to call them manually.
  58253. */
  58254. export class HtmlElementTexture extends BaseTexture {
  58255. /**
  58256. * The texture URL.
  58257. */
  58258. element: HTMLVideoElement | HTMLCanvasElement;
  58259. private static readonly DefaultOptions;
  58260. private _textureMatrix;
  58261. private _engine;
  58262. private _isVideo;
  58263. private _generateMipMaps;
  58264. private _samplingMode;
  58265. /**
  58266. * Instantiates a HtmlElementTexture from the following parameters.
  58267. *
  58268. * @param name Defines the name of the texture
  58269. * @param element Defines the video or canvas the texture is filled with
  58270. * @param options Defines the other none mandatory texture creation options
  58271. */
  58272. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58273. private _createInternalTexture;
  58274. /**
  58275. * Returns the texture matrix used in most of the material.
  58276. */
  58277. getTextureMatrix(): Matrix;
  58278. /**
  58279. * Updates the content of the texture.
  58280. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58281. */
  58282. update(invertY?: Nullable<boolean>): void;
  58283. }
  58284. }
  58285. declare module "babylonjs/Materials/Textures/index" {
  58286. export * from "babylonjs/Materials/Textures/baseTexture";
  58287. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  58288. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  58289. export * from "babylonjs/Materials/Textures/cubeTexture";
  58290. export * from "babylonjs/Materials/Textures/dynamicTexture";
  58291. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  58292. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  58293. export * from "babylonjs/Materials/Textures/internalTexture";
  58294. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  58295. export * from "babylonjs/Materials/Textures/Loaders/index";
  58296. export * from "babylonjs/Materials/Textures/mirrorTexture";
  58297. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  58298. export * from "babylonjs/Materials/Textures/Procedurals/index";
  58299. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  58300. export * from "babylonjs/Materials/Textures/rawTexture";
  58301. export * from "babylonjs/Materials/Textures/rawTexture3D";
  58302. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  58303. export * from "babylonjs/Materials/Textures/refractionTexture";
  58304. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  58305. export * from "babylonjs/Materials/Textures/texture";
  58306. export * from "babylonjs/Materials/Textures/videoTexture";
  58307. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  58308. }
  58309. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  58310. /**
  58311. * Enum used to define the target of a block
  58312. */
  58313. export enum NodeMaterialBlockTargets {
  58314. /** Vertex shader */
  58315. Vertex = 1,
  58316. /** Fragment shader */
  58317. Fragment = 2,
  58318. /** Neutral */
  58319. Neutral = 4,
  58320. /** Vertex and Fragment */
  58321. VertexAndFragment = 3
  58322. }
  58323. }
  58324. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  58325. /**
  58326. * Defines the kind of connection point for node based material
  58327. */
  58328. export enum NodeMaterialBlockConnectionPointTypes {
  58329. /** Float */
  58330. Float = 1,
  58331. /** Int */
  58332. Int = 2,
  58333. /** Vector2 */
  58334. Vector2 = 4,
  58335. /** Vector3 */
  58336. Vector3 = 8,
  58337. /** Vector4 */
  58338. Vector4 = 16,
  58339. /** Color3 */
  58340. Color3 = 32,
  58341. /** Color4 */
  58342. Color4 = 64,
  58343. /** Matrix */
  58344. Matrix = 128,
  58345. /** Detect type based on connection */
  58346. AutoDetect = 1024,
  58347. /** Output type that will be defined by input type */
  58348. BasedOnInput = 2048
  58349. }
  58350. }
  58351. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  58352. /**
  58353. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  58354. */
  58355. export enum NodeMaterialBlockConnectionPointMode {
  58356. /** Value is an uniform */
  58357. Uniform = 0,
  58358. /** Value is a mesh attribute */
  58359. Attribute = 1,
  58360. /** Value is a varying between vertex and fragment shaders */
  58361. Varying = 2,
  58362. /** Mode is undefined */
  58363. Undefined = 3
  58364. }
  58365. }
  58366. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  58367. /**
  58368. * Enum used to define system values e.g. values automatically provided by the system
  58369. */
  58370. export enum NodeMaterialSystemValues {
  58371. /** World */
  58372. World = 1,
  58373. /** View */
  58374. View = 2,
  58375. /** Projection */
  58376. Projection = 3,
  58377. /** ViewProjection */
  58378. ViewProjection = 4,
  58379. /** WorldView */
  58380. WorldView = 5,
  58381. /** WorldViewProjection */
  58382. WorldViewProjection = 6,
  58383. /** CameraPosition */
  58384. CameraPosition = 7,
  58385. /** Fog Color */
  58386. FogColor = 8,
  58387. /** Delta time */
  58388. DeltaTime = 9
  58389. }
  58390. }
  58391. declare module "babylonjs/Materials/Node/Enums/index" {
  58392. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58393. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58394. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  58395. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58396. }
  58397. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  58398. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58399. /**
  58400. * Root class for all node material optimizers
  58401. */
  58402. export class NodeMaterialOptimizer {
  58403. /**
  58404. * Function used to optimize a NodeMaterial graph
  58405. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  58406. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  58407. */
  58408. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  58409. }
  58410. }
  58411. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  58412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58415. import { Scene } from "babylonjs/scene";
  58416. /**
  58417. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  58418. */
  58419. export class TransformBlock extends NodeMaterialBlock {
  58420. /**
  58421. * Defines the value to use to complement W value to transform it to a Vector4
  58422. */
  58423. complementW: number;
  58424. /**
  58425. * Defines the value to use to complement z value to transform it to a Vector4
  58426. */
  58427. complementZ: number;
  58428. /**
  58429. * Creates a new TransformBlock
  58430. * @param name defines the block name
  58431. */
  58432. constructor(name: string);
  58433. /**
  58434. * Gets the current class name
  58435. * @returns the class name
  58436. */
  58437. getClassName(): string;
  58438. /**
  58439. * Gets the vector input
  58440. */
  58441. get vector(): NodeMaterialConnectionPoint;
  58442. /**
  58443. * Gets the output component
  58444. */
  58445. get output(): NodeMaterialConnectionPoint;
  58446. /**
  58447. * Gets the matrix transform input
  58448. */
  58449. get transform(): NodeMaterialConnectionPoint;
  58450. protected _buildBlock(state: NodeMaterialBuildState): this;
  58451. serialize(): any;
  58452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58453. protected _dumpPropertiesCode(): string;
  58454. }
  58455. }
  58456. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  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 vertex position
  58462. */
  58463. export class VertexOutputBlock extends NodeMaterialBlock {
  58464. /**
  58465. * Creates a new VertexOutputBlock
  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 vector input component
  58476. */
  58477. get vector(): NodeMaterialConnectionPoint;
  58478. protected _buildBlock(state: NodeMaterialBuildState): this;
  58479. }
  58480. }
  58481. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  58482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58485. /**
  58486. * Block used to output the final color
  58487. */
  58488. export class FragmentOutputBlock extends NodeMaterialBlock {
  58489. /**
  58490. * Create a new FragmentOutputBlock
  58491. * @param name defines the block name
  58492. */
  58493. constructor(name: string);
  58494. /**
  58495. * Gets the current class name
  58496. * @returns the class name
  58497. */
  58498. getClassName(): string;
  58499. /**
  58500. * Gets the rgba input component
  58501. */
  58502. get rgba(): NodeMaterialConnectionPoint;
  58503. /**
  58504. * Gets the rgb input component
  58505. */
  58506. get rgb(): NodeMaterialConnectionPoint;
  58507. /**
  58508. * Gets the a input component
  58509. */
  58510. get a(): NodeMaterialConnectionPoint;
  58511. protected _buildBlock(state: NodeMaterialBuildState): this;
  58512. }
  58513. }
  58514. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  58515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58518. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58520. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58521. import { Effect } from "babylonjs/Materials/effect";
  58522. import { Mesh } from "babylonjs/Meshes/mesh";
  58523. import { Nullable } from "babylonjs/types";
  58524. import { Scene } from "babylonjs/scene";
  58525. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58526. /**
  58527. * Block used to read a reflection texture from a sampler
  58528. */
  58529. export class ReflectionTextureBlock extends NodeMaterialBlock {
  58530. private _define3DName;
  58531. private _defineCubicName;
  58532. private _defineExplicitName;
  58533. private _defineProjectionName;
  58534. private _defineLocalCubicName;
  58535. private _defineSphericalName;
  58536. private _definePlanarName;
  58537. private _defineEquirectangularName;
  58538. private _defineMirroredEquirectangularFixedName;
  58539. private _defineEquirectangularFixedName;
  58540. private _defineSkyboxName;
  58541. private _cubeSamplerName;
  58542. private _2DSamplerName;
  58543. private _positionUVWName;
  58544. private _directionWName;
  58545. private _reflectionCoordsName;
  58546. private _reflection2DCoordsName;
  58547. private _reflectionColorName;
  58548. private _reflectionMatrixName;
  58549. /**
  58550. * Gets or sets the texture associated with the node
  58551. */
  58552. texture: Nullable<BaseTexture>;
  58553. /**
  58554. * Create a new TextureBlock
  58555. * @param name defines the block name
  58556. */
  58557. constructor(name: string);
  58558. /**
  58559. * Gets the current class name
  58560. * @returns the class name
  58561. */
  58562. getClassName(): string;
  58563. /**
  58564. * Gets the world position input component
  58565. */
  58566. get position(): NodeMaterialConnectionPoint;
  58567. /**
  58568. * Gets the world position input component
  58569. */
  58570. get worldPosition(): NodeMaterialConnectionPoint;
  58571. /**
  58572. * Gets the world normal input component
  58573. */
  58574. get worldNormal(): NodeMaterialConnectionPoint;
  58575. /**
  58576. * Gets the world input component
  58577. */
  58578. get world(): NodeMaterialConnectionPoint;
  58579. /**
  58580. * Gets the camera (or eye) position component
  58581. */
  58582. get cameraPosition(): NodeMaterialConnectionPoint;
  58583. /**
  58584. * Gets the view input component
  58585. */
  58586. get view(): NodeMaterialConnectionPoint;
  58587. /**
  58588. * Gets the rgb output component
  58589. */
  58590. get rgb(): NodeMaterialConnectionPoint;
  58591. /**
  58592. * Gets the r output component
  58593. */
  58594. get r(): NodeMaterialConnectionPoint;
  58595. /**
  58596. * Gets the g output component
  58597. */
  58598. get g(): NodeMaterialConnectionPoint;
  58599. /**
  58600. * Gets the b output component
  58601. */
  58602. get b(): NodeMaterialConnectionPoint;
  58603. autoConfigure(material: NodeMaterial): void;
  58604. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58605. isReady(): boolean;
  58606. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58607. private _injectVertexCode;
  58608. private _writeOutput;
  58609. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58610. protected _dumpPropertiesCode(): string;
  58611. serialize(): any;
  58612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58613. }
  58614. }
  58615. declare module "babylonjs/Materials/Node/nodeMaterial" {
  58616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58617. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58618. import { Scene } from "babylonjs/scene";
  58619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58620. import { Matrix } from "babylonjs/Maths/math.vector";
  58621. import { Mesh } from "babylonjs/Meshes/mesh";
  58622. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58623. import { Observable } from "babylonjs/Misc/observable";
  58624. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58625. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58626. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58627. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58628. import { Nullable } from "babylonjs/types";
  58629. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58630. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58631. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58632. /**
  58633. * Interface used to configure the node material editor
  58634. */
  58635. export interface INodeMaterialEditorOptions {
  58636. /** Define the URl to load node editor script */
  58637. editorURL?: string;
  58638. }
  58639. /** @hidden */
  58640. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  58641. /** BONES */
  58642. NUM_BONE_INFLUENCERS: number;
  58643. BonesPerMesh: number;
  58644. BONETEXTURE: boolean;
  58645. /** MORPH TARGETS */
  58646. MORPHTARGETS: boolean;
  58647. MORPHTARGETS_NORMAL: boolean;
  58648. MORPHTARGETS_TANGENT: boolean;
  58649. MORPHTARGETS_UV: boolean;
  58650. NUM_MORPH_INFLUENCERS: number;
  58651. /** IMAGE PROCESSING */
  58652. IMAGEPROCESSING: boolean;
  58653. VIGNETTE: boolean;
  58654. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58655. VIGNETTEBLENDMODEOPAQUE: boolean;
  58656. TONEMAPPING: boolean;
  58657. TONEMAPPING_ACES: boolean;
  58658. CONTRAST: boolean;
  58659. EXPOSURE: boolean;
  58660. COLORCURVES: boolean;
  58661. COLORGRADING: boolean;
  58662. COLORGRADING3D: boolean;
  58663. SAMPLER3DGREENDEPTH: boolean;
  58664. SAMPLER3DBGRMAP: boolean;
  58665. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58666. /** MISC. */
  58667. BUMPDIRECTUV: number;
  58668. constructor();
  58669. setValue(name: string, value: boolean): void;
  58670. }
  58671. /**
  58672. * Class used to configure NodeMaterial
  58673. */
  58674. export interface INodeMaterialOptions {
  58675. /**
  58676. * Defines if blocks should emit comments
  58677. */
  58678. emitComments: boolean;
  58679. }
  58680. /**
  58681. * Class used to create a node based material built by assembling shader blocks
  58682. */
  58683. export class NodeMaterial extends PushMaterial {
  58684. private static _BuildIdGenerator;
  58685. private _options;
  58686. private _vertexCompilationState;
  58687. private _fragmentCompilationState;
  58688. private _sharedData;
  58689. private _buildId;
  58690. private _buildWasSuccessful;
  58691. private _cachedWorldViewMatrix;
  58692. private _cachedWorldViewProjectionMatrix;
  58693. private _optimizers;
  58694. private _animationFrame;
  58695. /** Define the URl to load node editor script */
  58696. static EditorURL: string;
  58697. private BJSNODEMATERIALEDITOR;
  58698. /** Get the inspector from bundle or global */
  58699. private _getGlobalNodeMaterialEditor;
  58700. /**
  58701. * Gets or sets data used by visual editor
  58702. * @see https://nme.babylonjs.com
  58703. */
  58704. editorData: any;
  58705. /**
  58706. * 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)
  58707. */
  58708. ignoreAlpha: boolean;
  58709. /**
  58710. * Defines the maximum number of lights that can be used in the material
  58711. */
  58712. maxSimultaneousLights: number;
  58713. /**
  58714. * Observable raised when the material is built
  58715. */
  58716. onBuildObservable: Observable<NodeMaterial>;
  58717. /**
  58718. * Gets or sets the root nodes of the material vertex shader
  58719. */
  58720. _vertexOutputNodes: NodeMaterialBlock[];
  58721. /**
  58722. * Gets or sets the root nodes of the material fragment (pixel) shader
  58723. */
  58724. _fragmentOutputNodes: NodeMaterialBlock[];
  58725. /** Gets or sets options to control the node material overall behavior */
  58726. get options(): INodeMaterialOptions;
  58727. set options(options: INodeMaterialOptions);
  58728. /**
  58729. * Default configuration related to image processing available in the standard Material.
  58730. */
  58731. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58732. /**
  58733. * Gets the image processing configuration used either in this material.
  58734. */
  58735. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58736. /**
  58737. * Sets the Default image processing configuration used either in the this material.
  58738. *
  58739. * If sets to null, the scene one is in use.
  58740. */
  58741. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58742. /**
  58743. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  58744. */
  58745. attachedBlocks: NodeMaterialBlock[];
  58746. /**
  58747. * Create a new node based material
  58748. * @param name defines the material name
  58749. * @param scene defines the hosting scene
  58750. * @param options defines creation option
  58751. */
  58752. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  58753. /**
  58754. * Gets the current class name of the material e.g. "NodeMaterial"
  58755. * @returns the class name
  58756. */
  58757. getClassName(): string;
  58758. /**
  58759. * Keep track of the image processing observer to allow dispose and replace.
  58760. */
  58761. private _imageProcessingObserver;
  58762. /**
  58763. * Attaches a new image processing configuration to the Standard Material.
  58764. * @param configuration
  58765. */
  58766. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58767. /**
  58768. * Get a block by its name
  58769. * @param name defines the name of the block to retrieve
  58770. * @returns the required block or null if not found
  58771. */
  58772. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  58773. /**
  58774. * Get a block by its name
  58775. * @param predicate defines the predicate used to find the good candidate
  58776. * @returns the required block or null if not found
  58777. */
  58778. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  58779. /**
  58780. * Get an input block by its name
  58781. * @param predicate defines the predicate used to find the good candidate
  58782. * @returns the required input block or null if not found
  58783. */
  58784. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  58785. /**
  58786. * Gets the list of input blocks attached to this material
  58787. * @returns an array of InputBlocks
  58788. */
  58789. getInputBlocks(): InputBlock[];
  58790. /**
  58791. * Adds a new optimizer to the list of optimizers
  58792. * @param optimizer defines the optimizers to add
  58793. * @returns the current material
  58794. */
  58795. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58796. /**
  58797. * Remove an optimizer from the list of optimizers
  58798. * @param optimizer defines the optimizers to remove
  58799. * @returns the current material
  58800. */
  58801. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58802. /**
  58803. * Add a new block to the list of output nodes
  58804. * @param node defines the node to add
  58805. * @returns the current material
  58806. */
  58807. addOutputNode(node: NodeMaterialBlock): this;
  58808. /**
  58809. * Remove a block from the list of root nodes
  58810. * @param node defines the node to remove
  58811. * @returns the current material
  58812. */
  58813. removeOutputNode(node: NodeMaterialBlock): this;
  58814. private _addVertexOutputNode;
  58815. private _removeVertexOutputNode;
  58816. private _addFragmentOutputNode;
  58817. private _removeFragmentOutputNode;
  58818. /**
  58819. * Specifies if the material will require alpha blending
  58820. * @returns a boolean specifying if alpha blending is needed
  58821. */
  58822. needAlphaBlending(): boolean;
  58823. /**
  58824. * Specifies if this material should be rendered in alpha test mode
  58825. * @returns a boolean specifying if an alpha test is needed.
  58826. */
  58827. needAlphaTesting(): boolean;
  58828. private _initializeBlock;
  58829. private _resetDualBlocks;
  58830. /**
  58831. * Remove a block from the current node material
  58832. * @param block defines the block to remove
  58833. */
  58834. removeBlock(block: NodeMaterialBlock): void;
  58835. /**
  58836. * Build the material and generates the inner effect
  58837. * @param verbose defines if the build should log activity
  58838. */
  58839. build(verbose?: boolean): void;
  58840. /**
  58841. * Runs an otpimization phase to try to improve the shader code
  58842. */
  58843. optimize(): void;
  58844. private _prepareDefinesForAttributes;
  58845. /**
  58846. * Get if the submesh is ready to be used and all its information available.
  58847. * Child classes can use it to update shaders
  58848. * @param mesh defines the mesh to check
  58849. * @param subMesh defines which submesh to check
  58850. * @param useInstances specifies that instances should be used
  58851. * @returns a boolean indicating that the submesh is ready or not
  58852. */
  58853. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58854. /**
  58855. * Get a string representing the shaders built by the current node graph
  58856. */
  58857. get compiledShaders(): string;
  58858. /**
  58859. * Binds the world matrix to the material
  58860. * @param world defines the world transformation matrix
  58861. */
  58862. bindOnlyWorldMatrix(world: Matrix): void;
  58863. /**
  58864. * Binds the submesh to this material by preparing the effect and shader to draw
  58865. * @param world defines the world transformation matrix
  58866. * @param mesh defines the mesh containing the submesh
  58867. * @param subMesh defines the submesh to bind the material to
  58868. */
  58869. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58870. /**
  58871. * Gets the active textures from the material
  58872. * @returns an array of textures
  58873. */
  58874. getActiveTextures(): BaseTexture[];
  58875. /**
  58876. * Gets the list of texture blocks
  58877. * @returns an array of texture blocks
  58878. */
  58879. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  58880. /**
  58881. * Specifies if the material uses a texture
  58882. * @param texture defines the texture to check against the material
  58883. * @returns a boolean specifying if the material uses the texture
  58884. */
  58885. hasTexture(texture: BaseTexture): boolean;
  58886. /**
  58887. * Disposes the material
  58888. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58889. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58890. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58891. */
  58892. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58893. /** Creates the node editor window. */
  58894. private _createNodeEditor;
  58895. /**
  58896. * Launch the node material editor
  58897. * @param config Define the configuration of the editor
  58898. * @return a promise fulfilled when the node editor is visible
  58899. */
  58900. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58901. /**
  58902. * Clear the current material
  58903. */
  58904. clear(): void;
  58905. /**
  58906. * Clear the current material and set it to a default state
  58907. */
  58908. setToDefault(): void;
  58909. /**
  58910. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58911. * @param url defines the url to load from
  58912. * @returns a promise that will fullfil when the material is fully loaded
  58913. */
  58914. loadAsync(url: string): Promise<void>;
  58915. private _gatherBlocks;
  58916. /**
  58917. * Generate a string containing the code declaration required to create an equivalent of this material
  58918. * @returns a string
  58919. */
  58920. generateCode(): string;
  58921. /**
  58922. * Serializes this material in a JSON representation
  58923. * @returns the serialized material object
  58924. */
  58925. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58926. private _restoreConnections;
  58927. /**
  58928. * Clear the current graph and load a new one from a serialization object
  58929. * @param source defines the JSON representation of the material
  58930. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58931. */
  58932. loadFromSerialization(source: any, rootUrl?: string): void;
  58933. /**
  58934. * Creates a node material from parsed material data
  58935. * @param source defines the JSON representation of the material
  58936. * @param scene defines the hosting scene
  58937. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58938. * @returns a new node material
  58939. */
  58940. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58941. /**
  58942. * Creates a new node material set to default basic configuration
  58943. * @param name defines the name of the material
  58944. * @param scene defines the hosting scene
  58945. * @returns a new NodeMaterial
  58946. */
  58947. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58948. }
  58949. }
  58950. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  58951. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58953. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58954. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58956. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58957. import { Effect } from "babylonjs/Materials/effect";
  58958. import { Mesh } from "babylonjs/Meshes/mesh";
  58959. import { Nullable } from "babylonjs/types";
  58960. import { Texture } from "babylonjs/Materials/Textures/texture";
  58961. import { Scene } from "babylonjs/scene";
  58962. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58963. /**
  58964. * Block used to read a texture from a sampler
  58965. */
  58966. export class TextureBlock extends NodeMaterialBlock {
  58967. private _defineName;
  58968. private _linearDefineName;
  58969. private _tempTextureRead;
  58970. private _samplerName;
  58971. private _transformedUVName;
  58972. private _textureTransformName;
  58973. private _textureInfoName;
  58974. private _mainUVName;
  58975. private _mainUVDefineName;
  58976. /**
  58977. * Gets or sets the texture associated with the node
  58978. */
  58979. texture: Nullable<Texture>;
  58980. /**
  58981. * Create a new TextureBlock
  58982. * @param name defines the block name
  58983. */
  58984. constructor(name: string);
  58985. /**
  58986. * Gets the current class name
  58987. * @returns the class name
  58988. */
  58989. getClassName(): string;
  58990. /**
  58991. * Gets the uv input component
  58992. */
  58993. get uv(): NodeMaterialConnectionPoint;
  58994. /**
  58995. * Gets the rgba output component
  58996. */
  58997. get rgba(): NodeMaterialConnectionPoint;
  58998. /**
  58999. * Gets the rgb output component
  59000. */
  59001. get rgb(): NodeMaterialConnectionPoint;
  59002. /**
  59003. * Gets the r output component
  59004. */
  59005. get r(): NodeMaterialConnectionPoint;
  59006. /**
  59007. * Gets the g output component
  59008. */
  59009. get g(): NodeMaterialConnectionPoint;
  59010. /**
  59011. * Gets the b output component
  59012. */
  59013. get b(): NodeMaterialConnectionPoint;
  59014. /**
  59015. * Gets the a output component
  59016. */
  59017. get a(): NodeMaterialConnectionPoint;
  59018. get target(): NodeMaterialBlockTargets;
  59019. autoConfigure(material: NodeMaterial): void;
  59020. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59022. private _getTextureBase;
  59023. isReady(): boolean;
  59024. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59025. private get _isMixed();
  59026. private _injectVertexCode;
  59027. private _writeTextureRead;
  59028. private _writeOutput;
  59029. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59030. protected _dumpPropertiesCode(): string;
  59031. serialize(): any;
  59032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59033. }
  59034. }
  59035. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  59036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59037. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59038. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59039. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59040. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59041. import { Scene } from "babylonjs/scene";
  59042. /**
  59043. * Class used to store shared data between 2 NodeMaterialBuildState
  59044. */
  59045. export class NodeMaterialBuildStateSharedData {
  59046. /**
  59047. * Gets the list of emitted varyings
  59048. */
  59049. temps: string[];
  59050. /**
  59051. * Gets the list of emitted varyings
  59052. */
  59053. varyings: string[];
  59054. /**
  59055. * Gets the varying declaration string
  59056. */
  59057. varyingDeclaration: string;
  59058. /**
  59059. * Input blocks
  59060. */
  59061. inputBlocks: InputBlock[];
  59062. /**
  59063. * Input blocks
  59064. */
  59065. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  59066. /**
  59067. * Bindable blocks (Blocks that need to set data to the effect)
  59068. */
  59069. bindableBlocks: NodeMaterialBlock[];
  59070. /**
  59071. * List of blocks that can provide a compilation fallback
  59072. */
  59073. blocksWithFallbacks: NodeMaterialBlock[];
  59074. /**
  59075. * List of blocks that can provide a define update
  59076. */
  59077. blocksWithDefines: NodeMaterialBlock[];
  59078. /**
  59079. * List of blocks that can provide a repeatable content
  59080. */
  59081. repeatableContentBlocks: NodeMaterialBlock[];
  59082. /**
  59083. * List of blocks that can provide a dynamic list of uniforms
  59084. */
  59085. dynamicUniformBlocks: NodeMaterialBlock[];
  59086. /**
  59087. * List of blocks that can block the isReady function for the material
  59088. */
  59089. blockingBlocks: NodeMaterialBlock[];
  59090. /**
  59091. * Gets the list of animated inputs
  59092. */
  59093. animatedInputs: InputBlock[];
  59094. /**
  59095. * Build Id used to avoid multiple recompilations
  59096. */
  59097. buildId: number;
  59098. /** List of emitted variables */
  59099. variableNames: {
  59100. [key: string]: number;
  59101. };
  59102. /** List of emitted defines */
  59103. defineNames: {
  59104. [key: string]: number;
  59105. };
  59106. /** Should emit comments? */
  59107. emitComments: boolean;
  59108. /** Emit build activity */
  59109. verbose: boolean;
  59110. /** Gets or sets the hosting scene */
  59111. scene: Scene;
  59112. /**
  59113. * Gets the compilation hints emitted at compilation time
  59114. */
  59115. hints: {
  59116. needWorldViewMatrix: boolean;
  59117. needWorldViewProjectionMatrix: boolean;
  59118. needAlphaBlending: boolean;
  59119. needAlphaTesting: boolean;
  59120. };
  59121. /**
  59122. * List of compilation checks
  59123. */
  59124. checks: {
  59125. emitVertex: boolean;
  59126. emitFragment: boolean;
  59127. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  59128. };
  59129. /** Creates a new shared data */
  59130. constructor();
  59131. /**
  59132. * Emits console errors and exceptions if there is a failing check
  59133. */
  59134. emitErrors(): void;
  59135. }
  59136. }
  59137. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  59138. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59139. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59140. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  59141. /**
  59142. * Class used to store node based material build state
  59143. */
  59144. export class NodeMaterialBuildState {
  59145. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  59146. supportUniformBuffers: boolean;
  59147. /**
  59148. * Gets the list of emitted attributes
  59149. */
  59150. attributes: string[];
  59151. /**
  59152. * Gets the list of emitted uniforms
  59153. */
  59154. uniforms: string[];
  59155. /**
  59156. * Gets the list of emitted constants
  59157. */
  59158. constants: string[];
  59159. /**
  59160. * Gets the list of emitted samplers
  59161. */
  59162. samplers: string[];
  59163. /**
  59164. * Gets the list of emitted functions
  59165. */
  59166. functions: {
  59167. [key: string]: string;
  59168. };
  59169. /**
  59170. * Gets the list of emitted extensions
  59171. */
  59172. extensions: {
  59173. [key: string]: string;
  59174. };
  59175. /**
  59176. * Gets the target of the compilation state
  59177. */
  59178. target: NodeMaterialBlockTargets;
  59179. /**
  59180. * Gets the list of emitted counters
  59181. */
  59182. counters: {
  59183. [key: string]: number;
  59184. };
  59185. /**
  59186. * Shared data between multiple NodeMaterialBuildState instances
  59187. */
  59188. sharedData: NodeMaterialBuildStateSharedData;
  59189. /** @hidden */
  59190. _vertexState: NodeMaterialBuildState;
  59191. /** @hidden */
  59192. _attributeDeclaration: string;
  59193. /** @hidden */
  59194. _uniformDeclaration: string;
  59195. /** @hidden */
  59196. _constantDeclaration: string;
  59197. /** @hidden */
  59198. _samplerDeclaration: string;
  59199. /** @hidden */
  59200. _varyingTransfer: string;
  59201. private _repeatableContentAnchorIndex;
  59202. /** @hidden */
  59203. _builtCompilationString: string;
  59204. /**
  59205. * Gets the emitted compilation strings
  59206. */
  59207. compilationString: string;
  59208. /**
  59209. * Finalize the compilation strings
  59210. * @param state defines the current compilation state
  59211. */
  59212. finalize(state: NodeMaterialBuildState): void;
  59213. /** @hidden */
  59214. get _repeatableContentAnchor(): string;
  59215. /** @hidden */
  59216. _getFreeVariableName(prefix: string): string;
  59217. /** @hidden */
  59218. _getFreeDefineName(prefix: string): string;
  59219. /** @hidden */
  59220. _excludeVariableName(name: string): void;
  59221. /** @hidden */
  59222. _emit2DSampler(name: string): void;
  59223. /** @hidden */
  59224. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  59225. /** @hidden */
  59226. _emitExtension(name: string, extension: string): void;
  59227. /** @hidden */
  59228. _emitFunction(name: string, code: string, comments: string): void;
  59229. /** @hidden */
  59230. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  59231. replaceStrings?: {
  59232. search: RegExp;
  59233. replace: string;
  59234. }[];
  59235. repeatKey?: string;
  59236. }): string;
  59237. /** @hidden */
  59238. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  59239. repeatKey?: string;
  59240. removeAttributes?: boolean;
  59241. removeUniforms?: boolean;
  59242. removeVaryings?: boolean;
  59243. removeIfDef?: boolean;
  59244. replaceStrings?: {
  59245. search: RegExp;
  59246. replace: string;
  59247. }[];
  59248. }, storeKey?: string): void;
  59249. /** @hidden */
  59250. _registerTempVariable(name: string): boolean;
  59251. /** @hidden */
  59252. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  59253. /** @hidden */
  59254. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  59255. /** @hidden */
  59256. _emitFloat(value: number): string;
  59257. }
  59258. }
  59259. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  59260. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59261. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59262. import { Nullable } from "babylonjs/types";
  59263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59264. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59265. import { Effect } from "babylonjs/Materials/effect";
  59266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59267. import { Mesh } from "babylonjs/Meshes/mesh";
  59268. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59269. import { Scene } from "babylonjs/scene";
  59270. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59271. /**
  59272. * Defines a block that can be used inside a node based material
  59273. */
  59274. export class NodeMaterialBlock {
  59275. private _buildId;
  59276. private _buildTarget;
  59277. private _target;
  59278. private _isFinalMerger;
  59279. private _isInput;
  59280. protected _isUnique: boolean;
  59281. /** @hidden */
  59282. _codeVariableName: string;
  59283. /** @hidden */
  59284. _inputs: NodeMaterialConnectionPoint[];
  59285. /** @hidden */
  59286. _outputs: NodeMaterialConnectionPoint[];
  59287. /** @hidden */
  59288. _preparationId: number;
  59289. /**
  59290. * Gets or sets the name of the block
  59291. */
  59292. name: string;
  59293. /**
  59294. * Gets or sets the unique id of the node
  59295. */
  59296. uniqueId: number;
  59297. /**
  59298. * Gets or sets the comments associated with this block
  59299. */
  59300. comments: string;
  59301. /**
  59302. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  59303. */
  59304. get isUnique(): boolean;
  59305. /**
  59306. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  59307. */
  59308. get isFinalMerger(): boolean;
  59309. /**
  59310. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  59311. */
  59312. get isInput(): boolean;
  59313. /**
  59314. * Gets or sets the build Id
  59315. */
  59316. get buildId(): number;
  59317. set buildId(value: number);
  59318. /**
  59319. * Gets or sets the target of the block
  59320. */
  59321. get target(): NodeMaterialBlockTargets;
  59322. set target(value: NodeMaterialBlockTargets);
  59323. /**
  59324. * Gets the list of input points
  59325. */
  59326. get inputs(): NodeMaterialConnectionPoint[];
  59327. /** Gets the list of output points */
  59328. get outputs(): NodeMaterialConnectionPoint[];
  59329. /**
  59330. * Find an input by its name
  59331. * @param name defines the name of the input to look for
  59332. * @returns the input or null if not found
  59333. */
  59334. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59335. /**
  59336. * Find an output by its name
  59337. * @param name defines the name of the outputto look for
  59338. * @returns the output or null if not found
  59339. */
  59340. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59341. /**
  59342. * Creates a new NodeMaterialBlock
  59343. * @param name defines the block name
  59344. * @param target defines the target of that block (Vertex by default)
  59345. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  59346. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  59347. */
  59348. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  59349. /**
  59350. * Initialize the block and prepare the context for build
  59351. * @param state defines the state that will be used for the build
  59352. */
  59353. initialize(state: NodeMaterialBuildState): void;
  59354. /**
  59355. * Bind data to effect. Will only be called for blocks with isBindable === true
  59356. * @param effect defines the effect to bind data to
  59357. * @param nodeMaterial defines the hosting NodeMaterial
  59358. * @param mesh defines the mesh that will be rendered
  59359. */
  59360. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59361. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  59362. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  59363. protected _writeFloat(value: number): string;
  59364. /**
  59365. * Gets the current class name e.g. "NodeMaterialBlock"
  59366. * @returns the class name
  59367. */
  59368. getClassName(): string;
  59369. /**
  59370. * Register a new input. Must be called inside a block constructor
  59371. * @param name defines the connection point name
  59372. * @param type defines the connection point type
  59373. * @param isOptional defines a boolean indicating that this input can be omitted
  59374. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59375. * @returns the current block
  59376. */
  59377. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  59378. /**
  59379. * Register a new output. Must be called inside a block constructor
  59380. * @param name defines the connection point name
  59381. * @param type defines the connection point type
  59382. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59383. * @returns the current block
  59384. */
  59385. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  59386. /**
  59387. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  59388. * @param forOutput defines an optional connection point to check compatibility with
  59389. * @returns the first available input or null
  59390. */
  59391. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  59392. /**
  59393. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  59394. * @param forBlock defines an optional block to check compatibility with
  59395. * @returns the first available input or null
  59396. */
  59397. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  59398. /**
  59399. * Gets the sibling of the given output
  59400. * @param current defines the current output
  59401. * @returns the next output in the list or null
  59402. */
  59403. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  59404. /**
  59405. * Connect current block with another block
  59406. * @param other defines the block to connect with
  59407. * @param options define the various options to help pick the right connections
  59408. * @returns the current block
  59409. */
  59410. connectTo(other: NodeMaterialBlock, options?: {
  59411. input?: string;
  59412. output?: string;
  59413. outputSwizzle?: string;
  59414. }): this | undefined;
  59415. protected _buildBlock(state: NodeMaterialBuildState): void;
  59416. /**
  59417. * Add uniforms, samplers and uniform buffers at compilation time
  59418. * @param state defines the state to update
  59419. * @param nodeMaterial defines the node material requesting the update
  59420. * @param defines defines the material defines to update
  59421. * @param uniformBuffers defines the list of uniform buffer names
  59422. */
  59423. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59424. /**
  59425. * Add potential fallbacks if shader compilation fails
  59426. * @param mesh defines the mesh to be rendered
  59427. * @param fallbacks defines the current prioritized list of fallbacks
  59428. */
  59429. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59430. /**
  59431. * Initialize defines for shader compilation
  59432. * @param mesh defines the mesh to be rendered
  59433. * @param nodeMaterial defines the node material requesting the update
  59434. * @param defines defines the material defines to update
  59435. * @param useInstances specifies that instances should be used
  59436. */
  59437. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59438. /**
  59439. * Update defines for shader compilation
  59440. * @param mesh defines the mesh to be rendered
  59441. * @param nodeMaterial defines the node material requesting the update
  59442. * @param defines defines the material defines to update
  59443. * @param useInstances specifies that instances should be used
  59444. */
  59445. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59446. /**
  59447. * Lets the block try to connect some inputs automatically
  59448. * @param material defines the hosting NodeMaterial
  59449. */
  59450. autoConfigure(material: NodeMaterial): void;
  59451. /**
  59452. * Function called when a block is declared as repeatable content generator
  59453. * @param vertexShaderState defines the current compilation state for the vertex shader
  59454. * @param fragmentShaderState defines the current compilation state for the fragment shader
  59455. * @param mesh defines the mesh to be rendered
  59456. * @param defines defines the material defines to update
  59457. */
  59458. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59459. /**
  59460. * Checks if the block is ready
  59461. * @param mesh defines the mesh to be rendered
  59462. * @param nodeMaterial defines the node material requesting the update
  59463. * @param defines defines the material defines to update
  59464. * @param useInstances specifies that instances should be used
  59465. * @returns true if the block is ready
  59466. */
  59467. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  59468. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  59469. private _processBuild;
  59470. /**
  59471. * Compile the current node and generate the shader code
  59472. * @param state defines the current compilation state (uniforms, samplers, current string)
  59473. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  59474. * @returns true if already built
  59475. */
  59476. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  59477. protected _inputRename(name: string): string;
  59478. protected _outputRename(name: string): string;
  59479. protected _dumpPropertiesCode(): string;
  59480. /** @hidden */
  59481. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  59482. /** @hidden */
  59483. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  59484. /**
  59485. * Clone the current block to a new identical block
  59486. * @param scene defines the hosting scene
  59487. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59488. * @returns a copy of the current block
  59489. */
  59490. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  59491. /**
  59492. * Serializes this block in a JSON representation
  59493. * @returns the serialized block object
  59494. */
  59495. serialize(): any;
  59496. /** @hidden */
  59497. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59498. /**
  59499. * Release resources
  59500. */
  59501. dispose(): void;
  59502. }
  59503. }
  59504. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  59505. /**
  59506. * Enum defining the type of animations supported by InputBlock
  59507. */
  59508. export enum AnimatedInputBlockTypes {
  59509. /** No animation */
  59510. None = 0,
  59511. /** Time based animation. Will only work for floats */
  59512. Time = 1
  59513. }
  59514. }
  59515. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  59516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59517. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59518. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59519. import { Nullable } from "babylonjs/types";
  59520. import { Effect } from "babylonjs/Materials/effect";
  59521. import { Matrix } from "babylonjs/Maths/math.vector";
  59522. import { Scene } from "babylonjs/scene";
  59523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59525. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59526. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  59527. /**
  59528. * Block used to expose an input value
  59529. */
  59530. export class InputBlock extends NodeMaterialBlock {
  59531. private _mode;
  59532. private _associatedVariableName;
  59533. private _storedValue;
  59534. private _valueCallback;
  59535. private _type;
  59536. private _animationType;
  59537. /** Gets or set a value used to limit the range of float values */
  59538. min: number;
  59539. /** Gets or set a value used to limit the range of float values */
  59540. max: number;
  59541. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  59542. matrixMode: number;
  59543. /** @hidden */
  59544. _systemValue: Nullable<NodeMaterialSystemValues>;
  59545. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  59546. visibleInInspector: boolean;
  59547. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  59548. isConstant: boolean;
  59549. /** Gets or sets the group to use to display this block in the Inspector */
  59550. groupInInspector: string;
  59551. /**
  59552. * Gets or sets the connection point type (default is float)
  59553. */
  59554. get type(): NodeMaterialBlockConnectionPointTypes;
  59555. /**
  59556. * Creates a new InputBlock
  59557. * @param name defines the block name
  59558. * @param target defines the target of that block (Vertex by default)
  59559. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  59560. */
  59561. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  59562. /**
  59563. * Gets the output component
  59564. */
  59565. get output(): NodeMaterialConnectionPoint;
  59566. /**
  59567. * Set the source of this connection point to a vertex attribute
  59568. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  59569. * @returns the current connection point
  59570. */
  59571. setAsAttribute(attributeName?: string): InputBlock;
  59572. /**
  59573. * Set the source of this connection point to a system value
  59574. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  59575. * @returns the current connection point
  59576. */
  59577. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  59578. /**
  59579. * Gets or sets the value of that point.
  59580. * Please note that this value will be ignored if valueCallback is defined
  59581. */
  59582. get value(): any;
  59583. set value(value: any);
  59584. /**
  59585. * Gets or sets a callback used to get the value of that point.
  59586. * Please note that setting this value will force the connection point to ignore the value property
  59587. */
  59588. get valueCallback(): () => any;
  59589. set valueCallback(value: () => any);
  59590. /**
  59591. * Gets or sets the associated variable name in the shader
  59592. */
  59593. get associatedVariableName(): string;
  59594. set associatedVariableName(value: string);
  59595. /** Gets or sets the type of animation applied to the input */
  59596. get animationType(): AnimatedInputBlockTypes;
  59597. set animationType(value: AnimatedInputBlockTypes);
  59598. /**
  59599. * Gets a boolean indicating that this connection point not defined yet
  59600. */
  59601. get isUndefined(): boolean;
  59602. /**
  59603. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  59604. * In this case the connection point name must be the name of the uniform to use.
  59605. * Can only be set on inputs
  59606. */
  59607. get isUniform(): boolean;
  59608. set isUniform(value: boolean);
  59609. /**
  59610. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  59611. * In this case the connection point name must be the name of the attribute to use
  59612. * Can only be set on inputs
  59613. */
  59614. get isAttribute(): boolean;
  59615. set isAttribute(value: boolean);
  59616. /**
  59617. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  59618. * Can only be set on exit points
  59619. */
  59620. get isVarying(): boolean;
  59621. set isVarying(value: boolean);
  59622. /**
  59623. * Gets a boolean indicating that the current connection point is a system value
  59624. */
  59625. get isSystemValue(): boolean;
  59626. /**
  59627. * Gets or sets the current well known value or null if not defined as a system value
  59628. */
  59629. get systemValue(): Nullable<NodeMaterialSystemValues>;
  59630. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  59631. /**
  59632. * Gets the current class name
  59633. * @returns the class name
  59634. */
  59635. getClassName(): string;
  59636. /**
  59637. * Animate the input if animationType !== None
  59638. * @param scene defines the rendering scene
  59639. */
  59640. animate(scene: Scene): void;
  59641. private _emitDefine;
  59642. initialize(state: NodeMaterialBuildState): void;
  59643. /**
  59644. * Set the input block to its default value (based on its type)
  59645. */
  59646. setDefaultValue(): void;
  59647. private _emitConstant;
  59648. private _emit;
  59649. /** @hidden */
  59650. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  59651. /** @hidden */
  59652. _transmit(effect: Effect, scene: Scene): void;
  59653. protected _buildBlock(state: NodeMaterialBuildState): void;
  59654. protected _dumpPropertiesCode(): string;
  59655. serialize(): any;
  59656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59657. }
  59658. }
  59659. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  59660. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59661. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59662. import { Nullable } from "babylonjs/types";
  59663. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59664. import { Observable } from "babylonjs/Misc/observable";
  59665. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59666. /**
  59667. * Enum used to define the compatibility state between two connection points
  59668. */
  59669. export enum NodeMaterialConnectionPointCompatibilityStates {
  59670. /** Points are compatibles */
  59671. Compatible = 0,
  59672. /** Points are incompatible because of their types */
  59673. TypeIncompatible = 1,
  59674. /** Points are incompatible because of their targets (vertex vs fragment) */
  59675. TargetIncompatible = 2
  59676. }
  59677. /**
  59678. * Defines the direction of a connection point
  59679. */
  59680. export enum NodeMaterialConnectionPointDirection {
  59681. /** Input */
  59682. Input = 0,
  59683. /** Output */
  59684. Output = 1
  59685. }
  59686. /**
  59687. * Defines a connection point for a block
  59688. */
  59689. export class NodeMaterialConnectionPoint {
  59690. /** @hidden */
  59691. _ownerBlock: NodeMaterialBlock;
  59692. /** @hidden */
  59693. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  59694. private _endpoints;
  59695. private _associatedVariableName;
  59696. private _direction;
  59697. /** @hidden */
  59698. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59699. /** @hidden */
  59700. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59701. private _type;
  59702. /** @hidden */
  59703. _enforceAssociatedVariableName: boolean;
  59704. /** Gets the direction of the point */
  59705. get direction(): NodeMaterialConnectionPointDirection;
  59706. /**
  59707. * Gets or sets the additional types supported by this connection point
  59708. */
  59709. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59710. /**
  59711. * Gets or sets the additional types excluded by this connection point
  59712. */
  59713. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59714. /**
  59715. * Observable triggered when this point is connected
  59716. */
  59717. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  59718. /**
  59719. * Gets or sets the associated variable name in the shader
  59720. */
  59721. get associatedVariableName(): string;
  59722. set associatedVariableName(value: string);
  59723. /**
  59724. * Gets or sets the connection point type (default is float)
  59725. */
  59726. get type(): NodeMaterialBlockConnectionPointTypes;
  59727. set type(value: NodeMaterialBlockConnectionPointTypes);
  59728. /**
  59729. * Gets or sets the connection point name
  59730. */
  59731. name: string;
  59732. /**
  59733. * Gets or sets a boolean indicating that this connection point can be omitted
  59734. */
  59735. isOptional: boolean;
  59736. /**
  59737. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  59738. */
  59739. define: string;
  59740. /** @hidden */
  59741. _prioritizeVertex: boolean;
  59742. private _target;
  59743. /** Gets or sets the target of that connection point */
  59744. get target(): NodeMaterialBlockTargets;
  59745. set target(value: NodeMaterialBlockTargets);
  59746. /**
  59747. * Gets a boolean indicating that the current point is connected
  59748. */
  59749. get isConnected(): boolean;
  59750. /**
  59751. * Gets a boolean indicating that the current point is connected to an input block
  59752. */
  59753. get isConnectedToInputBlock(): boolean;
  59754. /**
  59755. * Gets a the connected input block (if any)
  59756. */
  59757. get connectInputBlock(): Nullable<InputBlock>;
  59758. /** Get the other side of the connection (if any) */
  59759. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  59760. /** Get the block that owns this connection point */
  59761. get ownerBlock(): NodeMaterialBlock;
  59762. /** Get the block connected on the other side of this connection (if any) */
  59763. get sourceBlock(): Nullable<NodeMaterialBlock>;
  59764. /** Get the block connected on the endpoints of this connection (if any) */
  59765. get connectedBlocks(): Array<NodeMaterialBlock>;
  59766. /** Gets the list of connected endpoints */
  59767. get endpoints(): NodeMaterialConnectionPoint[];
  59768. /** Gets a boolean indicating if that output point is connected to at least one input */
  59769. get hasEndpoints(): boolean;
  59770. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  59771. get isConnectedInVertexShader(): boolean;
  59772. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  59773. get isConnectedInFragmentShader(): boolean;
  59774. /**
  59775. * Creates a new connection point
  59776. * @param name defines the connection point name
  59777. * @param ownerBlock defines the block hosting this connection point
  59778. * @param direction defines the direction of the connection point
  59779. */
  59780. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  59781. /**
  59782. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59783. * @returns the class name
  59784. */
  59785. getClassName(): string;
  59786. /**
  59787. * Gets a boolean indicating if the current point can be connected to another point
  59788. * @param connectionPoint defines the other connection point
  59789. * @returns a boolean
  59790. */
  59791. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  59792. /**
  59793. * Gets a number indicating if the current point can be connected to another point
  59794. * @param connectionPoint defines the other connection point
  59795. * @returns a number defining the compatibility state
  59796. */
  59797. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  59798. /**
  59799. * Connect this point to another connection point
  59800. * @param connectionPoint defines the other connection point
  59801. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  59802. * @returns the current connection point
  59803. */
  59804. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  59805. /**
  59806. * Disconnect this point from one of his endpoint
  59807. * @param endpoint defines the other connection point
  59808. * @returns the current connection point
  59809. */
  59810. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  59811. /**
  59812. * Serializes this point in a JSON representation
  59813. * @returns the serialized point object
  59814. */
  59815. serialize(): any;
  59816. /**
  59817. * Release resources
  59818. */
  59819. dispose(): void;
  59820. }
  59821. }
  59822. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  59823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59824. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59826. import { Mesh } from "babylonjs/Meshes/mesh";
  59827. import { Effect } from "babylonjs/Materials/effect";
  59828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59829. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59830. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59831. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59832. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59833. /**
  59834. * Block used to add support for vertex skinning (bones)
  59835. */
  59836. export class BonesBlock extends NodeMaterialBlock {
  59837. /**
  59838. * Creates a new BonesBlock
  59839. * @param name defines the block name
  59840. */
  59841. constructor(name: string);
  59842. /**
  59843. * Initialize the block and prepare the context for build
  59844. * @param state defines the state that will be used for the build
  59845. */
  59846. initialize(state: NodeMaterialBuildState): void;
  59847. /**
  59848. * Gets the current class name
  59849. * @returns the class name
  59850. */
  59851. getClassName(): string;
  59852. /**
  59853. * Gets the matrix indices input component
  59854. */
  59855. get matricesIndices(): NodeMaterialConnectionPoint;
  59856. /**
  59857. * Gets the matrix weights input component
  59858. */
  59859. get matricesWeights(): NodeMaterialConnectionPoint;
  59860. /**
  59861. * Gets the extra matrix indices input component
  59862. */
  59863. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59864. /**
  59865. * Gets the extra matrix weights input component
  59866. */
  59867. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59868. /**
  59869. * Gets the world input component
  59870. */
  59871. get world(): NodeMaterialConnectionPoint;
  59872. /**
  59873. * Gets the output component
  59874. */
  59875. get output(): NodeMaterialConnectionPoint;
  59876. autoConfigure(material: NodeMaterial): void;
  59877. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59878. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59879. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59880. protected _buildBlock(state: NodeMaterialBuildState): this;
  59881. }
  59882. }
  59883. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  59884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59885. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59888. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59889. /**
  59890. * Block used to add support for instances
  59891. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59892. */
  59893. export class InstancesBlock extends NodeMaterialBlock {
  59894. /**
  59895. * Creates a new InstancesBlock
  59896. * @param name defines the block name
  59897. */
  59898. constructor(name: string);
  59899. /**
  59900. * Gets the current class name
  59901. * @returns the class name
  59902. */
  59903. getClassName(): string;
  59904. /**
  59905. * Gets the first world row input component
  59906. */
  59907. get world0(): NodeMaterialConnectionPoint;
  59908. /**
  59909. * Gets the second world row input component
  59910. */
  59911. get world1(): NodeMaterialConnectionPoint;
  59912. /**
  59913. * Gets the third world row input component
  59914. */
  59915. get world2(): NodeMaterialConnectionPoint;
  59916. /**
  59917. * Gets the forth world row input component
  59918. */
  59919. get world3(): NodeMaterialConnectionPoint;
  59920. /**
  59921. * Gets the world input component
  59922. */
  59923. get world(): NodeMaterialConnectionPoint;
  59924. /**
  59925. * Gets the output component
  59926. */
  59927. get output(): NodeMaterialConnectionPoint;
  59928. autoConfigure(material: NodeMaterial): void;
  59929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59930. protected _buildBlock(state: NodeMaterialBuildState): this;
  59931. }
  59932. }
  59933. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  59934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59938. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59939. import { Effect } from "babylonjs/Materials/effect";
  59940. import { Mesh } from "babylonjs/Meshes/mesh";
  59941. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59943. /**
  59944. * Block used to add morph targets support to vertex shader
  59945. */
  59946. export class MorphTargetsBlock extends NodeMaterialBlock {
  59947. private _repeatableContentAnchor;
  59948. private _repeatebleContentGenerated;
  59949. /**
  59950. * Create a new MorphTargetsBlock
  59951. * @param name defines the block name
  59952. */
  59953. constructor(name: string);
  59954. /**
  59955. * Gets the current class name
  59956. * @returns the class name
  59957. */
  59958. getClassName(): string;
  59959. /**
  59960. * Gets the position input component
  59961. */
  59962. get position(): NodeMaterialConnectionPoint;
  59963. /**
  59964. * Gets the normal input component
  59965. */
  59966. get normal(): NodeMaterialConnectionPoint;
  59967. /**
  59968. * Gets the tangent input component
  59969. */
  59970. get tangent(): NodeMaterialConnectionPoint;
  59971. /**
  59972. * Gets the tangent input component
  59973. */
  59974. get uv(): NodeMaterialConnectionPoint;
  59975. /**
  59976. * Gets the position output component
  59977. */
  59978. get positionOutput(): NodeMaterialConnectionPoint;
  59979. /**
  59980. * Gets the normal output component
  59981. */
  59982. get normalOutput(): NodeMaterialConnectionPoint;
  59983. /**
  59984. * Gets the tangent output component
  59985. */
  59986. get tangentOutput(): NodeMaterialConnectionPoint;
  59987. /**
  59988. * Gets the tangent output component
  59989. */
  59990. get uvOutput(): NodeMaterialConnectionPoint;
  59991. initialize(state: NodeMaterialBuildState): void;
  59992. autoConfigure(material: NodeMaterial): void;
  59993. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59994. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59995. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59996. protected _buildBlock(state: NodeMaterialBuildState): this;
  59997. }
  59998. }
  59999. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  60000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60003. import { Nullable } from "babylonjs/types";
  60004. import { Scene } from "babylonjs/scene";
  60005. import { Effect } from "babylonjs/Materials/effect";
  60006. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60007. import { Mesh } from "babylonjs/Meshes/mesh";
  60008. import { Light } from "babylonjs/Lights/light";
  60009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60010. /**
  60011. * Block used to get data information from a light
  60012. */
  60013. export class LightInformationBlock extends NodeMaterialBlock {
  60014. private _lightDataUniformName;
  60015. private _lightColorUniformName;
  60016. private _lightTypeDefineName;
  60017. /**
  60018. * Gets or sets the light associated with this block
  60019. */
  60020. light: Nullable<Light>;
  60021. /**
  60022. * Creates a new LightInformationBlock
  60023. * @param name defines the block name
  60024. */
  60025. constructor(name: string);
  60026. /**
  60027. * Gets the current class name
  60028. * @returns the class name
  60029. */
  60030. getClassName(): string;
  60031. /**
  60032. * Gets the world position input component
  60033. */
  60034. get worldPosition(): NodeMaterialConnectionPoint;
  60035. /**
  60036. * Gets the direction output component
  60037. */
  60038. get direction(): NodeMaterialConnectionPoint;
  60039. /**
  60040. * Gets the direction output component
  60041. */
  60042. get color(): NodeMaterialConnectionPoint;
  60043. /**
  60044. * Gets the direction output component
  60045. */
  60046. get intensity(): NodeMaterialConnectionPoint;
  60047. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60048. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60049. protected _buildBlock(state: NodeMaterialBuildState): this;
  60050. serialize(): any;
  60051. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60052. }
  60053. }
  60054. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  60055. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  60056. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  60057. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  60058. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  60059. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  60060. }
  60061. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  60062. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60063. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60064. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60066. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60067. import { Effect } from "babylonjs/Materials/effect";
  60068. import { Mesh } from "babylonjs/Meshes/mesh";
  60069. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60070. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60071. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60072. /**
  60073. * Block used to add image processing support to fragment shader
  60074. */
  60075. export class ImageProcessingBlock extends NodeMaterialBlock {
  60076. /**
  60077. * Create a new ImageProcessingBlock
  60078. * @param name defines the block name
  60079. */
  60080. constructor(name: string);
  60081. /**
  60082. * Gets the current class name
  60083. * @returns the class name
  60084. */
  60085. getClassName(): string;
  60086. /**
  60087. * Gets the color input component
  60088. */
  60089. get color(): NodeMaterialConnectionPoint;
  60090. /**
  60091. * Gets the output component
  60092. */
  60093. get output(): NodeMaterialConnectionPoint;
  60094. /**
  60095. * Initialize the block and prepare the context for build
  60096. * @param state defines the state that will be used for the build
  60097. */
  60098. initialize(state: NodeMaterialBuildState): void;
  60099. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60100. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60102. protected _buildBlock(state: NodeMaterialBuildState): this;
  60103. }
  60104. }
  60105. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  60106. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60107. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60109. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60111. import { Effect } from "babylonjs/Materials/effect";
  60112. import { Mesh } from "babylonjs/Meshes/mesh";
  60113. import { Scene } from "babylonjs/scene";
  60114. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  60115. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  60116. /**
  60117. * Block used to pertub normals based on a normal map
  60118. */
  60119. export class PerturbNormalBlock extends NodeMaterialBlock {
  60120. private _tangentSpaceParameterName;
  60121. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60122. invertX: boolean;
  60123. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60124. invertY: boolean;
  60125. /**
  60126. * Create a new PerturbNormalBlock
  60127. * @param name defines the block name
  60128. */
  60129. constructor(name: string);
  60130. /**
  60131. * Gets the current class name
  60132. * @returns the class name
  60133. */
  60134. getClassName(): string;
  60135. /**
  60136. * Gets the world position input component
  60137. */
  60138. get worldPosition(): NodeMaterialConnectionPoint;
  60139. /**
  60140. * Gets the world normal input component
  60141. */
  60142. get worldNormal(): NodeMaterialConnectionPoint;
  60143. /**
  60144. * Gets the uv input component
  60145. */
  60146. get uv(): NodeMaterialConnectionPoint;
  60147. /**
  60148. * Gets the normal map color input component
  60149. */
  60150. get normalMapColor(): NodeMaterialConnectionPoint;
  60151. /**
  60152. * Gets the strength input component
  60153. */
  60154. get strength(): NodeMaterialConnectionPoint;
  60155. /**
  60156. * Gets the output component
  60157. */
  60158. get output(): NodeMaterialConnectionPoint;
  60159. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60160. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60161. autoConfigure(material: NodeMaterial): void;
  60162. protected _buildBlock(state: NodeMaterialBuildState): this;
  60163. protected _dumpPropertiesCode(): string;
  60164. serialize(): any;
  60165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60166. }
  60167. }
  60168. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  60169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60171. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60172. /**
  60173. * Block used to discard a pixel if a value is smaller than a cutoff
  60174. */
  60175. export class DiscardBlock extends NodeMaterialBlock {
  60176. /**
  60177. * Create a new DiscardBlock
  60178. * @param name defines the block name
  60179. */
  60180. constructor(name: string);
  60181. /**
  60182. * Gets the current class name
  60183. * @returns the class name
  60184. */
  60185. getClassName(): string;
  60186. /**
  60187. * Gets the color input component
  60188. */
  60189. get value(): NodeMaterialConnectionPoint;
  60190. /**
  60191. * Gets the cutoff input component
  60192. */
  60193. get cutoff(): NodeMaterialConnectionPoint;
  60194. protected _buildBlock(state: NodeMaterialBuildState): this;
  60195. }
  60196. }
  60197. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  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 test if the fragment shader is front facing
  60203. */
  60204. export class FrontFacingBlock extends NodeMaterialBlock {
  60205. /**
  60206. * Creates a new FrontFacingBlock
  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 output component
  60217. */
  60218. get output(): NodeMaterialConnectionPoint;
  60219. protected _buildBlock(state: NodeMaterialBuildState): this;
  60220. }
  60221. }
  60222. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  60223. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60224. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60225. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60226. /**
  60227. * Block used to get the derivative value on x and y of a given input
  60228. */
  60229. export class DerivativeBlock extends NodeMaterialBlock {
  60230. /**
  60231. * Create a new DerivativeBlock
  60232. * @param name defines the block name
  60233. */
  60234. constructor(name: string);
  60235. /**
  60236. * Gets the current class name
  60237. * @returns the class name
  60238. */
  60239. getClassName(): string;
  60240. /**
  60241. * Gets the input component
  60242. */
  60243. get input(): NodeMaterialConnectionPoint;
  60244. /**
  60245. * Gets the derivative output on x
  60246. */
  60247. get dx(): NodeMaterialConnectionPoint;
  60248. /**
  60249. * Gets the derivative output on y
  60250. */
  60251. get dy(): NodeMaterialConnectionPoint;
  60252. protected _buildBlock(state: NodeMaterialBuildState): this;
  60253. }
  60254. }
  60255. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  60256. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  60257. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  60258. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  60259. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  60260. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  60261. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  60262. }
  60263. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  60264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60266. import { Mesh } from "babylonjs/Meshes/mesh";
  60267. import { Effect } from "babylonjs/Materials/effect";
  60268. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60270. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60271. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60272. /**
  60273. * Block used to add support for scene fog
  60274. */
  60275. export class FogBlock extends NodeMaterialBlock {
  60276. private _fogDistanceName;
  60277. private _fogParameters;
  60278. /**
  60279. * Create a new FogBlock
  60280. * @param name defines the block name
  60281. */
  60282. constructor(name: string);
  60283. /**
  60284. * Gets the current class name
  60285. * @returns the class name
  60286. */
  60287. getClassName(): string;
  60288. /**
  60289. * Gets the world position input component
  60290. */
  60291. get worldPosition(): NodeMaterialConnectionPoint;
  60292. /**
  60293. * Gets the view input component
  60294. */
  60295. get view(): NodeMaterialConnectionPoint;
  60296. /**
  60297. * Gets the color input component
  60298. */
  60299. get input(): NodeMaterialConnectionPoint;
  60300. /**
  60301. * Gets the fog color input component
  60302. */
  60303. get fogColor(): NodeMaterialConnectionPoint;
  60304. /**
  60305. * Gets the output component
  60306. */
  60307. get output(): NodeMaterialConnectionPoint;
  60308. autoConfigure(material: NodeMaterial): void;
  60309. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60310. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60311. protected _buildBlock(state: NodeMaterialBuildState): this;
  60312. }
  60313. }
  60314. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  60315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60319. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60320. import { Effect } from "babylonjs/Materials/effect";
  60321. import { Mesh } from "babylonjs/Meshes/mesh";
  60322. import { Light } from "babylonjs/Lights/light";
  60323. import { Nullable } from "babylonjs/types";
  60324. import { Scene } from "babylonjs/scene";
  60325. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60326. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60327. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60328. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60329. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60330. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60331. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60332. /**
  60333. * Block used to add light in the fragment shader
  60334. */
  60335. export class LightBlock extends NodeMaterialBlock {
  60336. private _lightId;
  60337. /**
  60338. * Gets or sets the light associated with this block
  60339. */
  60340. light: Nullable<Light>;
  60341. /**
  60342. * Create a new LightBlock
  60343. * @param name defines the block name
  60344. */
  60345. constructor(name: string);
  60346. /**
  60347. * Gets the current class name
  60348. * @returns the class name
  60349. */
  60350. getClassName(): string;
  60351. /**
  60352. * Gets the world position input component
  60353. */
  60354. get worldPosition(): NodeMaterialConnectionPoint;
  60355. /**
  60356. * Gets the world normal input component
  60357. */
  60358. get worldNormal(): NodeMaterialConnectionPoint;
  60359. /**
  60360. * Gets the camera (or eye) position component
  60361. */
  60362. get cameraPosition(): NodeMaterialConnectionPoint;
  60363. /**
  60364. * Gets the glossiness component
  60365. */
  60366. get glossiness(): NodeMaterialConnectionPoint;
  60367. /**
  60368. * Gets the glossinness power component
  60369. */
  60370. get glossPower(): NodeMaterialConnectionPoint;
  60371. /**
  60372. * Gets the diffuse color component
  60373. */
  60374. get diffuseColor(): NodeMaterialConnectionPoint;
  60375. /**
  60376. * Gets the specular color component
  60377. */
  60378. get specularColor(): NodeMaterialConnectionPoint;
  60379. /**
  60380. * Gets the diffuse output component
  60381. */
  60382. get diffuseOutput(): NodeMaterialConnectionPoint;
  60383. /**
  60384. * Gets the specular output component
  60385. */
  60386. get specularOutput(): NodeMaterialConnectionPoint;
  60387. /**
  60388. * Gets the shadow output component
  60389. */
  60390. get shadow(): NodeMaterialConnectionPoint;
  60391. autoConfigure(material: NodeMaterial): void;
  60392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60393. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60394. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60395. private _injectVertexCode;
  60396. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60397. serialize(): any;
  60398. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60399. }
  60400. }
  60401. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  60402. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  60403. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  60404. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60405. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60406. }
  60407. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  60408. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60409. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60410. }
  60411. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  60412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60415. /**
  60416. * Block used to multiply 2 values
  60417. */
  60418. export class MultiplyBlock extends NodeMaterialBlock {
  60419. /**
  60420. * Creates a new MultiplyBlock
  60421. * @param name defines the block name
  60422. */
  60423. constructor(name: string);
  60424. /**
  60425. * Gets the current class name
  60426. * @returns the class name
  60427. */
  60428. getClassName(): string;
  60429. /**
  60430. * Gets the left operand input component
  60431. */
  60432. get left(): NodeMaterialConnectionPoint;
  60433. /**
  60434. * Gets the right operand input component
  60435. */
  60436. get right(): NodeMaterialConnectionPoint;
  60437. /**
  60438. * Gets the output component
  60439. */
  60440. get output(): NodeMaterialConnectionPoint;
  60441. protected _buildBlock(state: NodeMaterialBuildState): this;
  60442. }
  60443. }
  60444. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  60445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60448. /**
  60449. * Block used to add 2 vectors
  60450. */
  60451. export class AddBlock extends NodeMaterialBlock {
  60452. /**
  60453. * Creates a new AddBlock
  60454. * @param name defines the block name
  60455. */
  60456. constructor(name: string);
  60457. /**
  60458. * Gets the current class name
  60459. * @returns the class name
  60460. */
  60461. getClassName(): string;
  60462. /**
  60463. * Gets the left operand input component
  60464. */
  60465. get left(): NodeMaterialConnectionPoint;
  60466. /**
  60467. * Gets the right operand input component
  60468. */
  60469. get right(): NodeMaterialConnectionPoint;
  60470. /**
  60471. * Gets the output component
  60472. */
  60473. get output(): NodeMaterialConnectionPoint;
  60474. protected _buildBlock(state: NodeMaterialBuildState): this;
  60475. }
  60476. }
  60477. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  60478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60480. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60481. /**
  60482. * Block used to scale a vector by a float
  60483. */
  60484. export class ScaleBlock extends NodeMaterialBlock {
  60485. /**
  60486. * Creates a new ScaleBlock
  60487. * @param name defines the block name
  60488. */
  60489. constructor(name: string);
  60490. /**
  60491. * Gets the current class name
  60492. * @returns the class name
  60493. */
  60494. getClassName(): string;
  60495. /**
  60496. * Gets the input component
  60497. */
  60498. get input(): NodeMaterialConnectionPoint;
  60499. /**
  60500. * Gets the factor input component
  60501. */
  60502. get factor(): NodeMaterialConnectionPoint;
  60503. /**
  60504. * Gets the output component
  60505. */
  60506. get output(): NodeMaterialConnectionPoint;
  60507. protected _buildBlock(state: NodeMaterialBuildState): this;
  60508. }
  60509. }
  60510. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  60511. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60512. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60513. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60514. import { Scene } from "babylonjs/scene";
  60515. /**
  60516. * Block used to clamp a float
  60517. */
  60518. export class ClampBlock extends NodeMaterialBlock {
  60519. /** Gets or sets the minimum range */
  60520. minimum: number;
  60521. /** Gets or sets the maximum range */
  60522. maximum: number;
  60523. /**
  60524. * Creates a new ClampBlock
  60525. * @param name defines the block name
  60526. */
  60527. constructor(name: string);
  60528. /**
  60529. * Gets the current class name
  60530. * @returns the class name
  60531. */
  60532. getClassName(): string;
  60533. /**
  60534. * Gets the value input component
  60535. */
  60536. get value(): NodeMaterialConnectionPoint;
  60537. /**
  60538. * Gets the output component
  60539. */
  60540. get output(): NodeMaterialConnectionPoint;
  60541. protected _buildBlock(state: NodeMaterialBuildState): this;
  60542. protected _dumpPropertiesCode(): string;
  60543. serialize(): any;
  60544. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60545. }
  60546. }
  60547. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  60548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60551. /**
  60552. * Block used to apply a cross product between 2 vectors
  60553. */
  60554. export class CrossBlock extends NodeMaterialBlock {
  60555. /**
  60556. * Creates a new CrossBlock
  60557. * @param name defines the block name
  60558. */
  60559. constructor(name: string);
  60560. /**
  60561. * Gets the current class name
  60562. * @returns the class name
  60563. */
  60564. getClassName(): string;
  60565. /**
  60566. * Gets the left operand input component
  60567. */
  60568. get left(): NodeMaterialConnectionPoint;
  60569. /**
  60570. * Gets the right operand input component
  60571. */
  60572. get right(): NodeMaterialConnectionPoint;
  60573. /**
  60574. * Gets the output component
  60575. */
  60576. get output(): NodeMaterialConnectionPoint;
  60577. protected _buildBlock(state: NodeMaterialBuildState): this;
  60578. }
  60579. }
  60580. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  60581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60584. /**
  60585. * Block used to apply a dot product between 2 vectors
  60586. */
  60587. export class DotBlock extends NodeMaterialBlock {
  60588. /**
  60589. * Creates a new DotBlock
  60590. * @param name defines the block name
  60591. */
  60592. constructor(name: string);
  60593. /**
  60594. * Gets the current class name
  60595. * @returns the class name
  60596. */
  60597. getClassName(): string;
  60598. /**
  60599. * Gets the left operand input component
  60600. */
  60601. get left(): NodeMaterialConnectionPoint;
  60602. /**
  60603. * Gets the right operand input component
  60604. */
  60605. get right(): NodeMaterialConnectionPoint;
  60606. /**
  60607. * Gets the output component
  60608. */
  60609. get output(): NodeMaterialConnectionPoint;
  60610. protected _buildBlock(state: NodeMaterialBuildState): this;
  60611. }
  60612. }
  60613. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  60614. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60615. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60616. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60617. import { Vector2 } from "babylonjs/Maths/math.vector";
  60618. import { Scene } from "babylonjs/scene";
  60619. /**
  60620. * Block used to remap a float from a range to a new one
  60621. */
  60622. export class RemapBlock extends NodeMaterialBlock {
  60623. /**
  60624. * Gets or sets the source range
  60625. */
  60626. sourceRange: Vector2;
  60627. /**
  60628. * Gets or sets the target range
  60629. */
  60630. targetRange: Vector2;
  60631. /**
  60632. * Creates a new RemapBlock
  60633. * @param name defines the block name
  60634. */
  60635. constructor(name: string);
  60636. /**
  60637. * Gets the current class name
  60638. * @returns the class name
  60639. */
  60640. getClassName(): string;
  60641. /**
  60642. * Gets the input component
  60643. */
  60644. get input(): NodeMaterialConnectionPoint;
  60645. /**
  60646. * Gets the source min input component
  60647. */
  60648. get sourceMin(): NodeMaterialConnectionPoint;
  60649. /**
  60650. * Gets the source max input component
  60651. */
  60652. get sourceMax(): NodeMaterialConnectionPoint;
  60653. /**
  60654. * Gets the target min input component
  60655. */
  60656. get targetMin(): NodeMaterialConnectionPoint;
  60657. /**
  60658. * Gets the target max input component
  60659. */
  60660. get targetMax(): NodeMaterialConnectionPoint;
  60661. /**
  60662. * Gets the output component
  60663. */
  60664. get output(): NodeMaterialConnectionPoint;
  60665. protected _buildBlock(state: NodeMaterialBuildState): this;
  60666. protected _dumpPropertiesCode(): string;
  60667. serialize(): any;
  60668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60669. }
  60670. }
  60671. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  60672. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60673. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60674. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60675. /**
  60676. * Block used to normalize a vector
  60677. */
  60678. export class NormalizeBlock extends NodeMaterialBlock {
  60679. /**
  60680. * Creates a new NormalizeBlock
  60681. * @param name defines the block name
  60682. */
  60683. constructor(name: string);
  60684. /**
  60685. * Gets the current class name
  60686. * @returns the class name
  60687. */
  60688. getClassName(): string;
  60689. /**
  60690. * Gets the input component
  60691. */
  60692. get input(): NodeMaterialConnectionPoint;
  60693. /**
  60694. * Gets the output component
  60695. */
  60696. get output(): NodeMaterialConnectionPoint;
  60697. protected _buildBlock(state: NodeMaterialBuildState): this;
  60698. }
  60699. }
  60700. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  60701. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60702. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60703. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60704. import { Scene } from "babylonjs/scene";
  60705. /**
  60706. * Operations supported by the Trigonometry block
  60707. */
  60708. export enum TrigonometryBlockOperations {
  60709. /** Cos */
  60710. Cos = 0,
  60711. /** Sin */
  60712. Sin = 1,
  60713. /** Abs */
  60714. Abs = 2,
  60715. /** Exp */
  60716. Exp = 3,
  60717. /** Exp2 */
  60718. Exp2 = 4,
  60719. /** Round */
  60720. Round = 5,
  60721. /** Floor */
  60722. Floor = 6,
  60723. /** Ceiling */
  60724. Ceiling = 7,
  60725. /** Square root */
  60726. Sqrt = 8,
  60727. /** Log */
  60728. Log = 9,
  60729. /** Tangent */
  60730. Tan = 10,
  60731. /** Arc tangent */
  60732. ArcTan = 11,
  60733. /** Arc cosinus */
  60734. ArcCos = 12,
  60735. /** Arc sinus */
  60736. ArcSin = 13,
  60737. /** Fraction */
  60738. Fract = 14,
  60739. /** Sign */
  60740. Sign = 15,
  60741. /** To radians (from degrees) */
  60742. Radians = 16,
  60743. /** To degrees (from radians) */
  60744. Degrees = 17
  60745. }
  60746. /**
  60747. * Block used to apply trigonometry operation to floats
  60748. */
  60749. export class TrigonometryBlock extends NodeMaterialBlock {
  60750. /**
  60751. * Gets or sets the operation applied by the block
  60752. */
  60753. operation: TrigonometryBlockOperations;
  60754. /**
  60755. * Creates a new TrigonometryBlock
  60756. * @param name defines the block name
  60757. */
  60758. constructor(name: string);
  60759. /**
  60760. * Gets the current class name
  60761. * @returns the class name
  60762. */
  60763. getClassName(): string;
  60764. /**
  60765. * Gets the input component
  60766. */
  60767. get input(): NodeMaterialConnectionPoint;
  60768. /**
  60769. * Gets the output component
  60770. */
  60771. get output(): NodeMaterialConnectionPoint;
  60772. protected _buildBlock(state: NodeMaterialBuildState): this;
  60773. serialize(): any;
  60774. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60775. protected _dumpPropertiesCode(): string;
  60776. }
  60777. }
  60778. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  60779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60782. /**
  60783. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60784. */
  60785. export class ColorMergerBlock extends NodeMaterialBlock {
  60786. /**
  60787. * Create a new ColorMergerBlock
  60788. * @param name defines the block name
  60789. */
  60790. constructor(name: string);
  60791. /**
  60792. * Gets the current class name
  60793. * @returns the class name
  60794. */
  60795. getClassName(): string;
  60796. /**
  60797. * Gets the rgb component (input)
  60798. */
  60799. get rgbIn(): NodeMaterialConnectionPoint;
  60800. /**
  60801. * Gets the r component (input)
  60802. */
  60803. get r(): NodeMaterialConnectionPoint;
  60804. /**
  60805. * Gets the g component (input)
  60806. */
  60807. get g(): NodeMaterialConnectionPoint;
  60808. /**
  60809. * Gets the b component (input)
  60810. */
  60811. get b(): NodeMaterialConnectionPoint;
  60812. /**
  60813. * Gets the a component (input)
  60814. */
  60815. get a(): NodeMaterialConnectionPoint;
  60816. /**
  60817. * Gets the rgba component (output)
  60818. */
  60819. get rgba(): NodeMaterialConnectionPoint;
  60820. /**
  60821. * Gets the rgb component (output)
  60822. */
  60823. get rgbOut(): NodeMaterialConnectionPoint;
  60824. /**
  60825. * Gets the rgb component (output)
  60826. * @deprecated Please use rgbOut instead.
  60827. */
  60828. get rgb(): NodeMaterialConnectionPoint;
  60829. protected _buildBlock(state: NodeMaterialBuildState): this;
  60830. }
  60831. }
  60832. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60836. /**
  60837. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60838. */
  60839. export class VectorMergerBlock extends NodeMaterialBlock {
  60840. /**
  60841. * Create a new VectorMergerBlock
  60842. * @param name defines the block name
  60843. */
  60844. constructor(name: string);
  60845. /**
  60846. * Gets the current class name
  60847. * @returns the class name
  60848. */
  60849. getClassName(): string;
  60850. /**
  60851. * Gets the xyz component (input)
  60852. */
  60853. get xyzIn(): NodeMaterialConnectionPoint;
  60854. /**
  60855. * Gets the xy component (input)
  60856. */
  60857. get xyIn(): NodeMaterialConnectionPoint;
  60858. /**
  60859. * Gets the x component (input)
  60860. */
  60861. get x(): NodeMaterialConnectionPoint;
  60862. /**
  60863. * Gets the y component (input)
  60864. */
  60865. get y(): NodeMaterialConnectionPoint;
  60866. /**
  60867. * Gets the z component (input)
  60868. */
  60869. get z(): NodeMaterialConnectionPoint;
  60870. /**
  60871. * Gets the w component (input)
  60872. */
  60873. get w(): NodeMaterialConnectionPoint;
  60874. /**
  60875. * Gets the xyzw component (output)
  60876. */
  60877. get xyzw(): NodeMaterialConnectionPoint;
  60878. /**
  60879. * Gets the xyz component (output)
  60880. */
  60881. get xyzOut(): NodeMaterialConnectionPoint;
  60882. /**
  60883. * Gets the xy component (output)
  60884. */
  60885. get xyOut(): NodeMaterialConnectionPoint;
  60886. /**
  60887. * Gets the xy component (output)
  60888. * @deprecated Please use xyOut instead.
  60889. */
  60890. get xy(): NodeMaterialConnectionPoint;
  60891. /**
  60892. * Gets the xyz component (output)
  60893. * @deprecated Please use xyzOut instead.
  60894. */
  60895. get xyz(): NodeMaterialConnectionPoint;
  60896. protected _buildBlock(state: NodeMaterialBuildState): this;
  60897. }
  60898. }
  60899. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  60900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60903. /**
  60904. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60905. */
  60906. export class ColorSplitterBlock extends NodeMaterialBlock {
  60907. /**
  60908. * Create a new ColorSplitterBlock
  60909. * @param name defines the block name
  60910. */
  60911. constructor(name: string);
  60912. /**
  60913. * Gets the current class name
  60914. * @returns the class name
  60915. */
  60916. getClassName(): string;
  60917. /**
  60918. * Gets the rgba component (input)
  60919. */
  60920. get rgba(): NodeMaterialConnectionPoint;
  60921. /**
  60922. * Gets the rgb component (input)
  60923. */
  60924. get rgbIn(): NodeMaterialConnectionPoint;
  60925. /**
  60926. * Gets the rgb component (output)
  60927. */
  60928. get rgbOut(): NodeMaterialConnectionPoint;
  60929. /**
  60930. * Gets the r component (output)
  60931. */
  60932. get r(): NodeMaterialConnectionPoint;
  60933. /**
  60934. * Gets the g component (output)
  60935. */
  60936. get g(): NodeMaterialConnectionPoint;
  60937. /**
  60938. * Gets the b component (output)
  60939. */
  60940. get b(): NodeMaterialConnectionPoint;
  60941. /**
  60942. * Gets the a component (output)
  60943. */
  60944. get a(): NodeMaterialConnectionPoint;
  60945. protected _inputRename(name: string): string;
  60946. protected _outputRename(name: string): string;
  60947. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60948. }
  60949. }
  60950. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  60951. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60953. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60954. /**
  60955. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60956. */
  60957. export class VectorSplitterBlock extends NodeMaterialBlock {
  60958. /**
  60959. * Create a new VectorSplitterBlock
  60960. * @param name defines the block name
  60961. */
  60962. constructor(name: string);
  60963. /**
  60964. * Gets the current class name
  60965. * @returns the class name
  60966. */
  60967. getClassName(): string;
  60968. /**
  60969. * Gets the xyzw component (input)
  60970. */
  60971. get xyzw(): NodeMaterialConnectionPoint;
  60972. /**
  60973. * Gets the xyz component (input)
  60974. */
  60975. get xyzIn(): NodeMaterialConnectionPoint;
  60976. /**
  60977. * Gets the xy component (input)
  60978. */
  60979. get xyIn(): NodeMaterialConnectionPoint;
  60980. /**
  60981. * Gets the xyz component (output)
  60982. */
  60983. get xyzOut(): NodeMaterialConnectionPoint;
  60984. /**
  60985. * Gets the xy component (output)
  60986. */
  60987. get xyOut(): NodeMaterialConnectionPoint;
  60988. /**
  60989. * Gets the x component (output)
  60990. */
  60991. get x(): NodeMaterialConnectionPoint;
  60992. /**
  60993. * Gets the y component (output)
  60994. */
  60995. get y(): NodeMaterialConnectionPoint;
  60996. /**
  60997. * Gets the z component (output)
  60998. */
  60999. get z(): NodeMaterialConnectionPoint;
  61000. /**
  61001. * Gets the w component (output)
  61002. */
  61003. get w(): NodeMaterialConnectionPoint;
  61004. protected _inputRename(name: string): string;
  61005. protected _outputRename(name: string): string;
  61006. protected _buildBlock(state: NodeMaterialBuildState): this;
  61007. }
  61008. }
  61009. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  61010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61011. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61013. /**
  61014. * Block used to lerp between 2 values
  61015. */
  61016. export class LerpBlock extends NodeMaterialBlock {
  61017. /**
  61018. * Creates a new LerpBlock
  61019. * @param name defines the block name
  61020. */
  61021. constructor(name: string);
  61022. /**
  61023. * Gets the current class name
  61024. * @returns the class name
  61025. */
  61026. getClassName(): string;
  61027. /**
  61028. * Gets the left operand input component
  61029. */
  61030. get left(): NodeMaterialConnectionPoint;
  61031. /**
  61032. * Gets the right operand input component
  61033. */
  61034. get right(): NodeMaterialConnectionPoint;
  61035. /**
  61036. * Gets the gradient operand input component
  61037. */
  61038. get gradient(): NodeMaterialConnectionPoint;
  61039. /**
  61040. * Gets the output component
  61041. */
  61042. get output(): NodeMaterialConnectionPoint;
  61043. protected _buildBlock(state: NodeMaterialBuildState): this;
  61044. }
  61045. }
  61046. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  61047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61050. /**
  61051. * Block used to divide 2 vectors
  61052. */
  61053. export class DivideBlock extends NodeMaterialBlock {
  61054. /**
  61055. * Creates a new DivideBlock
  61056. * @param name defines the block name
  61057. */
  61058. constructor(name: string);
  61059. /**
  61060. * Gets the current class name
  61061. * @returns the class name
  61062. */
  61063. getClassName(): string;
  61064. /**
  61065. * Gets the left operand input component
  61066. */
  61067. get left(): NodeMaterialConnectionPoint;
  61068. /**
  61069. * Gets the right operand input component
  61070. */
  61071. get right(): NodeMaterialConnectionPoint;
  61072. /**
  61073. * Gets the output component
  61074. */
  61075. get output(): NodeMaterialConnectionPoint;
  61076. protected _buildBlock(state: NodeMaterialBuildState): this;
  61077. }
  61078. }
  61079. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  61080. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61081. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61082. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61083. /**
  61084. * Block used to subtract 2 vectors
  61085. */
  61086. export class SubtractBlock extends NodeMaterialBlock {
  61087. /**
  61088. * Creates a new SubtractBlock
  61089. * @param name defines the block name
  61090. */
  61091. constructor(name: string);
  61092. /**
  61093. * Gets the current class name
  61094. * @returns the class name
  61095. */
  61096. getClassName(): string;
  61097. /**
  61098. * Gets the left operand input component
  61099. */
  61100. get left(): NodeMaterialConnectionPoint;
  61101. /**
  61102. * Gets the right operand input component
  61103. */
  61104. get right(): NodeMaterialConnectionPoint;
  61105. /**
  61106. * Gets the output component
  61107. */
  61108. get output(): NodeMaterialConnectionPoint;
  61109. protected _buildBlock(state: NodeMaterialBuildState): this;
  61110. }
  61111. }
  61112. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  61113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61116. /**
  61117. * Block used to step a value
  61118. */
  61119. export class StepBlock extends NodeMaterialBlock {
  61120. /**
  61121. * Creates a new StepBlock
  61122. * @param name defines the block name
  61123. */
  61124. constructor(name: string);
  61125. /**
  61126. * Gets the current class name
  61127. * @returns the class name
  61128. */
  61129. getClassName(): string;
  61130. /**
  61131. * Gets the value operand input component
  61132. */
  61133. get value(): NodeMaterialConnectionPoint;
  61134. /**
  61135. * Gets the edge operand input component
  61136. */
  61137. get edge(): NodeMaterialConnectionPoint;
  61138. /**
  61139. * Gets the output component
  61140. */
  61141. get output(): NodeMaterialConnectionPoint;
  61142. protected _buildBlock(state: NodeMaterialBuildState): this;
  61143. }
  61144. }
  61145. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  61146. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61147. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61148. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61149. /**
  61150. * Block used to get the opposite (1 - x) of a value
  61151. */
  61152. export class OneMinusBlock extends NodeMaterialBlock {
  61153. /**
  61154. * Creates a new OneMinusBlock
  61155. * @param name defines the block name
  61156. */
  61157. constructor(name: string);
  61158. /**
  61159. * Gets the current class name
  61160. * @returns the class name
  61161. */
  61162. getClassName(): string;
  61163. /**
  61164. * Gets the input component
  61165. */
  61166. get input(): NodeMaterialConnectionPoint;
  61167. /**
  61168. * Gets the output component
  61169. */
  61170. get output(): NodeMaterialConnectionPoint;
  61171. protected _buildBlock(state: NodeMaterialBuildState): this;
  61172. }
  61173. }
  61174. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  61175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61178. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61179. /**
  61180. * Block used to get the view direction
  61181. */
  61182. export class ViewDirectionBlock extends NodeMaterialBlock {
  61183. /**
  61184. * Creates a new ViewDirectionBlock
  61185. * @param name defines the block name
  61186. */
  61187. constructor(name: string);
  61188. /**
  61189. * Gets the current class name
  61190. * @returns the class name
  61191. */
  61192. getClassName(): string;
  61193. /**
  61194. * Gets the world position component
  61195. */
  61196. get worldPosition(): NodeMaterialConnectionPoint;
  61197. /**
  61198. * Gets the camera position component
  61199. */
  61200. get cameraPosition(): NodeMaterialConnectionPoint;
  61201. /**
  61202. * Gets the output component
  61203. */
  61204. get output(): NodeMaterialConnectionPoint;
  61205. autoConfigure(material: NodeMaterial): void;
  61206. protected _buildBlock(state: NodeMaterialBuildState): this;
  61207. }
  61208. }
  61209. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  61210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61213. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61214. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  61215. /**
  61216. * Block used to compute fresnel value
  61217. */
  61218. export class FresnelBlock extends NodeMaterialBlock {
  61219. /**
  61220. * Create a new FresnelBlock
  61221. * @param name defines the block name
  61222. */
  61223. constructor(name: string);
  61224. /**
  61225. * Gets the current class name
  61226. * @returns the class name
  61227. */
  61228. getClassName(): string;
  61229. /**
  61230. * Gets the world normal input component
  61231. */
  61232. get worldNormal(): NodeMaterialConnectionPoint;
  61233. /**
  61234. * Gets the view direction input component
  61235. */
  61236. get viewDirection(): NodeMaterialConnectionPoint;
  61237. /**
  61238. * Gets the bias input component
  61239. */
  61240. get bias(): NodeMaterialConnectionPoint;
  61241. /**
  61242. * Gets the camera (or eye) position component
  61243. */
  61244. get power(): NodeMaterialConnectionPoint;
  61245. /**
  61246. * Gets the fresnel output component
  61247. */
  61248. get fresnel(): NodeMaterialConnectionPoint;
  61249. autoConfigure(material: NodeMaterial): void;
  61250. protected _buildBlock(state: NodeMaterialBuildState): this;
  61251. }
  61252. }
  61253. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  61254. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61255. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61256. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61257. /**
  61258. * Block used to get the max of 2 values
  61259. */
  61260. export class MaxBlock extends NodeMaterialBlock {
  61261. /**
  61262. * Creates a new MaxBlock
  61263. * @param name defines the block name
  61264. */
  61265. constructor(name: string);
  61266. /**
  61267. * Gets the current class name
  61268. * @returns the class name
  61269. */
  61270. getClassName(): string;
  61271. /**
  61272. * Gets the left operand input component
  61273. */
  61274. get left(): NodeMaterialConnectionPoint;
  61275. /**
  61276. * Gets the right operand input component
  61277. */
  61278. get right(): NodeMaterialConnectionPoint;
  61279. /**
  61280. * Gets the output component
  61281. */
  61282. get output(): NodeMaterialConnectionPoint;
  61283. protected _buildBlock(state: NodeMaterialBuildState): this;
  61284. }
  61285. }
  61286. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  61287. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61288. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61289. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61290. /**
  61291. * Block used to get the min of 2 values
  61292. */
  61293. export class MinBlock extends NodeMaterialBlock {
  61294. /**
  61295. * Creates a new MinBlock
  61296. * @param name defines the block name
  61297. */
  61298. constructor(name: string);
  61299. /**
  61300. * Gets the current class name
  61301. * @returns the class name
  61302. */
  61303. getClassName(): string;
  61304. /**
  61305. * Gets the left operand input component
  61306. */
  61307. get left(): NodeMaterialConnectionPoint;
  61308. /**
  61309. * Gets the right operand input component
  61310. */
  61311. get right(): NodeMaterialConnectionPoint;
  61312. /**
  61313. * Gets the output component
  61314. */
  61315. get output(): NodeMaterialConnectionPoint;
  61316. protected _buildBlock(state: NodeMaterialBuildState): this;
  61317. }
  61318. }
  61319. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  61320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61323. /**
  61324. * Block used to get the distance between 2 values
  61325. */
  61326. export class DistanceBlock extends NodeMaterialBlock {
  61327. /**
  61328. * Creates a new DistanceBlock
  61329. * @param name defines the block name
  61330. */
  61331. constructor(name: string);
  61332. /**
  61333. * Gets the current class name
  61334. * @returns the class name
  61335. */
  61336. getClassName(): string;
  61337. /**
  61338. * Gets the left operand input component
  61339. */
  61340. get left(): NodeMaterialConnectionPoint;
  61341. /**
  61342. * Gets the right operand input component
  61343. */
  61344. get right(): NodeMaterialConnectionPoint;
  61345. /**
  61346. * Gets the output component
  61347. */
  61348. get output(): NodeMaterialConnectionPoint;
  61349. protected _buildBlock(state: NodeMaterialBuildState): this;
  61350. }
  61351. }
  61352. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  61353. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61354. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61355. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61356. /**
  61357. * Block used to get the length of a vector
  61358. */
  61359. export class LengthBlock extends NodeMaterialBlock {
  61360. /**
  61361. * Creates a new LengthBlock
  61362. * @param name defines the block name
  61363. */
  61364. constructor(name: string);
  61365. /**
  61366. * Gets the current class name
  61367. * @returns the class name
  61368. */
  61369. getClassName(): string;
  61370. /**
  61371. * Gets the value input component
  61372. */
  61373. get value(): NodeMaterialConnectionPoint;
  61374. /**
  61375. * Gets the output component
  61376. */
  61377. get output(): NodeMaterialConnectionPoint;
  61378. protected _buildBlock(state: NodeMaterialBuildState): this;
  61379. }
  61380. }
  61381. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  61382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61385. /**
  61386. * Block used to get negative version of a value (i.e. x * -1)
  61387. */
  61388. export class NegateBlock extends NodeMaterialBlock {
  61389. /**
  61390. * Creates a new NegateBlock
  61391. * @param name defines the block name
  61392. */
  61393. constructor(name: string);
  61394. /**
  61395. * Gets the current class name
  61396. * @returns the class name
  61397. */
  61398. getClassName(): string;
  61399. /**
  61400. * Gets the value input component
  61401. */
  61402. get value(): NodeMaterialConnectionPoint;
  61403. /**
  61404. * Gets the output component
  61405. */
  61406. get output(): NodeMaterialConnectionPoint;
  61407. protected _buildBlock(state: NodeMaterialBuildState): this;
  61408. }
  61409. }
  61410. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  61411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61414. /**
  61415. * Block used to get the value of the first parameter raised to the power of the second
  61416. */
  61417. export class PowBlock extends NodeMaterialBlock {
  61418. /**
  61419. * Creates a new PowBlock
  61420. * @param name defines the block name
  61421. */
  61422. constructor(name: string);
  61423. /**
  61424. * Gets the current class name
  61425. * @returns the class name
  61426. */
  61427. getClassName(): string;
  61428. /**
  61429. * Gets the value operand input component
  61430. */
  61431. get value(): NodeMaterialConnectionPoint;
  61432. /**
  61433. * Gets the power operand input component
  61434. */
  61435. get power(): NodeMaterialConnectionPoint;
  61436. /**
  61437. * Gets the output component
  61438. */
  61439. get output(): NodeMaterialConnectionPoint;
  61440. protected _buildBlock(state: NodeMaterialBuildState): this;
  61441. }
  61442. }
  61443. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  61444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61447. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61448. /**
  61449. * Block used to get a random number
  61450. */
  61451. export class RandomNumberBlock extends NodeMaterialBlock {
  61452. /**
  61453. * Creates a new RandomNumberBlock
  61454. * @param name defines the block name
  61455. */
  61456. constructor(name: string);
  61457. /**
  61458. * Gets the current class name
  61459. * @returns the class name
  61460. */
  61461. getClassName(): string;
  61462. /**
  61463. * Gets the seed input component
  61464. */
  61465. get seed(): NodeMaterialConnectionPoint;
  61466. /**
  61467. * Gets the output component
  61468. */
  61469. get output(): NodeMaterialConnectionPoint;
  61470. protected _buildBlock(state: NodeMaterialBuildState): this;
  61471. }
  61472. }
  61473. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  61474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61477. /**
  61478. * Block used to compute arc tangent of 2 values
  61479. */
  61480. export class ArcTan2Block extends NodeMaterialBlock {
  61481. /**
  61482. * Creates a new ArcTan2Block
  61483. * @param name defines the block name
  61484. */
  61485. constructor(name: string);
  61486. /**
  61487. * Gets the current class name
  61488. * @returns the class name
  61489. */
  61490. getClassName(): string;
  61491. /**
  61492. * Gets the x operand input component
  61493. */
  61494. get x(): NodeMaterialConnectionPoint;
  61495. /**
  61496. * Gets the y operand input component
  61497. */
  61498. get y(): NodeMaterialConnectionPoint;
  61499. /**
  61500. * Gets the output component
  61501. */
  61502. get output(): NodeMaterialConnectionPoint;
  61503. protected _buildBlock(state: NodeMaterialBuildState): this;
  61504. }
  61505. }
  61506. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  61507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61510. /**
  61511. * Block used to smooth step a value
  61512. */
  61513. export class SmoothStepBlock extends NodeMaterialBlock {
  61514. /**
  61515. * Creates a new SmoothStepBlock
  61516. * @param name defines the block name
  61517. */
  61518. constructor(name: string);
  61519. /**
  61520. * Gets the current class name
  61521. * @returns the class name
  61522. */
  61523. getClassName(): string;
  61524. /**
  61525. * Gets the value operand input component
  61526. */
  61527. get value(): NodeMaterialConnectionPoint;
  61528. /**
  61529. * Gets the first edge operand input component
  61530. */
  61531. get edge0(): NodeMaterialConnectionPoint;
  61532. /**
  61533. * Gets the second edge operand input component
  61534. */
  61535. get edge1(): NodeMaterialConnectionPoint;
  61536. /**
  61537. * Gets the output component
  61538. */
  61539. get output(): NodeMaterialConnectionPoint;
  61540. protected _buildBlock(state: NodeMaterialBuildState): this;
  61541. }
  61542. }
  61543. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  61544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61545. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61546. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61547. /**
  61548. * Block used to get the reciprocal (1 / x) of a value
  61549. */
  61550. export class ReciprocalBlock extends NodeMaterialBlock {
  61551. /**
  61552. * Creates a new ReciprocalBlock
  61553. * @param name defines the block name
  61554. */
  61555. constructor(name: string);
  61556. /**
  61557. * Gets the current class name
  61558. * @returns the class name
  61559. */
  61560. getClassName(): string;
  61561. /**
  61562. * Gets the input component
  61563. */
  61564. get input(): NodeMaterialConnectionPoint;
  61565. /**
  61566. * Gets the output component
  61567. */
  61568. get output(): NodeMaterialConnectionPoint;
  61569. protected _buildBlock(state: NodeMaterialBuildState): this;
  61570. }
  61571. }
  61572. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  61573. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61574. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61575. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61576. /**
  61577. * Block used to replace a color by another one
  61578. */
  61579. export class ReplaceColorBlock extends NodeMaterialBlock {
  61580. /**
  61581. * Creates a new ReplaceColorBlock
  61582. * @param name defines the block name
  61583. */
  61584. constructor(name: string);
  61585. /**
  61586. * Gets the current class name
  61587. * @returns the class name
  61588. */
  61589. getClassName(): string;
  61590. /**
  61591. * Gets the value input component
  61592. */
  61593. get value(): NodeMaterialConnectionPoint;
  61594. /**
  61595. * Gets the reference input component
  61596. */
  61597. get reference(): NodeMaterialConnectionPoint;
  61598. /**
  61599. * Gets the distance input component
  61600. */
  61601. get distance(): NodeMaterialConnectionPoint;
  61602. /**
  61603. * Gets the replacement input component
  61604. */
  61605. get replacement(): NodeMaterialConnectionPoint;
  61606. /**
  61607. * Gets the output component
  61608. */
  61609. get output(): NodeMaterialConnectionPoint;
  61610. protected _buildBlock(state: NodeMaterialBuildState): this;
  61611. }
  61612. }
  61613. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  61614. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61615. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61616. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61617. /**
  61618. * Block used to posterize a value
  61619. * @see https://en.wikipedia.org/wiki/Posterization
  61620. */
  61621. export class PosterizeBlock extends NodeMaterialBlock {
  61622. /**
  61623. * Creates a new PosterizeBlock
  61624. * @param name defines the block name
  61625. */
  61626. constructor(name: string);
  61627. /**
  61628. * Gets the current class name
  61629. * @returns the class name
  61630. */
  61631. getClassName(): string;
  61632. /**
  61633. * Gets the value input component
  61634. */
  61635. get value(): NodeMaterialConnectionPoint;
  61636. /**
  61637. * Gets the steps input component
  61638. */
  61639. get steps(): NodeMaterialConnectionPoint;
  61640. /**
  61641. * Gets the output component
  61642. */
  61643. get output(): NodeMaterialConnectionPoint;
  61644. protected _buildBlock(state: NodeMaterialBuildState): this;
  61645. }
  61646. }
  61647. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  61648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61651. import { Scene } from "babylonjs/scene";
  61652. /**
  61653. * Operations supported by the Wave block
  61654. */
  61655. export enum WaveBlockKind {
  61656. /** SawTooth */
  61657. SawTooth = 0,
  61658. /** Square */
  61659. Square = 1,
  61660. /** Triangle */
  61661. Triangle = 2
  61662. }
  61663. /**
  61664. * Block used to apply wave operation to floats
  61665. */
  61666. export class WaveBlock extends NodeMaterialBlock {
  61667. /**
  61668. * Gets or sets the kibnd of wave to be applied by the block
  61669. */
  61670. kind: WaveBlockKind;
  61671. /**
  61672. * Creates a new WaveBlock
  61673. * @param name defines the block name
  61674. */
  61675. constructor(name: string);
  61676. /**
  61677. * Gets the current class name
  61678. * @returns the class name
  61679. */
  61680. getClassName(): string;
  61681. /**
  61682. * Gets the input component
  61683. */
  61684. get input(): NodeMaterialConnectionPoint;
  61685. /**
  61686. * Gets the output component
  61687. */
  61688. get output(): NodeMaterialConnectionPoint;
  61689. protected _buildBlock(state: NodeMaterialBuildState): this;
  61690. serialize(): any;
  61691. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61692. }
  61693. }
  61694. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  61695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61698. import { Color3 } from "babylonjs/Maths/math.color";
  61699. import { Scene } from "babylonjs/scene";
  61700. /**
  61701. * Class used to store a color step for the GradientBlock
  61702. */
  61703. export class GradientBlockColorStep {
  61704. /**
  61705. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61706. */
  61707. step: number;
  61708. /**
  61709. * Gets or sets the color associated with this step
  61710. */
  61711. color: Color3;
  61712. /**
  61713. * Creates a new GradientBlockColorStep
  61714. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  61715. * @param color defines the color associated with this step
  61716. */
  61717. constructor(
  61718. /**
  61719. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61720. */
  61721. step: number,
  61722. /**
  61723. * Gets or sets the color associated with this step
  61724. */
  61725. color: Color3);
  61726. }
  61727. /**
  61728. * Block used to return a color from a gradient based on an input value between 0 and 1
  61729. */
  61730. export class GradientBlock extends NodeMaterialBlock {
  61731. /**
  61732. * Gets or sets the list of color steps
  61733. */
  61734. colorSteps: GradientBlockColorStep[];
  61735. /**
  61736. * Creates a new GradientBlock
  61737. * @param name defines the block name
  61738. */
  61739. constructor(name: string);
  61740. /**
  61741. * Gets the current class name
  61742. * @returns the class name
  61743. */
  61744. getClassName(): string;
  61745. /**
  61746. * Gets the gradient input component
  61747. */
  61748. get gradient(): NodeMaterialConnectionPoint;
  61749. /**
  61750. * Gets the output component
  61751. */
  61752. get output(): NodeMaterialConnectionPoint;
  61753. private _writeColorConstant;
  61754. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61755. serialize(): any;
  61756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61757. protected _dumpPropertiesCode(): string;
  61758. }
  61759. }
  61760. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  61761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61764. /**
  61765. * Block used to normalize lerp between 2 values
  61766. */
  61767. export class NLerpBlock extends NodeMaterialBlock {
  61768. /**
  61769. * Creates a new NLerpBlock
  61770. * @param name defines the block name
  61771. */
  61772. constructor(name: string);
  61773. /**
  61774. * Gets the current class name
  61775. * @returns the class name
  61776. */
  61777. getClassName(): string;
  61778. /**
  61779. * Gets the left operand input component
  61780. */
  61781. get left(): NodeMaterialConnectionPoint;
  61782. /**
  61783. * Gets the right operand input component
  61784. */
  61785. get right(): NodeMaterialConnectionPoint;
  61786. /**
  61787. * Gets the gradient operand input component
  61788. */
  61789. get gradient(): NodeMaterialConnectionPoint;
  61790. /**
  61791. * Gets the output component
  61792. */
  61793. get output(): NodeMaterialConnectionPoint;
  61794. protected _buildBlock(state: NodeMaterialBuildState): this;
  61795. }
  61796. }
  61797. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  61798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61801. import { Scene } from "babylonjs/scene";
  61802. /**
  61803. * block used to Generate a Worley Noise 3D Noise Pattern
  61804. */
  61805. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61806. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61807. manhattanDistance: boolean;
  61808. /**
  61809. * Creates a new WorleyNoise3DBlock
  61810. * @param name defines the block name
  61811. */
  61812. constructor(name: string);
  61813. /**
  61814. * Gets the current class name
  61815. * @returns the class name
  61816. */
  61817. getClassName(): string;
  61818. /**
  61819. * Gets the seed input component
  61820. */
  61821. get seed(): NodeMaterialConnectionPoint;
  61822. /**
  61823. * Gets the jitter input component
  61824. */
  61825. get jitter(): NodeMaterialConnectionPoint;
  61826. /**
  61827. * Gets the output component
  61828. */
  61829. get output(): NodeMaterialConnectionPoint;
  61830. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61831. /**
  61832. * Exposes the properties to the UI?
  61833. */
  61834. protected _dumpPropertiesCode(): string;
  61835. /**
  61836. * Exposes the properties to the Seralize?
  61837. */
  61838. serialize(): any;
  61839. /**
  61840. * Exposes the properties to the deseralize?
  61841. */
  61842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61843. }
  61844. }
  61845. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  61846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61849. /**
  61850. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61851. */
  61852. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61853. /**
  61854. * Creates a new SimplexPerlin3DBlock
  61855. * @param name defines the block name
  61856. */
  61857. constructor(name: string);
  61858. /**
  61859. * Gets the current class name
  61860. * @returns the class name
  61861. */
  61862. getClassName(): string;
  61863. /**
  61864. * Gets the seed operand input component
  61865. */
  61866. get seed(): NodeMaterialConnectionPoint;
  61867. /**
  61868. * Gets the output component
  61869. */
  61870. get output(): NodeMaterialConnectionPoint;
  61871. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61872. }
  61873. }
  61874. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  61875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61878. /**
  61879. * Block used to blend normals
  61880. */
  61881. export class NormalBlendBlock extends NodeMaterialBlock {
  61882. /**
  61883. * Creates a new NormalBlendBlock
  61884. * @param name defines the block name
  61885. */
  61886. constructor(name: string);
  61887. /**
  61888. * Gets the current class name
  61889. * @returns the class name
  61890. */
  61891. getClassName(): string;
  61892. /**
  61893. * Gets the first input component
  61894. */
  61895. get normalMap0(): NodeMaterialConnectionPoint;
  61896. /**
  61897. * Gets the second input component
  61898. */
  61899. get normalMap1(): NodeMaterialConnectionPoint;
  61900. /**
  61901. * Gets the output component
  61902. */
  61903. get output(): NodeMaterialConnectionPoint;
  61904. protected _buildBlock(state: NodeMaterialBuildState): this;
  61905. }
  61906. }
  61907. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  61908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61910. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61911. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61912. /**
  61913. * Block used to rotate a 2d vector by a given angle
  61914. */
  61915. export class Rotate2dBlock extends NodeMaterialBlock {
  61916. /**
  61917. * Creates a new Rotate2dBlock
  61918. * @param name defines the block name
  61919. */
  61920. constructor(name: string);
  61921. /**
  61922. * Gets the current class name
  61923. * @returns the class name
  61924. */
  61925. getClassName(): string;
  61926. /**
  61927. * Gets the input vector
  61928. */
  61929. get input(): NodeMaterialConnectionPoint;
  61930. /**
  61931. * Gets the input angle
  61932. */
  61933. get angle(): NodeMaterialConnectionPoint;
  61934. /**
  61935. * Gets the output component
  61936. */
  61937. get output(): NodeMaterialConnectionPoint;
  61938. autoConfigure(material: NodeMaterial): void;
  61939. protected _buildBlock(state: NodeMaterialBuildState): this;
  61940. }
  61941. }
  61942. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  61943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61946. /**
  61947. * Block used to get the reflected vector from a direction and a normal
  61948. */
  61949. export class ReflectBlock extends NodeMaterialBlock {
  61950. /**
  61951. * Creates a new ReflectBlock
  61952. * @param name defines the block name
  61953. */
  61954. constructor(name: string);
  61955. /**
  61956. * Gets the current class name
  61957. * @returns the class name
  61958. */
  61959. getClassName(): string;
  61960. /**
  61961. * Gets the incident component
  61962. */
  61963. get incident(): NodeMaterialConnectionPoint;
  61964. /**
  61965. * Gets the normal component
  61966. */
  61967. get normal(): NodeMaterialConnectionPoint;
  61968. /**
  61969. * Gets the output component
  61970. */
  61971. get output(): NodeMaterialConnectionPoint;
  61972. protected _buildBlock(state: NodeMaterialBuildState): this;
  61973. }
  61974. }
  61975. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  61976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61979. /**
  61980. * Block used to get the refracted vector from a direction and a normal
  61981. */
  61982. export class RefractBlock extends NodeMaterialBlock {
  61983. /**
  61984. * Creates a new RefractBlock
  61985. * @param name defines the block name
  61986. */
  61987. constructor(name: string);
  61988. /**
  61989. * Gets the current class name
  61990. * @returns the class name
  61991. */
  61992. getClassName(): string;
  61993. /**
  61994. * Gets the incident component
  61995. */
  61996. get incident(): NodeMaterialConnectionPoint;
  61997. /**
  61998. * Gets the normal component
  61999. */
  62000. get normal(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the index of refraction component
  62003. */
  62004. get ior(): NodeMaterialConnectionPoint;
  62005. /**
  62006. * Gets the output component
  62007. */
  62008. get output(): NodeMaterialConnectionPoint;
  62009. protected _buildBlock(state: NodeMaterialBuildState): this;
  62010. }
  62011. }
  62012. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  62013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62015. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62016. /**
  62017. * Block used to desaturate a color
  62018. */
  62019. export class DesaturateBlock extends NodeMaterialBlock {
  62020. /**
  62021. * Creates a new DesaturateBlock
  62022. * @param name defines the block name
  62023. */
  62024. constructor(name: string);
  62025. /**
  62026. * Gets the current class name
  62027. * @returns the class name
  62028. */
  62029. getClassName(): string;
  62030. /**
  62031. * Gets the color operand input component
  62032. */
  62033. get color(): NodeMaterialConnectionPoint;
  62034. /**
  62035. * Gets the level operand input component
  62036. */
  62037. get level(): NodeMaterialConnectionPoint;
  62038. /**
  62039. * Gets the output component
  62040. */
  62041. get output(): NodeMaterialConnectionPoint;
  62042. protected _buildBlock(state: NodeMaterialBuildState): this;
  62043. }
  62044. }
  62045. declare module "babylonjs/Materials/Node/Blocks/index" {
  62046. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  62047. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  62048. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  62049. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  62050. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  62051. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  62052. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  62053. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  62054. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  62055. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  62056. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  62057. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  62058. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  62059. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  62060. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  62061. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  62062. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  62063. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  62064. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  62065. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  62066. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  62067. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  62068. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  62069. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  62070. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  62071. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  62072. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  62073. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  62074. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  62075. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  62076. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  62077. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  62078. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  62079. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  62080. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  62081. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  62082. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  62083. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  62084. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  62085. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  62086. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  62087. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  62088. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  62089. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  62090. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  62091. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  62092. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  62093. }
  62094. declare module "babylonjs/Materials/Node/Optimizers/index" {
  62095. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  62096. }
  62097. declare module "babylonjs/Materials/Node/index" {
  62098. export * from "babylonjs/Materials/Node/Enums/index";
  62099. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62100. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  62101. export * from "babylonjs/Materials/Node/nodeMaterial";
  62102. export * from "babylonjs/Materials/Node/Blocks/index";
  62103. export * from "babylonjs/Materials/Node/Optimizers/index";
  62104. }
  62105. declare module "babylonjs/Materials/effectRenderer" {
  62106. import { Nullable } from "babylonjs/types";
  62107. import { Texture } from "babylonjs/Materials/Textures/texture";
  62108. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62109. import { Viewport } from "babylonjs/Maths/math.viewport";
  62110. import { Observable } from "babylonjs/Misc/observable";
  62111. import { Effect } from "babylonjs/Materials/effect";
  62112. import "babylonjs/Engines/Extensions/engine.renderTarget";
  62113. import "babylonjs/Shaders/postprocess.vertex";
  62114. /**
  62115. * Effect Render Options
  62116. */
  62117. export interface IEffectRendererOptions {
  62118. /**
  62119. * Defines the vertices positions.
  62120. */
  62121. positions?: number[];
  62122. /**
  62123. * Defines the indices.
  62124. */
  62125. indices?: number[];
  62126. }
  62127. /**
  62128. * Helper class to render one or more effects
  62129. */
  62130. export class EffectRenderer {
  62131. private engine;
  62132. private static _DefaultOptions;
  62133. private _vertexBuffers;
  62134. private _indexBuffer;
  62135. private _ringBufferIndex;
  62136. private _ringScreenBuffer;
  62137. private _fullscreenViewport;
  62138. private _getNextFrameBuffer;
  62139. /**
  62140. * Creates an effect renderer
  62141. * @param engine the engine to use for rendering
  62142. * @param options defines the options of the effect renderer
  62143. */
  62144. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62145. /**
  62146. * Sets the current viewport in normalized coordinates 0-1
  62147. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62148. */
  62149. setViewport(viewport?: Viewport): void;
  62150. /**
  62151. * Binds the embedded attributes buffer to the effect.
  62152. * @param effect Defines the effect to bind the attributes for
  62153. */
  62154. bindBuffers(effect: Effect): void;
  62155. /**
  62156. * Sets the current effect wrapper to use during draw.
  62157. * The effect needs to be ready before calling this api.
  62158. * This also sets the default full screen position attribute.
  62159. * @param effectWrapper Defines the effect to draw with
  62160. */
  62161. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62162. /**
  62163. * Draws a full screen quad.
  62164. */
  62165. draw(): void;
  62166. /**
  62167. * renders one or more effects to a specified texture
  62168. * @param effectWrappers list of effects to renderer
  62169. * @param outputTexture texture to draw to, if null it will render to the screen
  62170. */
  62171. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  62172. /**
  62173. * Disposes of the effect renderer
  62174. */
  62175. dispose(): void;
  62176. }
  62177. /**
  62178. * Options to create an EffectWrapper
  62179. */
  62180. interface EffectWrapperCreationOptions {
  62181. /**
  62182. * Engine to use to create the effect
  62183. */
  62184. engine: ThinEngine;
  62185. /**
  62186. * Fragment shader for the effect
  62187. */
  62188. fragmentShader: string;
  62189. /**
  62190. * Vertex shader for the effect
  62191. */
  62192. vertexShader?: string;
  62193. /**
  62194. * Attributes to use in the shader
  62195. */
  62196. attributeNames?: Array<string>;
  62197. /**
  62198. * Uniforms to use in the shader
  62199. */
  62200. uniformNames?: Array<string>;
  62201. /**
  62202. * Texture sampler names to use in the shader
  62203. */
  62204. samplerNames?: Array<string>;
  62205. /**
  62206. * The friendly name of the effect displayed in Spector.
  62207. */
  62208. name?: string;
  62209. }
  62210. /**
  62211. * Wraps an effect to be used for rendering
  62212. */
  62213. export class EffectWrapper {
  62214. /**
  62215. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62216. */
  62217. onApplyObservable: Observable<{}>;
  62218. /**
  62219. * The underlying effect
  62220. */
  62221. effect: Effect;
  62222. /**
  62223. * Creates an effect to be renderer
  62224. * @param creationOptions options to create the effect
  62225. */
  62226. constructor(creationOptions: EffectWrapperCreationOptions);
  62227. /**
  62228. * Disposes of the effect wrapper
  62229. */
  62230. dispose(): void;
  62231. }
  62232. }
  62233. declare module "babylonjs/Materials/index" {
  62234. export * from "babylonjs/Materials/Background/index";
  62235. export * from "babylonjs/Materials/colorCurves";
  62236. export * from "babylonjs/Materials/iEffectFallbacks";
  62237. export * from "babylonjs/Materials/effectFallbacks";
  62238. export * from "babylonjs/Materials/effect";
  62239. export * from "babylonjs/Materials/fresnelParameters";
  62240. export * from "babylonjs/Materials/imageProcessingConfiguration";
  62241. export * from "babylonjs/Materials/material";
  62242. export * from "babylonjs/Materials/materialDefines";
  62243. export * from "babylonjs/Materials/materialHelper";
  62244. export * from "babylonjs/Materials/multiMaterial";
  62245. export * from "babylonjs/Materials/PBR/index";
  62246. export * from "babylonjs/Materials/pushMaterial";
  62247. export * from "babylonjs/Materials/shaderMaterial";
  62248. export * from "babylonjs/Materials/standardMaterial";
  62249. export * from "babylonjs/Materials/Textures/index";
  62250. export * from "babylonjs/Materials/uniformBuffer";
  62251. export * from "babylonjs/Materials/materialFlags";
  62252. export * from "babylonjs/Materials/Node/index";
  62253. export * from "babylonjs/Materials/effectRenderer";
  62254. }
  62255. declare module "babylonjs/Maths/index" {
  62256. export * from "babylonjs/Maths/math.scalar";
  62257. export * from "babylonjs/Maths/math";
  62258. export * from "babylonjs/Maths/sphericalPolynomial";
  62259. }
  62260. declare module "babylonjs/Misc/workerPool" {
  62261. import { IDisposable } from "babylonjs/scene";
  62262. /**
  62263. * Helper class to push actions to a pool of workers.
  62264. */
  62265. export class WorkerPool implements IDisposable {
  62266. private _workerInfos;
  62267. private _pendingActions;
  62268. /**
  62269. * Constructor
  62270. * @param workers Array of workers to use for actions
  62271. */
  62272. constructor(workers: Array<Worker>);
  62273. /**
  62274. * Terminates all workers and clears any pending actions.
  62275. */
  62276. dispose(): void;
  62277. /**
  62278. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62279. * pended until a worker has completed its action.
  62280. * @param action The action to perform. Call onComplete when the action is complete.
  62281. */
  62282. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62283. private _execute;
  62284. }
  62285. }
  62286. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  62287. import { IDisposable } from "babylonjs/scene";
  62288. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  62289. /**
  62290. * Configuration for Draco compression
  62291. */
  62292. export interface IDracoCompressionConfiguration {
  62293. /**
  62294. * Configuration for the decoder.
  62295. */
  62296. decoder: {
  62297. /**
  62298. * The url to the WebAssembly module.
  62299. */
  62300. wasmUrl?: string;
  62301. /**
  62302. * The url to the WebAssembly binary.
  62303. */
  62304. wasmBinaryUrl?: string;
  62305. /**
  62306. * The url to the fallback JavaScript module.
  62307. */
  62308. fallbackUrl?: string;
  62309. };
  62310. }
  62311. /**
  62312. * Draco compression (https://google.github.io/draco/)
  62313. *
  62314. * This class wraps the Draco module.
  62315. *
  62316. * **Encoder**
  62317. *
  62318. * The encoder is not currently implemented.
  62319. *
  62320. * **Decoder**
  62321. *
  62322. * 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.
  62323. *
  62324. * To update the configuration, use the following code:
  62325. * ```javascript
  62326. * DracoCompression.Configuration = {
  62327. * decoder: {
  62328. * wasmUrl: "<url to the WebAssembly library>",
  62329. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  62330. * fallbackUrl: "<url to the fallback JavaScript library>",
  62331. * }
  62332. * };
  62333. * ```
  62334. *
  62335. * 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.
  62336. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  62337. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  62338. *
  62339. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  62340. * ```javascript
  62341. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  62342. * ```
  62343. *
  62344. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  62345. */
  62346. export class DracoCompression implements IDisposable {
  62347. private _workerPoolPromise?;
  62348. private _decoderModulePromise?;
  62349. /**
  62350. * The configuration. Defaults to the following urls:
  62351. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  62352. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  62353. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  62354. */
  62355. static Configuration: IDracoCompressionConfiguration;
  62356. /**
  62357. * Returns true if the decoder configuration is available.
  62358. */
  62359. static get DecoderAvailable(): boolean;
  62360. /**
  62361. * Default number of workers to create when creating the draco compression object.
  62362. */
  62363. static DefaultNumWorkers: number;
  62364. private static GetDefaultNumWorkers;
  62365. private static _Default;
  62366. /**
  62367. * Default instance for the draco compression object.
  62368. */
  62369. static get Default(): DracoCompression;
  62370. /**
  62371. * Constructor
  62372. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62373. */
  62374. constructor(numWorkers?: number);
  62375. /**
  62376. * Stop all async operations and release resources.
  62377. */
  62378. dispose(): void;
  62379. /**
  62380. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  62381. * @returns a promise that resolves when ready
  62382. */
  62383. whenReadyAsync(): Promise<void>;
  62384. /**
  62385. * Decode Draco compressed mesh data to vertex data.
  62386. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  62387. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  62388. * @returns A promise that resolves with the decoded vertex data
  62389. */
  62390. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  62391. [kind: string]: number;
  62392. }): Promise<VertexData>;
  62393. }
  62394. }
  62395. declare module "babylonjs/Meshes/Compression/index" {
  62396. export * from "babylonjs/Meshes/Compression/dracoCompression";
  62397. }
  62398. declare module "babylonjs/Meshes/csg" {
  62399. import { Nullable } from "babylonjs/types";
  62400. import { Scene } from "babylonjs/scene";
  62401. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62402. import { Mesh } from "babylonjs/Meshes/mesh";
  62403. import { Material } from "babylonjs/Materials/material";
  62404. /**
  62405. * Class for building Constructive Solid Geometry
  62406. */
  62407. export class CSG {
  62408. private polygons;
  62409. /**
  62410. * The world matrix
  62411. */
  62412. matrix: Matrix;
  62413. /**
  62414. * Stores the position
  62415. */
  62416. position: Vector3;
  62417. /**
  62418. * Stores the rotation
  62419. */
  62420. rotation: Vector3;
  62421. /**
  62422. * Stores the rotation quaternion
  62423. */
  62424. rotationQuaternion: Nullable<Quaternion>;
  62425. /**
  62426. * Stores the scaling vector
  62427. */
  62428. scaling: Vector3;
  62429. /**
  62430. * Convert the Mesh to CSG
  62431. * @param mesh The Mesh to convert to CSG
  62432. * @returns A new CSG from the Mesh
  62433. */
  62434. static FromMesh(mesh: Mesh): CSG;
  62435. /**
  62436. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  62437. * @param polygons Polygons used to construct a CSG solid
  62438. */
  62439. private static FromPolygons;
  62440. /**
  62441. * Clones, or makes a deep copy, of the CSG
  62442. * @returns A new CSG
  62443. */
  62444. clone(): CSG;
  62445. /**
  62446. * Unions this CSG with another CSG
  62447. * @param csg The CSG to union against this CSG
  62448. * @returns The unioned CSG
  62449. */
  62450. union(csg: CSG): CSG;
  62451. /**
  62452. * Unions this CSG with another CSG in place
  62453. * @param csg The CSG to union against this CSG
  62454. */
  62455. unionInPlace(csg: CSG): void;
  62456. /**
  62457. * Subtracts this CSG with another CSG
  62458. * @param csg The CSG to subtract against this CSG
  62459. * @returns A new CSG
  62460. */
  62461. subtract(csg: CSG): CSG;
  62462. /**
  62463. * Subtracts this CSG with another CSG in place
  62464. * @param csg The CSG to subtact against this CSG
  62465. */
  62466. subtractInPlace(csg: CSG): void;
  62467. /**
  62468. * Intersect this CSG with another CSG
  62469. * @param csg The CSG to intersect against this CSG
  62470. * @returns A new CSG
  62471. */
  62472. intersect(csg: CSG): CSG;
  62473. /**
  62474. * Intersects this CSG with another CSG in place
  62475. * @param csg The CSG to intersect against this CSG
  62476. */
  62477. intersectInPlace(csg: CSG): void;
  62478. /**
  62479. * Return a new CSG solid with solid and empty space switched. This solid is
  62480. * not modified.
  62481. * @returns A new CSG solid with solid and empty space switched
  62482. */
  62483. inverse(): CSG;
  62484. /**
  62485. * Inverses the CSG in place
  62486. */
  62487. inverseInPlace(): void;
  62488. /**
  62489. * This is used to keep meshes transformations so they can be restored
  62490. * when we build back a Babylon Mesh
  62491. * NB : All CSG operations are performed in world coordinates
  62492. * @param csg The CSG to copy the transform attributes from
  62493. * @returns This CSG
  62494. */
  62495. copyTransformAttributes(csg: CSG): CSG;
  62496. /**
  62497. * Build Raw mesh from CSG
  62498. * Coordinates here are in world space
  62499. * @param name The name of the mesh geometry
  62500. * @param scene The Scene
  62501. * @param keepSubMeshes Specifies if the submeshes should be kept
  62502. * @returns A new Mesh
  62503. */
  62504. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62505. /**
  62506. * Build Mesh from CSG taking material and transforms into account
  62507. * @param name The name of the Mesh
  62508. * @param material The material of the Mesh
  62509. * @param scene The Scene
  62510. * @param keepSubMeshes Specifies if submeshes should be kept
  62511. * @returns The new Mesh
  62512. */
  62513. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62514. }
  62515. }
  62516. declare module "babylonjs/Meshes/trailMesh" {
  62517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62518. import { Mesh } from "babylonjs/Meshes/mesh";
  62519. import { Scene } from "babylonjs/scene";
  62520. /**
  62521. * Class used to create a trail following a mesh
  62522. */
  62523. export class TrailMesh extends Mesh {
  62524. private _generator;
  62525. private _autoStart;
  62526. private _running;
  62527. private _diameter;
  62528. private _length;
  62529. private _sectionPolygonPointsCount;
  62530. private _sectionVectors;
  62531. private _sectionNormalVectors;
  62532. private _beforeRenderObserver;
  62533. /**
  62534. * @constructor
  62535. * @param name The value used by scene.getMeshByName() to do a lookup.
  62536. * @param generator The mesh to generate a trail.
  62537. * @param scene The scene to add this mesh to.
  62538. * @param diameter Diameter of trailing mesh. Default is 1.
  62539. * @param length Length of trailing mesh. Default is 60.
  62540. * @param autoStart Automatically start trailing mesh. Default true.
  62541. */
  62542. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  62543. /**
  62544. * "TrailMesh"
  62545. * @returns "TrailMesh"
  62546. */
  62547. getClassName(): string;
  62548. private _createMesh;
  62549. /**
  62550. * Start trailing mesh.
  62551. */
  62552. start(): void;
  62553. /**
  62554. * Stop trailing mesh.
  62555. */
  62556. stop(): void;
  62557. /**
  62558. * Update trailing mesh geometry.
  62559. */
  62560. update(): void;
  62561. /**
  62562. * Returns a new TrailMesh object.
  62563. * @param name is a string, the name given to the new mesh
  62564. * @param newGenerator use new generator object for cloned trail mesh
  62565. * @returns a new mesh
  62566. */
  62567. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  62568. /**
  62569. * Serializes this trail mesh
  62570. * @param serializationObject object to write serialization to
  62571. */
  62572. serialize(serializationObject: any): void;
  62573. /**
  62574. * Parses a serialized trail mesh
  62575. * @param parsedMesh the serialized mesh
  62576. * @param scene the scene to create the trail mesh in
  62577. * @returns the created trail mesh
  62578. */
  62579. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  62580. }
  62581. }
  62582. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  62583. import { Nullable } from "babylonjs/types";
  62584. import { Scene } from "babylonjs/scene";
  62585. import { Vector4 } from "babylonjs/Maths/math.vector";
  62586. import { Color4 } from "babylonjs/Maths/math.color";
  62587. import { Mesh } from "babylonjs/Meshes/mesh";
  62588. /**
  62589. * Class containing static functions to help procedurally build meshes
  62590. */
  62591. export class TiledBoxBuilder {
  62592. /**
  62593. * Creates a box mesh
  62594. * 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)
  62595. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62599. * @param name defines the name of the mesh
  62600. * @param options defines the options used to create the mesh
  62601. * @param scene defines the hosting scene
  62602. * @returns the box mesh
  62603. */
  62604. static CreateTiledBox(name: string, options: {
  62605. pattern?: number;
  62606. width?: number;
  62607. height?: number;
  62608. depth?: number;
  62609. tileSize?: number;
  62610. tileWidth?: number;
  62611. tileHeight?: number;
  62612. alignHorizontal?: number;
  62613. alignVertical?: number;
  62614. faceUV?: Vector4[];
  62615. faceColors?: Color4[];
  62616. sideOrientation?: number;
  62617. updatable?: boolean;
  62618. }, scene?: Nullable<Scene>): Mesh;
  62619. }
  62620. }
  62621. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  62622. import { Vector4 } from "babylonjs/Maths/math.vector";
  62623. import { Mesh } from "babylonjs/Meshes/mesh";
  62624. /**
  62625. * Class containing static functions to help procedurally build meshes
  62626. */
  62627. export class TorusKnotBuilder {
  62628. /**
  62629. * Creates a torus knot mesh
  62630. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62631. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62632. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62633. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62635. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62637. * @param name defines the name of the mesh
  62638. * @param options defines the options used to create the mesh
  62639. * @param scene defines the hosting scene
  62640. * @returns the torus knot mesh
  62641. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62642. */
  62643. static CreateTorusKnot(name: string, options: {
  62644. radius?: number;
  62645. tube?: number;
  62646. radialSegments?: number;
  62647. tubularSegments?: number;
  62648. p?: number;
  62649. q?: number;
  62650. updatable?: boolean;
  62651. sideOrientation?: number;
  62652. frontUVs?: Vector4;
  62653. backUVs?: Vector4;
  62654. }, scene: any): Mesh;
  62655. }
  62656. }
  62657. declare module "babylonjs/Meshes/polygonMesh" {
  62658. import { Scene } from "babylonjs/scene";
  62659. import { Vector2 } from "babylonjs/Maths/math.vector";
  62660. import { Mesh } from "babylonjs/Meshes/mesh";
  62661. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  62662. import { Path2 } from "babylonjs/Maths/math.path";
  62663. /**
  62664. * Polygon
  62665. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  62666. */
  62667. export class Polygon {
  62668. /**
  62669. * Creates a rectangle
  62670. * @param xmin bottom X coord
  62671. * @param ymin bottom Y coord
  62672. * @param xmax top X coord
  62673. * @param ymax top Y coord
  62674. * @returns points that make the resulting rectation
  62675. */
  62676. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  62677. /**
  62678. * Creates a circle
  62679. * @param radius radius of circle
  62680. * @param cx scale in x
  62681. * @param cy scale in y
  62682. * @param numberOfSides number of sides that make up the circle
  62683. * @returns points that make the resulting circle
  62684. */
  62685. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  62686. /**
  62687. * Creates a polygon from input string
  62688. * @param input Input polygon data
  62689. * @returns the parsed points
  62690. */
  62691. static Parse(input: string): Vector2[];
  62692. /**
  62693. * Starts building a polygon from x and y coordinates
  62694. * @param x x coordinate
  62695. * @param y y coordinate
  62696. * @returns the started path2
  62697. */
  62698. static StartingAt(x: number, y: number): Path2;
  62699. }
  62700. /**
  62701. * Builds a polygon
  62702. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  62703. */
  62704. export class PolygonMeshBuilder {
  62705. private _points;
  62706. private _outlinepoints;
  62707. private _holes;
  62708. private _name;
  62709. private _scene;
  62710. private _epoints;
  62711. private _eholes;
  62712. private _addToepoint;
  62713. /**
  62714. * Babylon reference to the earcut plugin.
  62715. */
  62716. bjsEarcut: any;
  62717. /**
  62718. * Creates a PolygonMeshBuilder
  62719. * @param name name of the builder
  62720. * @param contours Path of the polygon
  62721. * @param scene scene to add to when creating the mesh
  62722. * @param earcutInjection can be used to inject your own earcut reference
  62723. */
  62724. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  62725. /**
  62726. * Adds a whole within the polygon
  62727. * @param hole Array of points defining the hole
  62728. * @returns this
  62729. */
  62730. addHole(hole: Vector2[]): PolygonMeshBuilder;
  62731. /**
  62732. * Creates the polygon
  62733. * @param updatable If the mesh should be updatable
  62734. * @param depth The depth of the mesh created
  62735. * @returns the created mesh
  62736. */
  62737. build(updatable?: boolean, depth?: number): Mesh;
  62738. /**
  62739. * Creates the polygon
  62740. * @param depth The depth of the mesh created
  62741. * @returns the created VertexData
  62742. */
  62743. buildVertexData(depth?: number): VertexData;
  62744. /**
  62745. * Adds a side to the polygon
  62746. * @param positions points that make the polygon
  62747. * @param normals normals of the polygon
  62748. * @param uvs uvs of the polygon
  62749. * @param indices indices of the polygon
  62750. * @param bounds bounds of the polygon
  62751. * @param points points of the polygon
  62752. * @param depth depth of the polygon
  62753. * @param flip flip of the polygon
  62754. */
  62755. private addSide;
  62756. }
  62757. }
  62758. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  62759. import { Scene } from "babylonjs/scene";
  62760. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62761. import { Color4 } from "babylonjs/Maths/math.color";
  62762. import { Mesh } from "babylonjs/Meshes/mesh";
  62763. import { Nullable } from "babylonjs/types";
  62764. /**
  62765. * Class containing static functions to help procedurally build meshes
  62766. */
  62767. export class PolygonBuilder {
  62768. /**
  62769. * Creates a polygon mesh
  62770. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62771. * * 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
  62772. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62775. * * Remember you can only change the shape positions, not their number when updating a polygon
  62776. * @param name defines the name of the mesh
  62777. * @param options defines the options used to create the mesh
  62778. * @param scene defines the hosting scene
  62779. * @param earcutInjection can be used to inject your own earcut reference
  62780. * @returns the polygon mesh
  62781. */
  62782. static CreatePolygon(name: string, options: {
  62783. shape: Vector3[];
  62784. holes?: Vector3[][];
  62785. depth?: number;
  62786. faceUV?: Vector4[];
  62787. faceColors?: Color4[];
  62788. updatable?: boolean;
  62789. sideOrientation?: number;
  62790. frontUVs?: Vector4;
  62791. backUVs?: Vector4;
  62792. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62793. /**
  62794. * Creates an extruded polygon mesh, with depth in the Y direction.
  62795. * * 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)
  62796. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62797. * @param name defines the name of the mesh
  62798. * @param options defines the options used to create the mesh
  62799. * @param scene defines the hosting scene
  62800. * @param earcutInjection can be used to inject your own earcut reference
  62801. * @returns the polygon mesh
  62802. */
  62803. static ExtrudePolygon(name: string, options: {
  62804. shape: Vector3[];
  62805. holes?: Vector3[][];
  62806. depth?: number;
  62807. faceUV?: Vector4[];
  62808. faceColors?: Color4[];
  62809. updatable?: boolean;
  62810. sideOrientation?: number;
  62811. frontUVs?: Vector4;
  62812. backUVs?: Vector4;
  62813. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62814. }
  62815. }
  62816. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  62817. import { Scene } from "babylonjs/scene";
  62818. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62819. import { Mesh } from "babylonjs/Meshes/mesh";
  62820. import { Nullable } from "babylonjs/types";
  62821. /**
  62822. * Class containing static functions to help procedurally build meshes
  62823. */
  62824. export class LatheBuilder {
  62825. /**
  62826. * Creates lathe mesh.
  62827. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62828. * * 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
  62829. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62830. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62831. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62832. * * 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
  62833. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62834. * * 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
  62835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62837. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62839. * @param name defines the name of the mesh
  62840. * @param options defines the options used to create the mesh
  62841. * @param scene defines the hosting scene
  62842. * @returns the lathe mesh
  62843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62844. */
  62845. static CreateLathe(name: string, options: {
  62846. shape: Vector3[];
  62847. radius?: number;
  62848. tessellation?: number;
  62849. clip?: number;
  62850. arc?: number;
  62851. closed?: boolean;
  62852. updatable?: boolean;
  62853. sideOrientation?: number;
  62854. frontUVs?: Vector4;
  62855. backUVs?: Vector4;
  62856. cap?: number;
  62857. invertUV?: boolean;
  62858. }, scene?: Nullable<Scene>): Mesh;
  62859. }
  62860. }
  62861. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  62862. import { Nullable } from "babylonjs/types";
  62863. import { Scene } from "babylonjs/scene";
  62864. import { Vector4 } from "babylonjs/Maths/math.vector";
  62865. import { Mesh } from "babylonjs/Meshes/mesh";
  62866. /**
  62867. * Class containing static functions to help procedurally build meshes
  62868. */
  62869. export class TiledPlaneBuilder {
  62870. /**
  62871. * Creates a tiled plane mesh
  62872. * * The parameter `pattern` will, depending on value, do nothing or
  62873. * * * flip (reflect about central vertical) alternate tiles across and up
  62874. * * * flip every tile on alternate rows
  62875. * * * rotate (180 degs) alternate tiles across and up
  62876. * * * rotate every tile on alternate rows
  62877. * * * flip and rotate alternate tiles across and up
  62878. * * * flip and rotate every tile on alternate rows
  62879. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62880. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62882. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62883. * * 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)
  62884. * * 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)
  62885. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62886. * @param name defines the name of the mesh
  62887. * @param options defines the options used to create the mesh
  62888. * @param scene defines the hosting scene
  62889. * @returns the box mesh
  62890. */
  62891. static CreateTiledPlane(name: string, options: {
  62892. pattern?: number;
  62893. tileSize?: number;
  62894. tileWidth?: number;
  62895. tileHeight?: number;
  62896. size?: number;
  62897. width?: number;
  62898. height?: number;
  62899. alignHorizontal?: number;
  62900. alignVertical?: number;
  62901. sideOrientation?: number;
  62902. frontUVs?: Vector4;
  62903. backUVs?: Vector4;
  62904. updatable?: boolean;
  62905. }, scene?: Nullable<Scene>): Mesh;
  62906. }
  62907. }
  62908. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  62909. import { Nullable } from "babylonjs/types";
  62910. import { Scene } from "babylonjs/scene";
  62911. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62912. import { Mesh } from "babylonjs/Meshes/mesh";
  62913. /**
  62914. * Class containing static functions to help procedurally build meshes
  62915. */
  62916. export class TubeBuilder {
  62917. /**
  62918. * Creates a tube mesh.
  62919. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62920. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62921. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62922. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62923. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62924. * * 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)
  62925. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62926. * * 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
  62927. * * 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
  62928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62930. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62932. * @param name defines the name of the mesh
  62933. * @param options defines the options used to create the mesh
  62934. * @param scene defines the hosting scene
  62935. * @returns the tube mesh
  62936. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62937. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62938. */
  62939. static CreateTube(name: string, options: {
  62940. path: Vector3[];
  62941. radius?: number;
  62942. tessellation?: number;
  62943. radiusFunction?: {
  62944. (i: number, distance: number): number;
  62945. };
  62946. cap?: number;
  62947. arc?: number;
  62948. updatable?: boolean;
  62949. sideOrientation?: number;
  62950. frontUVs?: Vector4;
  62951. backUVs?: Vector4;
  62952. instance?: Mesh;
  62953. invertUV?: boolean;
  62954. }, scene?: Nullable<Scene>): Mesh;
  62955. }
  62956. }
  62957. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  62958. import { Scene } from "babylonjs/scene";
  62959. import { Vector4 } from "babylonjs/Maths/math.vector";
  62960. import { Mesh } from "babylonjs/Meshes/mesh";
  62961. import { Nullable } from "babylonjs/types";
  62962. /**
  62963. * Class containing static functions to help procedurally build meshes
  62964. */
  62965. export class IcoSphereBuilder {
  62966. /**
  62967. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62968. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62969. * * 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`)
  62970. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62971. * * 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
  62972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62975. * @param name defines the name of the mesh
  62976. * @param options defines the options used to create the mesh
  62977. * @param scene defines the hosting scene
  62978. * @returns the icosahedron mesh
  62979. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62980. */
  62981. static CreateIcoSphere(name: string, options: {
  62982. radius?: number;
  62983. radiusX?: number;
  62984. radiusY?: number;
  62985. radiusZ?: number;
  62986. flat?: boolean;
  62987. subdivisions?: number;
  62988. sideOrientation?: number;
  62989. frontUVs?: Vector4;
  62990. backUVs?: Vector4;
  62991. updatable?: boolean;
  62992. }, scene?: Nullable<Scene>): Mesh;
  62993. }
  62994. }
  62995. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  62996. import { Vector3 } from "babylonjs/Maths/math.vector";
  62997. import { Mesh } from "babylonjs/Meshes/mesh";
  62998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62999. /**
  63000. * Class containing static functions to help procedurally build meshes
  63001. */
  63002. export class DecalBuilder {
  63003. /**
  63004. * Creates a decal mesh.
  63005. * 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
  63006. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63007. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63008. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63009. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63010. * @param name defines the name of the mesh
  63011. * @param sourceMesh defines the mesh where the decal must be applied
  63012. * @param options defines the options used to create the mesh
  63013. * @param scene defines the hosting scene
  63014. * @returns the decal mesh
  63015. * @see https://doc.babylonjs.com/how_to/decals
  63016. */
  63017. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63018. position?: Vector3;
  63019. normal?: Vector3;
  63020. size?: Vector3;
  63021. angle?: number;
  63022. }): Mesh;
  63023. }
  63024. }
  63025. declare module "babylonjs/Meshes/meshBuilder" {
  63026. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  63027. import { Nullable } from "babylonjs/types";
  63028. import { Scene } from "babylonjs/scene";
  63029. import { Mesh } from "babylonjs/Meshes/mesh";
  63030. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  63031. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  63032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63033. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63034. import { Plane } from "babylonjs/Maths/math.plane";
  63035. /**
  63036. * Class containing static functions to help procedurally build meshes
  63037. */
  63038. export class MeshBuilder {
  63039. /**
  63040. * Creates a box mesh
  63041. * * The parameter `size` sets the size (float) of each box side (default 1)
  63042. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63043. * * 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)
  63044. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63048. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63049. * @param name defines the name of the mesh
  63050. * @param options defines the options used to create the mesh
  63051. * @param scene defines the hosting scene
  63052. * @returns the box mesh
  63053. */
  63054. static CreateBox(name: string, options: {
  63055. size?: number;
  63056. width?: number;
  63057. height?: number;
  63058. depth?: number;
  63059. faceUV?: Vector4[];
  63060. faceColors?: Color4[];
  63061. sideOrientation?: number;
  63062. frontUVs?: Vector4;
  63063. backUVs?: Vector4;
  63064. updatable?: boolean;
  63065. }, scene?: Nullable<Scene>): Mesh;
  63066. /**
  63067. * Creates a tiled box mesh
  63068. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63070. * @param name defines the name of the mesh
  63071. * @param options defines the options used to create the mesh
  63072. * @param scene defines the hosting scene
  63073. * @returns the tiled box mesh
  63074. */
  63075. static CreateTiledBox(name: string, options: {
  63076. pattern?: number;
  63077. size?: number;
  63078. width?: number;
  63079. height?: number;
  63080. depth: number;
  63081. tileSize?: number;
  63082. tileWidth?: number;
  63083. tileHeight?: number;
  63084. faceUV?: Vector4[];
  63085. faceColors?: Color4[];
  63086. alignHorizontal?: number;
  63087. alignVertical?: number;
  63088. sideOrientation?: number;
  63089. updatable?: boolean;
  63090. }, scene?: Nullable<Scene>): Mesh;
  63091. /**
  63092. * Creates a sphere mesh
  63093. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63094. * * 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`)
  63095. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63096. * * 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
  63097. * * 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)
  63098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63101. * @param name defines the name of the mesh
  63102. * @param options defines the options used to create the mesh
  63103. * @param scene defines the hosting scene
  63104. * @returns the sphere mesh
  63105. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63106. */
  63107. static CreateSphere(name: string, options: {
  63108. segments?: number;
  63109. diameter?: number;
  63110. diameterX?: number;
  63111. diameterY?: number;
  63112. diameterZ?: number;
  63113. arc?: number;
  63114. slice?: number;
  63115. sideOrientation?: number;
  63116. frontUVs?: Vector4;
  63117. backUVs?: Vector4;
  63118. updatable?: boolean;
  63119. }, scene?: Nullable<Scene>): Mesh;
  63120. /**
  63121. * Creates a plane polygonal mesh. By default, this is a disc
  63122. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63123. * * 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
  63124. * * 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
  63125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63128. * @param name defines the name of the mesh
  63129. * @param options defines the options used to create the mesh
  63130. * @param scene defines the hosting scene
  63131. * @returns the plane polygonal mesh
  63132. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63133. */
  63134. static CreateDisc(name: string, options: {
  63135. radius?: number;
  63136. tessellation?: number;
  63137. arc?: number;
  63138. updatable?: boolean;
  63139. sideOrientation?: number;
  63140. frontUVs?: Vector4;
  63141. backUVs?: Vector4;
  63142. }, scene?: Nullable<Scene>): Mesh;
  63143. /**
  63144. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63145. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63146. * * 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`)
  63147. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63148. * * 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
  63149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63152. * @param name defines the name of the mesh
  63153. * @param options defines the options used to create the mesh
  63154. * @param scene defines the hosting scene
  63155. * @returns the icosahedron mesh
  63156. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63157. */
  63158. static CreateIcoSphere(name: string, options: {
  63159. radius?: number;
  63160. radiusX?: number;
  63161. radiusY?: number;
  63162. radiusZ?: number;
  63163. flat?: boolean;
  63164. subdivisions?: number;
  63165. sideOrientation?: number;
  63166. frontUVs?: Vector4;
  63167. backUVs?: Vector4;
  63168. updatable?: boolean;
  63169. }, scene?: Nullable<Scene>): Mesh;
  63170. /**
  63171. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63172. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63173. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63174. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63175. * * 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
  63176. * * 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
  63177. * * 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
  63178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63180. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63181. * * 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
  63182. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63183. * * 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
  63184. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63186. * @param name defines the name of the mesh
  63187. * @param options defines the options used to create the mesh
  63188. * @param scene defines the hosting scene
  63189. * @returns the ribbon mesh
  63190. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  63191. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63192. */
  63193. static CreateRibbon(name: string, options: {
  63194. pathArray: Vector3[][];
  63195. closeArray?: boolean;
  63196. closePath?: boolean;
  63197. offset?: number;
  63198. updatable?: boolean;
  63199. sideOrientation?: number;
  63200. frontUVs?: Vector4;
  63201. backUVs?: Vector4;
  63202. instance?: Mesh;
  63203. invertUV?: boolean;
  63204. uvs?: Vector2[];
  63205. colors?: Color4[];
  63206. }, scene?: Nullable<Scene>): Mesh;
  63207. /**
  63208. * Creates a cylinder or a cone mesh
  63209. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  63210. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  63211. * * 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.
  63212. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  63213. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  63214. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  63215. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  63216. * * 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).
  63217. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  63218. * * 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).
  63219. * * 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
  63220. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  63221. * * 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
  63222. * * 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.
  63223. * * If `enclose` is false, a ring surface is one element.
  63224. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  63225. * * 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
  63226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63229. * @param name defines the name of the mesh
  63230. * @param options defines the options used to create the mesh
  63231. * @param scene defines the hosting scene
  63232. * @returns the cylinder mesh
  63233. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  63234. */
  63235. static CreateCylinder(name: string, options: {
  63236. height?: number;
  63237. diameterTop?: number;
  63238. diameterBottom?: number;
  63239. diameter?: number;
  63240. tessellation?: number;
  63241. subdivisions?: number;
  63242. arc?: number;
  63243. faceColors?: Color4[];
  63244. faceUV?: Vector4[];
  63245. updatable?: boolean;
  63246. hasRings?: boolean;
  63247. enclose?: boolean;
  63248. cap?: number;
  63249. sideOrientation?: number;
  63250. frontUVs?: Vector4;
  63251. backUVs?: Vector4;
  63252. }, scene?: Nullable<Scene>): Mesh;
  63253. /**
  63254. * Creates a torus mesh
  63255. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  63256. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  63257. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  63258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63261. * @param name defines the name of the mesh
  63262. * @param options defines the options used to create the mesh
  63263. * @param scene defines the hosting scene
  63264. * @returns the torus mesh
  63265. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  63266. */
  63267. static CreateTorus(name: string, options: {
  63268. diameter?: number;
  63269. thickness?: number;
  63270. tessellation?: number;
  63271. updatable?: boolean;
  63272. sideOrientation?: number;
  63273. frontUVs?: Vector4;
  63274. backUVs?: Vector4;
  63275. }, scene?: Nullable<Scene>): Mesh;
  63276. /**
  63277. * Creates a torus knot mesh
  63278. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63279. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63280. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63281. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63285. * @param name defines the name of the mesh
  63286. * @param options defines the options used to create the mesh
  63287. * @param scene defines the hosting scene
  63288. * @returns the torus knot mesh
  63289. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63290. */
  63291. static CreateTorusKnot(name: string, options: {
  63292. radius?: number;
  63293. tube?: number;
  63294. radialSegments?: number;
  63295. tubularSegments?: number;
  63296. p?: number;
  63297. q?: number;
  63298. updatable?: boolean;
  63299. sideOrientation?: number;
  63300. frontUVs?: Vector4;
  63301. backUVs?: Vector4;
  63302. }, scene?: Nullable<Scene>): Mesh;
  63303. /**
  63304. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  63305. * * 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
  63306. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  63307. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  63308. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  63309. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  63310. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  63311. * * 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
  63312. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  63313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  63315. * @param name defines the name of the new line system
  63316. * @param options defines the options used to create the line system
  63317. * @param scene defines the hosting scene
  63318. * @returns a new line system mesh
  63319. */
  63320. static CreateLineSystem(name: string, options: {
  63321. lines: Vector3[][];
  63322. updatable?: boolean;
  63323. instance?: Nullable<LinesMesh>;
  63324. colors?: Nullable<Color4[][]>;
  63325. useVertexAlpha?: boolean;
  63326. }, scene: Nullable<Scene>): LinesMesh;
  63327. /**
  63328. * Creates a line mesh
  63329. * 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
  63330. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63331. * * The parameter `points` is an array successive Vector3
  63332. * * 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
  63333. * * The optional parameter `colors` is an array of successive Color4, one per line point
  63334. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  63335. * * When updating an instance, remember that only point positions can change, not the number of points
  63336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  63338. * @param name defines the name of the new line system
  63339. * @param options defines the options used to create the line system
  63340. * @param scene defines the hosting scene
  63341. * @returns a new line mesh
  63342. */
  63343. static CreateLines(name: string, options: {
  63344. points: Vector3[];
  63345. updatable?: boolean;
  63346. instance?: Nullable<LinesMesh>;
  63347. colors?: Color4[];
  63348. useVertexAlpha?: boolean;
  63349. }, scene?: Nullable<Scene>): LinesMesh;
  63350. /**
  63351. * Creates a dashed line mesh
  63352. * * 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
  63353. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63354. * * The parameter `points` is an array successive Vector3
  63355. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  63356. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  63357. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  63358. * * 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
  63359. * * When updating an instance, remember that only point positions can change, not the number of points
  63360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63361. * @param name defines the name of the mesh
  63362. * @param options defines the options used to create the mesh
  63363. * @param scene defines the hosting scene
  63364. * @returns the dashed line mesh
  63365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  63366. */
  63367. static CreateDashedLines(name: string, options: {
  63368. points: Vector3[];
  63369. dashSize?: number;
  63370. gapSize?: number;
  63371. dashNb?: number;
  63372. updatable?: boolean;
  63373. instance?: LinesMesh;
  63374. }, scene?: Nullable<Scene>): LinesMesh;
  63375. /**
  63376. * 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.
  63377. * * 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.
  63378. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63379. * * 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.
  63380. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  63381. * * 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
  63382. * * 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
  63383. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  63384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63386. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  63387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63388. * @param name defines the name of the mesh
  63389. * @param options defines the options used to create the mesh
  63390. * @param scene defines the hosting scene
  63391. * @returns the extruded shape mesh
  63392. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63394. */
  63395. static ExtrudeShape(name: string, options: {
  63396. shape: Vector3[];
  63397. path: Vector3[];
  63398. scale?: number;
  63399. rotation?: number;
  63400. cap?: number;
  63401. updatable?: boolean;
  63402. sideOrientation?: number;
  63403. frontUVs?: Vector4;
  63404. backUVs?: Vector4;
  63405. instance?: Mesh;
  63406. invertUV?: boolean;
  63407. }, scene?: Nullable<Scene>): Mesh;
  63408. /**
  63409. * Creates an custom extruded shape mesh.
  63410. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  63411. * * 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.
  63412. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63413. * * 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
  63414. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  63415. * * 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
  63416. * * It must returns a float value that will be the scale value applied to the shape on each path point
  63417. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  63418. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  63419. * * 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
  63420. * * 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
  63421. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  63422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63424. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63426. * @param name defines the name of the mesh
  63427. * @param options defines the options used to create the mesh
  63428. * @param scene defines the hosting scene
  63429. * @returns the custom extruded shape mesh
  63430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  63431. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63433. */
  63434. static ExtrudeShapeCustom(name: string, options: {
  63435. shape: Vector3[];
  63436. path: Vector3[];
  63437. scaleFunction?: any;
  63438. rotationFunction?: any;
  63439. ribbonCloseArray?: boolean;
  63440. ribbonClosePath?: boolean;
  63441. cap?: number;
  63442. updatable?: boolean;
  63443. sideOrientation?: number;
  63444. frontUVs?: Vector4;
  63445. backUVs?: Vector4;
  63446. instance?: Mesh;
  63447. invertUV?: boolean;
  63448. }, scene?: Nullable<Scene>): Mesh;
  63449. /**
  63450. * Creates lathe mesh.
  63451. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63452. * * 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
  63453. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63454. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63455. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63456. * * 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
  63457. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63458. * * 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
  63459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63463. * @param name defines the name of the mesh
  63464. * @param options defines the options used to create the mesh
  63465. * @param scene defines the hosting scene
  63466. * @returns the lathe mesh
  63467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63468. */
  63469. static CreateLathe(name: string, options: {
  63470. shape: Vector3[];
  63471. radius?: number;
  63472. tessellation?: number;
  63473. clip?: number;
  63474. arc?: number;
  63475. closed?: boolean;
  63476. updatable?: boolean;
  63477. sideOrientation?: number;
  63478. frontUVs?: Vector4;
  63479. backUVs?: Vector4;
  63480. cap?: number;
  63481. invertUV?: boolean;
  63482. }, scene?: Nullable<Scene>): Mesh;
  63483. /**
  63484. * Creates a tiled plane mesh
  63485. * * You can set a limited pattern arrangement with the tiles
  63486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63489. * @param name defines the name of the mesh
  63490. * @param options defines the options used to create the mesh
  63491. * @param scene defines the hosting scene
  63492. * @returns the plane mesh
  63493. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63494. */
  63495. static CreateTiledPlane(name: string, options: {
  63496. pattern?: number;
  63497. tileSize?: number;
  63498. tileWidth?: number;
  63499. tileHeight?: number;
  63500. size?: number;
  63501. width?: number;
  63502. height?: number;
  63503. alignHorizontal?: number;
  63504. alignVertical?: number;
  63505. sideOrientation?: number;
  63506. frontUVs?: Vector4;
  63507. backUVs?: Vector4;
  63508. updatable?: boolean;
  63509. }, scene?: Nullable<Scene>): Mesh;
  63510. /**
  63511. * Creates a plane mesh
  63512. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  63513. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  63514. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  63515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63518. * @param name defines the name of the mesh
  63519. * @param options defines the options used to create the mesh
  63520. * @param scene defines the hosting scene
  63521. * @returns the plane mesh
  63522. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63523. */
  63524. static CreatePlane(name: string, options: {
  63525. size?: number;
  63526. width?: number;
  63527. height?: number;
  63528. sideOrientation?: number;
  63529. frontUVs?: Vector4;
  63530. backUVs?: Vector4;
  63531. updatable?: boolean;
  63532. sourcePlane?: Plane;
  63533. }, scene?: Nullable<Scene>): Mesh;
  63534. /**
  63535. * Creates a ground mesh
  63536. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  63537. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  63538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63539. * @param name defines the name of the mesh
  63540. * @param options defines the options used to create the mesh
  63541. * @param scene defines the hosting scene
  63542. * @returns the ground mesh
  63543. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  63544. */
  63545. static CreateGround(name: string, options: {
  63546. width?: number;
  63547. height?: number;
  63548. subdivisions?: number;
  63549. subdivisionsX?: number;
  63550. subdivisionsY?: number;
  63551. updatable?: boolean;
  63552. }, scene?: Nullable<Scene>): Mesh;
  63553. /**
  63554. * Creates a tiled ground mesh
  63555. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  63556. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  63557. * * 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
  63558. * * 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
  63559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63560. * @param name defines the name of the mesh
  63561. * @param options defines the options used to create the mesh
  63562. * @param scene defines the hosting scene
  63563. * @returns the tiled ground mesh
  63564. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  63565. */
  63566. static CreateTiledGround(name: string, options: {
  63567. xmin: number;
  63568. zmin: number;
  63569. xmax: number;
  63570. zmax: number;
  63571. subdivisions?: {
  63572. w: number;
  63573. h: number;
  63574. };
  63575. precision?: {
  63576. w: number;
  63577. h: number;
  63578. };
  63579. updatable?: boolean;
  63580. }, scene?: Nullable<Scene>): Mesh;
  63581. /**
  63582. * Creates a ground mesh from a height map
  63583. * * The parameter `url` sets the URL of the height map image resource.
  63584. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  63585. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  63586. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  63587. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  63588. * * 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.
  63589. * * 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).
  63590. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  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. * @param name defines the name of the mesh
  63593. * @param url defines the url to the height map
  63594. * @param options defines the options used to create the mesh
  63595. * @param scene defines the hosting scene
  63596. * @returns the ground mesh
  63597. * @see https://doc.babylonjs.com/babylon101/height_map
  63598. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  63599. */
  63600. static CreateGroundFromHeightMap(name: string, url: string, options: {
  63601. width?: number;
  63602. height?: number;
  63603. subdivisions?: number;
  63604. minHeight?: number;
  63605. maxHeight?: number;
  63606. colorFilter?: Color3;
  63607. alphaFilter?: number;
  63608. updatable?: boolean;
  63609. onReady?: (mesh: GroundMesh) => void;
  63610. }, scene?: Nullable<Scene>): GroundMesh;
  63611. /**
  63612. * Creates a polygon mesh
  63613. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63614. * * 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
  63615. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63618. * * Remember you can only change the shape positions, not their number when updating a polygon
  63619. * @param name defines the name of the mesh
  63620. * @param options defines the options used to create the mesh
  63621. * @param scene defines the hosting scene
  63622. * @param earcutInjection can be used to inject your own earcut reference
  63623. * @returns the polygon mesh
  63624. */
  63625. static CreatePolygon(name: string, options: {
  63626. shape: Vector3[];
  63627. holes?: Vector3[][];
  63628. depth?: number;
  63629. faceUV?: Vector4[];
  63630. faceColors?: Color4[];
  63631. updatable?: boolean;
  63632. sideOrientation?: number;
  63633. frontUVs?: Vector4;
  63634. backUVs?: Vector4;
  63635. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63636. /**
  63637. * Creates an extruded polygon mesh, with depth in the Y direction.
  63638. * * 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)
  63639. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63640. * @param name defines the name of the mesh
  63641. * @param options defines the options used to create the mesh
  63642. * @param scene defines the hosting scene
  63643. * @param earcutInjection can be used to inject your own earcut reference
  63644. * @returns the polygon mesh
  63645. */
  63646. static ExtrudePolygon(name: string, options: {
  63647. shape: Vector3[];
  63648. holes?: Vector3[][];
  63649. depth?: number;
  63650. faceUV?: Vector4[];
  63651. faceColors?: Color4[];
  63652. updatable?: boolean;
  63653. sideOrientation?: number;
  63654. frontUVs?: Vector4;
  63655. backUVs?: Vector4;
  63656. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63657. /**
  63658. * Creates a tube mesh.
  63659. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63660. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63661. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63662. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63663. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63664. * * 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)
  63665. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63666. * * 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
  63667. * * 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
  63668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63672. * @param name defines the name of the mesh
  63673. * @param options defines the options used to create the mesh
  63674. * @param scene defines the hosting scene
  63675. * @returns the tube mesh
  63676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63677. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63678. */
  63679. static CreateTube(name: string, options: {
  63680. path: Vector3[];
  63681. radius?: number;
  63682. tessellation?: number;
  63683. radiusFunction?: {
  63684. (i: number, distance: number): number;
  63685. };
  63686. cap?: number;
  63687. arc?: number;
  63688. updatable?: boolean;
  63689. sideOrientation?: number;
  63690. frontUVs?: Vector4;
  63691. backUVs?: Vector4;
  63692. instance?: Mesh;
  63693. invertUV?: boolean;
  63694. }, scene?: Nullable<Scene>): Mesh;
  63695. /**
  63696. * Creates a polyhedron mesh
  63697. * * 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
  63698. * * The parameter `size` (positive float, default 1) sets the polygon size
  63699. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  63700. * * 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`
  63701. * * 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
  63702. * * 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)`)
  63703. * * 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
  63704. * * 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
  63705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63708. * @param name defines the name of the mesh
  63709. * @param options defines the options used to create the mesh
  63710. * @param scene defines the hosting scene
  63711. * @returns the polyhedron mesh
  63712. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  63713. */
  63714. static CreatePolyhedron(name: string, options: {
  63715. type?: number;
  63716. size?: number;
  63717. sizeX?: number;
  63718. sizeY?: number;
  63719. sizeZ?: number;
  63720. custom?: any;
  63721. faceUV?: Vector4[];
  63722. faceColors?: Color4[];
  63723. flat?: boolean;
  63724. updatable?: boolean;
  63725. sideOrientation?: number;
  63726. frontUVs?: Vector4;
  63727. backUVs?: Vector4;
  63728. }, scene?: Nullable<Scene>): Mesh;
  63729. /**
  63730. * Creates a decal mesh.
  63731. * 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
  63732. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63733. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63734. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63735. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63736. * @param name defines the name of the mesh
  63737. * @param sourceMesh defines the mesh where the decal must be applied
  63738. * @param options defines the options used to create the mesh
  63739. * @param scene defines the hosting scene
  63740. * @returns the decal mesh
  63741. * @see https://doc.babylonjs.com/how_to/decals
  63742. */
  63743. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63744. position?: Vector3;
  63745. normal?: Vector3;
  63746. size?: Vector3;
  63747. angle?: number;
  63748. }): Mesh;
  63749. }
  63750. }
  63751. declare module "babylonjs/Meshes/meshSimplification" {
  63752. import { Mesh } from "babylonjs/Meshes/mesh";
  63753. /**
  63754. * A simplifier interface for future simplification implementations
  63755. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63756. */
  63757. export interface ISimplifier {
  63758. /**
  63759. * Simplification of a given mesh according to the given settings.
  63760. * Since this requires computation, it is assumed that the function runs async.
  63761. * @param settings The settings of the simplification, including quality and distance
  63762. * @param successCallback A callback that will be called after the mesh was simplified.
  63763. * @param errorCallback in case of an error, this callback will be called. optional.
  63764. */
  63765. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  63766. }
  63767. /**
  63768. * Expected simplification settings.
  63769. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  63770. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63771. */
  63772. export interface ISimplificationSettings {
  63773. /**
  63774. * Gets or sets the expected quality
  63775. */
  63776. quality: number;
  63777. /**
  63778. * Gets or sets the distance when this optimized version should be used
  63779. */
  63780. distance: number;
  63781. /**
  63782. * Gets an already optimized mesh
  63783. */
  63784. optimizeMesh?: boolean;
  63785. }
  63786. /**
  63787. * Class used to specify simplification options
  63788. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63789. */
  63790. export class SimplificationSettings implements ISimplificationSettings {
  63791. /** expected quality */
  63792. quality: number;
  63793. /** distance when this optimized version should be used */
  63794. distance: number;
  63795. /** already optimized mesh */
  63796. optimizeMesh?: boolean | undefined;
  63797. /**
  63798. * Creates a SimplificationSettings
  63799. * @param quality expected quality
  63800. * @param distance distance when this optimized version should be used
  63801. * @param optimizeMesh already optimized mesh
  63802. */
  63803. constructor(
  63804. /** expected quality */
  63805. quality: number,
  63806. /** distance when this optimized version should be used */
  63807. distance: number,
  63808. /** already optimized mesh */
  63809. optimizeMesh?: boolean | undefined);
  63810. }
  63811. /**
  63812. * Interface used to define a simplification task
  63813. */
  63814. export interface ISimplificationTask {
  63815. /**
  63816. * Array of settings
  63817. */
  63818. settings: Array<ISimplificationSettings>;
  63819. /**
  63820. * Simplification type
  63821. */
  63822. simplificationType: SimplificationType;
  63823. /**
  63824. * Mesh to simplify
  63825. */
  63826. mesh: Mesh;
  63827. /**
  63828. * Callback called on success
  63829. */
  63830. successCallback?: () => void;
  63831. /**
  63832. * Defines if parallel processing can be used
  63833. */
  63834. parallelProcessing: boolean;
  63835. }
  63836. /**
  63837. * Queue used to order the simplification tasks
  63838. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63839. */
  63840. export class SimplificationQueue {
  63841. private _simplificationArray;
  63842. /**
  63843. * Gets a boolean indicating that the process is still running
  63844. */
  63845. running: boolean;
  63846. /**
  63847. * Creates a new queue
  63848. */
  63849. constructor();
  63850. /**
  63851. * Adds a new simplification task
  63852. * @param task defines a task to add
  63853. */
  63854. addTask(task: ISimplificationTask): void;
  63855. /**
  63856. * Execute next task
  63857. */
  63858. executeNext(): void;
  63859. /**
  63860. * Execute a simplification task
  63861. * @param task defines the task to run
  63862. */
  63863. runSimplification(task: ISimplificationTask): void;
  63864. private getSimplifier;
  63865. }
  63866. /**
  63867. * The implemented types of simplification
  63868. * At the moment only Quadratic Error Decimation is implemented
  63869. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63870. */
  63871. export enum SimplificationType {
  63872. /** Quadratic error decimation */
  63873. QUADRATIC = 0
  63874. }
  63875. }
  63876. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  63877. import { Scene } from "babylonjs/scene";
  63878. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  63879. import { ISceneComponent } from "babylonjs/sceneComponent";
  63880. module "babylonjs/scene" {
  63881. interface Scene {
  63882. /** @hidden (Backing field) */
  63883. _simplificationQueue: SimplificationQueue;
  63884. /**
  63885. * Gets or sets the simplification queue attached to the scene
  63886. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63887. */
  63888. simplificationQueue: SimplificationQueue;
  63889. }
  63890. }
  63891. module "babylonjs/Meshes/mesh" {
  63892. interface Mesh {
  63893. /**
  63894. * Simplify the mesh according to the given array of settings.
  63895. * Function will return immediately and will simplify async
  63896. * @param settings a collection of simplification settings
  63897. * @param parallelProcessing should all levels calculate parallel or one after the other
  63898. * @param simplificationType the type of simplification to run
  63899. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63900. * @returns the current mesh
  63901. */
  63902. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63903. }
  63904. }
  63905. /**
  63906. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63907. * created in a scene
  63908. */
  63909. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63910. /**
  63911. * The component name helpfull to identify the component in the list of scene components.
  63912. */
  63913. readonly name: string;
  63914. /**
  63915. * The scene the component belongs to.
  63916. */
  63917. scene: Scene;
  63918. /**
  63919. * Creates a new instance of the component for the given scene
  63920. * @param scene Defines the scene to register the component in
  63921. */
  63922. constructor(scene: Scene);
  63923. /**
  63924. * Registers the component in a given scene
  63925. */
  63926. register(): void;
  63927. /**
  63928. * Rebuilds the elements related to this component in case of
  63929. * context lost for instance.
  63930. */
  63931. rebuild(): void;
  63932. /**
  63933. * Disposes the component and the associated ressources
  63934. */
  63935. dispose(): void;
  63936. private _beforeCameraUpdate;
  63937. }
  63938. }
  63939. declare module "babylonjs/Meshes/Builders/index" {
  63940. export * from "babylonjs/Meshes/Builders/boxBuilder";
  63941. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  63942. export * from "babylonjs/Meshes/Builders/discBuilder";
  63943. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  63944. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  63945. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  63946. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  63947. export * from "babylonjs/Meshes/Builders/torusBuilder";
  63948. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  63949. export * from "babylonjs/Meshes/Builders/linesBuilder";
  63950. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  63951. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  63952. export * from "babylonjs/Meshes/Builders/latheBuilder";
  63953. export * from "babylonjs/Meshes/Builders/planeBuilder";
  63954. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  63955. export * from "babylonjs/Meshes/Builders/groundBuilder";
  63956. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  63957. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  63958. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  63959. export * from "babylonjs/Meshes/Builders/decalBuilder";
  63960. }
  63961. declare module "babylonjs/Meshes/index" {
  63962. export * from "babylonjs/Meshes/abstractMesh";
  63963. export * from "babylonjs/Meshes/buffer";
  63964. export * from "babylonjs/Meshes/Compression/index";
  63965. export * from "babylonjs/Meshes/csg";
  63966. export * from "babylonjs/Meshes/geometry";
  63967. export * from "babylonjs/Meshes/groundMesh";
  63968. export * from "babylonjs/Meshes/trailMesh";
  63969. export * from "babylonjs/Meshes/instancedMesh";
  63970. export * from "babylonjs/Meshes/linesMesh";
  63971. export * from "babylonjs/Meshes/mesh";
  63972. export * from "babylonjs/Meshes/mesh.vertexData";
  63973. export * from "babylonjs/Meshes/meshBuilder";
  63974. export * from "babylonjs/Meshes/meshSimplification";
  63975. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  63976. export * from "babylonjs/Meshes/polygonMesh";
  63977. export * from "babylonjs/Meshes/subMesh";
  63978. export * from "babylonjs/Meshes/meshLODLevel";
  63979. export * from "babylonjs/Meshes/transformNode";
  63980. export * from "babylonjs/Meshes/Builders/index";
  63981. export * from "babylonjs/Meshes/dataBuffer";
  63982. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  63983. }
  63984. declare module "babylonjs/Morph/index" {
  63985. export * from "babylonjs/Morph/morphTarget";
  63986. export * from "babylonjs/Morph/morphTargetManager";
  63987. }
  63988. declare module "babylonjs/Navigation/INavigationEngine" {
  63989. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63990. import { Vector3 } from "babylonjs/Maths/math";
  63991. import { Mesh } from "babylonjs/Meshes/mesh";
  63992. import { Scene } from "babylonjs/scene";
  63993. /**
  63994. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63995. */
  63996. export interface INavigationEnginePlugin {
  63997. /**
  63998. * plugin name
  63999. */
  64000. name: string;
  64001. /**
  64002. * Creates a navigation mesh
  64003. * @param meshes array of all the geometry used to compute the navigatio mesh
  64004. * @param parameters bunch of parameters used to filter geometry
  64005. */
  64006. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64007. /**
  64008. * Create a navigation mesh debug mesh
  64009. * @param scene is where the mesh will be added
  64010. * @returns debug display mesh
  64011. */
  64012. createDebugNavMesh(scene: Scene): Mesh;
  64013. /**
  64014. * Get a navigation mesh constrained position, closest to the parameter position
  64015. * @param position world position
  64016. * @returns the closest point to position constrained by the navigation mesh
  64017. */
  64018. getClosestPoint(position: Vector3): Vector3;
  64019. /**
  64020. * Get a navigation mesh constrained position, within a particular radius
  64021. * @param position world position
  64022. * @param maxRadius the maximum distance to the constrained world position
  64023. * @returns the closest point to position constrained by the navigation mesh
  64024. */
  64025. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64026. /**
  64027. * Compute the final position from a segment made of destination-position
  64028. * @param position world position
  64029. * @param destination world position
  64030. * @returns the resulting point along the navmesh
  64031. */
  64032. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64033. /**
  64034. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64035. * @param start world position
  64036. * @param end world position
  64037. * @returns array containing world position composing the path
  64038. */
  64039. computePath(start: Vector3, end: Vector3): Vector3[];
  64040. /**
  64041. * If this plugin is supported
  64042. * @returns true if plugin is supported
  64043. */
  64044. isSupported(): boolean;
  64045. /**
  64046. * Create a new Crowd so you can add agents
  64047. * @param maxAgents the maximum agent count in the crowd
  64048. * @param maxAgentRadius the maximum radius an agent can have
  64049. * @param scene to attach the crowd to
  64050. * @returns the crowd you can add agents to
  64051. */
  64052. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64053. /**
  64054. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64055. * The queries will try to find a solution within those bounds
  64056. * default is (1,1,1)
  64057. * @param extent x,y,z value that define the extent around the queries point of reference
  64058. */
  64059. setDefaultQueryExtent(extent: Vector3): void;
  64060. /**
  64061. * Get the Bounding box extent specified by setDefaultQueryExtent
  64062. * @returns the box extent values
  64063. */
  64064. getDefaultQueryExtent(): Vector3;
  64065. /**
  64066. * Release all resources
  64067. */
  64068. dispose(): void;
  64069. }
  64070. /**
  64071. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64072. */
  64073. export interface ICrowd {
  64074. /**
  64075. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64076. * You can attach anything to that node. The node position is updated in the scene update tick.
  64077. * @param pos world position that will be constrained by the navigation mesh
  64078. * @param parameters agent parameters
  64079. * @param transform hooked to the agent that will be update by the scene
  64080. * @returns agent index
  64081. */
  64082. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64083. /**
  64084. * Returns the agent position in world space
  64085. * @param index agent index returned by addAgent
  64086. * @returns world space position
  64087. */
  64088. getAgentPosition(index: number): Vector3;
  64089. /**
  64090. * Gets the agent velocity in world space
  64091. * @param index agent index returned by addAgent
  64092. * @returns world space velocity
  64093. */
  64094. getAgentVelocity(index: number): Vector3;
  64095. /**
  64096. * remove a particular agent previously created
  64097. * @param index agent index returned by addAgent
  64098. */
  64099. removeAgent(index: number): void;
  64100. /**
  64101. * get the list of all agents attached to this crowd
  64102. * @returns list of agent indices
  64103. */
  64104. getAgents(): number[];
  64105. /**
  64106. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64107. * @param deltaTime in seconds
  64108. */
  64109. update(deltaTime: number): void;
  64110. /**
  64111. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64112. * @param index agent index returned by addAgent
  64113. * @param destination targeted world position
  64114. */
  64115. agentGoto(index: number, destination: Vector3): void;
  64116. /**
  64117. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64118. * The queries will try to find a solution within those bounds
  64119. * default is (1,1,1)
  64120. * @param extent x,y,z value that define the extent around the queries point of reference
  64121. */
  64122. setDefaultQueryExtent(extent: Vector3): void;
  64123. /**
  64124. * Get the Bounding box extent specified by setDefaultQueryExtent
  64125. * @returns the box extent values
  64126. */
  64127. getDefaultQueryExtent(): Vector3;
  64128. /**
  64129. * Release all resources
  64130. */
  64131. dispose(): void;
  64132. }
  64133. /**
  64134. * Configures an agent
  64135. */
  64136. export interface IAgentParameters {
  64137. /**
  64138. * Agent radius. [Limit: >= 0]
  64139. */
  64140. radius: number;
  64141. /**
  64142. * Agent height. [Limit: > 0]
  64143. */
  64144. height: number;
  64145. /**
  64146. * Maximum allowed acceleration. [Limit: >= 0]
  64147. */
  64148. maxAcceleration: number;
  64149. /**
  64150. * Maximum allowed speed. [Limit: >= 0]
  64151. */
  64152. maxSpeed: number;
  64153. /**
  64154. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  64155. */
  64156. collisionQueryRange: number;
  64157. /**
  64158. * The path visibility optimization range. [Limit: > 0]
  64159. */
  64160. pathOptimizationRange: number;
  64161. /**
  64162. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  64163. */
  64164. separationWeight: number;
  64165. }
  64166. /**
  64167. * Configures the navigation mesh creation
  64168. */
  64169. export interface INavMeshParameters {
  64170. /**
  64171. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  64172. */
  64173. cs: number;
  64174. /**
  64175. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  64176. */
  64177. ch: number;
  64178. /**
  64179. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  64180. */
  64181. walkableSlopeAngle: number;
  64182. /**
  64183. * Minimum floor to 'ceiling' height that will still allow the floor area to
  64184. * be considered walkable. [Limit: >= 3] [Units: vx]
  64185. */
  64186. walkableHeight: number;
  64187. /**
  64188. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  64189. */
  64190. walkableClimb: number;
  64191. /**
  64192. * The distance to erode/shrink the walkable area of the heightfield away from
  64193. * obstructions. [Limit: >=0] [Units: vx]
  64194. */
  64195. walkableRadius: number;
  64196. /**
  64197. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  64198. */
  64199. maxEdgeLen: number;
  64200. /**
  64201. * The maximum distance a simplfied contour's border edges should deviate
  64202. * the original raw contour. [Limit: >=0] [Units: vx]
  64203. */
  64204. maxSimplificationError: number;
  64205. /**
  64206. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  64207. */
  64208. minRegionArea: number;
  64209. /**
  64210. * Any regions with a span count smaller than this value will, if possible,
  64211. * be merged with larger regions. [Limit: >=0] [Units: vx]
  64212. */
  64213. mergeRegionArea: number;
  64214. /**
  64215. * The maximum number of vertices allowed for polygons generated during the
  64216. * contour to polygon conversion process. [Limit: >= 3]
  64217. */
  64218. maxVertsPerPoly: number;
  64219. /**
  64220. * Sets the sampling distance to use when generating the detail mesh.
  64221. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  64222. */
  64223. detailSampleDist: number;
  64224. /**
  64225. * The maximum distance the detail mesh surface should deviate from heightfield
  64226. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  64227. */
  64228. detailSampleMaxError: number;
  64229. }
  64230. }
  64231. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  64232. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  64233. import { Mesh } from "babylonjs/Meshes/mesh";
  64234. import { Scene } from "babylonjs/scene";
  64235. import { Vector3 } from "babylonjs/Maths/math";
  64236. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64237. /**
  64238. * RecastJS navigation plugin
  64239. */
  64240. export class RecastJSPlugin implements INavigationEnginePlugin {
  64241. /**
  64242. * Reference to the Recast library
  64243. */
  64244. bjsRECAST: any;
  64245. /**
  64246. * plugin name
  64247. */
  64248. name: string;
  64249. /**
  64250. * the first navmesh created. We might extend this to support multiple navmeshes
  64251. */
  64252. navMesh: any;
  64253. /**
  64254. * Initializes the recastJS plugin
  64255. * @param recastInjection can be used to inject your own recast reference
  64256. */
  64257. constructor(recastInjection?: any);
  64258. /**
  64259. * Creates a navigation mesh
  64260. * @param meshes array of all the geometry used to compute the navigatio mesh
  64261. * @param parameters bunch of parameters used to filter geometry
  64262. */
  64263. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64264. /**
  64265. * Create a navigation mesh debug mesh
  64266. * @param scene is where the mesh will be added
  64267. * @returns debug display mesh
  64268. */
  64269. createDebugNavMesh(scene: Scene): Mesh;
  64270. /**
  64271. * Get a navigation mesh constrained position, closest to the parameter position
  64272. * @param position world position
  64273. * @returns the closest point to position constrained by the navigation mesh
  64274. */
  64275. getClosestPoint(position: Vector3): Vector3;
  64276. /**
  64277. * Get a navigation mesh constrained position, within a particular radius
  64278. * @param position world position
  64279. * @param maxRadius the maximum distance to the constrained world position
  64280. * @returns the closest point to position constrained by the navigation mesh
  64281. */
  64282. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64283. /**
  64284. * Compute the final position from a segment made of destination-position
  64285. * @param position world position
  64286. * @param destination world position
  64287. * @returns the resulting point along the navmesh
  64288. */
  64289. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64290. /**
  64291. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64292. * @param start world position
  64293. * @param end world position
  64294. * @returns array containing world position composing the path
  64295. */
  64296. computePath(start: Vector3, end: Vector3): Vector3[];
  64297. /**
  64298. * Create a new Crowd so you can add agents
  64299. * @param maxAgents the maximum agent count in the crowd
  64300. * @param maxAgentRadius the maximum radius an agent can have
  64301. * @param scene to attach the crowd to
  64302. * @returns the crowd you can add agents to
  64303. */
  64304. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64305. /**
  64306. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64307. * The queries will try to find a solution within those bounds
  64308. * default is (1,1,1)
  64309. * @param extent x,y,z value that define the extent around the queries point of reference
  64310. */
  64311. setDefaultQueryExtent(extent: Vector3): void;
  64312. /**
  64313. * Get the Bounding box extent specified by setDefaultQueryExtent
  64314. * @returns the box extent values
  64315. */
  64316. getDefaultQueryExtent(): Vector3;
  64317. /**
  64318. * Disposes
  64319. */
  64320. dispose(): void;
  64321. /**
  64322. * If this plugin is supported
  64323. * @returns true if plugin is supported
  64324. */
  64325. isSupported(): boolean;
  64326. }
  64327. /**
  64328. * Recast detour crowd implementation
  64329. */
  64330. export class RecastJSCrowd implements ICrowd {
  64331. /**
  64332. * Recast/detour plugin
  64333. */
  64334. bjsRECASTPlugin: RecastJSPlugin;
  64335. /**
  64336. * Link to the detour crowd
  64337. */
  64338. recastCrowd: any;
  64339. /**
  64340. * One transform per agent
  64341. */
  64342. transforms: TransformNode[];
  64343. /**
  64344. * All agents created
  64345. */
  64346. agents: number[];
  64347. /**
  64348. * Link to the scene is kept to unregister the crowd from the scene
  64349. */
  64350. private _scene;
  64351. /**
  64352. * Observer for crowd updates
  64353. */
  64354. private _onBeforeAnimationsObserver;
  64355. /**
  64356. * Constructor
  64357. * @param plugin recastJS plugin
  64358. * @param maxAgents the maximum agent count in the crowd
  64359. * @param maxAgentRadius the maximum radius an agent can have
  64360. * @param scene to attach the crowd to
  64361. * @returns the crowd you can add agents to
  64362. */
  64363. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  64364. /**
  64365. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64366. * You can attach anything to that node. The node position is updated in the scene update tick.
  64367. * @param pos world position that will be constrained by the navigation mesh
  64368. * @param parameters agent parameters
  64369. * @param transform hooked to the agent that will be update by the scene
  64370. * @returns agent index
  64371. */
  64372. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64373. /**
  64374. * Returns the agent position in world space
  64375. * @param index agent index returned by addAgent
  64376. * @returns world space position
  64377. */
  64378. getAgentPosition(index: number): Vector3;
  64379. /**
  64380. * Returns the agent velocity in world space
  64381. * @param index agent index returned by addAgent
  64382. * @returns world space velocity
  64383. */
  64384. getAgentVelocity(index: number): Vector3;
  64385. /**
  64386. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64387. * @param index agent index returned by addAgent
  64388. * @param destination targeted world position
  64389. */
  64390. agentGoto(index: number, destination: Vector3): void;
  64391. /**
  64392. * remove a particular agent previously created
  64393. * @param index agent index returned by addAgent
  64394. */
  64395. removeAgent(index: number): void;
  64396. /**
  64397. * get the list of all agents attached to this crowd
  64398. * @returns list of agent indices
  64399. */
  64400. getAgents(): number[];
  64401. /**
  64402. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64403. * @param deltaTime in seconds
  64404. */
  64405. update(deltaTime: number): void;
  64406. /**
  64407. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64408. * The queries will try to find a solution within those bounds
  64409. * default is (1,1,1)
  64410. * @param extent x,y,z value that define the extent around the queries point of reference
  64411. */
  64412. setDefaultQueryExtent(extent: Vector3): void;
  64413. /**
  64414. * Get the Bounding box extent specified by setDefaultQueryExtent
  64415. * @returns the box extent values
  64416. */
  64417. getDefaultQueryExtent(): Vector3;
  64418. /**
  64419. * Release all resources
  64420. */
  64421. dispose(): void;
  64422. }
  64423. }
  64424. declare module "babylonjs/Navigation/Plugins/index" {
  64425. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  64426. }
  64427. declare module "babylonjs/Navigation/index" {
  64428. export * from "babylonjs/Navigation/INavigationEngine";
  64429. export * from "babylonjs/Navigation/Plugins/index";
  64430. }
  64431. declare module "babylonjs/Offline/database" {
  64432. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  64433. /**
  64434. * Class used to enable access to IndexedDB
  64435. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64436. */
  64437. export class Database implements IOfflineProvider {
  64438. private _callbackManifestChecked;
  64439. private _currentSceneUrl;
  64440. private _db;
  64441. private _enableSceneOffline;
  64442. private _enableTexturesOffline;
  64443. private _manifestVersionFound;
  64444. private _mustUpdateRessources;
  64445. private _hasReachedQuota;
  64446. private _isSupported;
  64447. private _idbFactory;
  64448. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  64449. private static IsUASupportingBlobStorage;
  64450. /**
  64451. * Gets a boolean indicating if Database storate is enabled (off by default)
  64452. */
  64453. static IDBStorageEnabled: boolean;
  64454. /**
  64455. * Gets a boolean indicating if scene must be saved in the database
  64456. */
  64457. get enableSceneOffline(): boolean;
  64458. /**
  64459. * Gets a boolean indicating if textures must be saved in the database
  64460. */
  64461. get enableTexturesOffline(): boolean;
  64462. /**
  64463. * Creates a new Database
  64464. * @param urlToScene defines the url to load the scene
  64465. * @param callbackManifestChecked defines the callback to use when manifest is checked
  64466. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  64467. */
  64468. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  64469. private static _ParseURL;
  64470. private static _ReturnFullUrlLocation;
  64471. private _checkManifestFile;
  64472. /**
  64473. * Open the database and make it available
  64474. * @param successCallback defines the callback to call on success
  64475. * @param errorCallback defines the callback to call on error
  64476. */
  64477. open(successCallback: () => void, errorCallback: () => void): void;
  64478. /**
  64479. * Loads an image from the database
  64480. * @param url defines the url to load from
  64481. * @param image defines the target DOM image
  64482. */
  64483. loadImage(url: string, image: HTMLImageElement): void;
  64484. private _loadImageFromDBAsync;
  64485. private _saveImageIntoDBAsync;
  64486. private _checkVersionFromDB;
  64487. private _loadVersionFromDBAsync;
  64488. private _saveVersionIntoDBAsync;
  64489. /**
  64490. * Loads a file from database
  64491. * @param url defines the URL to load from
  64492. * @param sceneLoaded defines a callback to call on success
  64493. * @param progressCallBack defines a callback to call when progress changed
  64494. * @param errorCallback defines a callback to call on error
  64495. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64496. */
  64497. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64498. private _loadFileAsync;
  64499. private _saveFileAsync;
  64500. /**
  64501. * Validates if xhr data is correct
  64502. * @param xhr defines the request to validate
  64503. * @param dataType defines the expected data type
  64504. * @returns true if data is correct
  64505. */
  64506. private static _ValidateXHRData;
  64507. }
  64508. }
  64509. declare module "babylonjs/Offline/index" {
  64510. export * from "babylonjs/Offline/database";
  64511. export * from "babylonjs/Offline/IOfflineProvider";
  64512. }
  64513. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  64514. /** @hidden */
  64515. export var gpuUpdateParticlesPixelShader: {
  64516. name: string;
  64517. shader: string;
  64518. };
  64519. }
  64520. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  64521. /** @hidden */
  64522. export var gpuUpdateParticlesVertexShader: {
  64523. name: string;
  64524. shader: string;
  64525. };
  64526. }
  64527. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  64528. /** @hidden */
  64529. export var clipPlaneFragmentDeclaration2: {
  64530. name: string;
  64531. shader: string;
  64532. };
  64533. }
  64534. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  64535. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  64536. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64537. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64538. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64539. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  64540. /** @hidden */
  64541. export var gpuRenderParticlesPixelShader: {
  64542. name: string;
  64543. shader: string;
  64544. };
  64545. }
  64546. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  64547. /** @hidden */
  64548. export var clipPlaneVertexDeclaration2: {
  64549. name: string;
  64550. shader: string;
  64551. };
  64552. }
  64553. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  64554. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  64555. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  64556. /** @hidden */
  64557. export var gpuRenderParticlesVertexShader: {
  64558. name: string;
  64559. shader: string;
  64560. };
  64561. }
  64562. declare module "babylonjs/Particles/gpuParticleSystem" {
  64563. import { Nullable } from "babylonjs/types";
  64564. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  64565. import { Observable } from "babylonjs/Misc/observable";
  64566. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64567. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64568. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  64569. import { Scene, IDisposable } from "babylonjs/scene";
  64570. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  64571. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64572. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  64573. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  64574. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  64575. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  64576. /**
  64577. * This represents a GPU particle system in Babylon
  64578. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  64579. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  64580. */
  64581. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  64582. /**
  64583. * The layer mask we are rendering the particles through.
  64584. */
  64585. layerMask: number;
  64586. private _capacity;
  64587. private _activeCount;
  64588. private _currentActiveCount;
  64589. private _accumulatedCount;
  64590. private _renderEffect;
  64591. private _updateEffect;
  64592. private _buffer0;
  64593. private _buffer1;
  64594. private _spriteBuffer;
  64595. private _updateVAO;
  64596. private _renderVAO;
  64597. private _targetIndex;
  64598. private _sourceBuffer;
  64599. private _targetBuffer;
  64600. private _engine;
  64601. private _currentRenderId;
  64602. private _started;
  64603. private _stopped;
  64604. private _timeDelta;
  64605. private _randomTexture;
  64606. private _randomTexture2;
  64607. private _attributesStrideSize;
  64608. private _updateEffectOptions;
  64609. private _randomTextureSize;
  64610. private _actualFrame;
  64611. private readonly _rawTextureWidth;
  64612. /**
  64613. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  64614. */
  64615. static get IsSupported(): boolean;
  64616. /**
  64617. * An event triggered when the system is disposed.
  64618. */
  64619. onDisposeObservable: Observable<GPUParticleSystem>;
  64620. /**
  64621. * Gets the maximum number of particles active at the same time.
  64622. * @returns The max number of active particles.
  64623. */
  64624. getCapacity(): number;
  64625. /**
  64626. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  64627. * to override the particles.
  64628. */
  64629. forceDepthWrite: boolean;
  64630. /**
  64631. * Gets or set the number of active particles
  64632. */
  64633. get activeParticleCount(): number;
  64634. set activeParticleCount(value: number);
  64635. private _preWarmDone;
  64636. /**
  64637. * Is this system ready to be used/rendered
  64638. * @return true if the system is ready
  64639. */
  64640. isReady(): boolean;
  64641. /**
  64642. * Gets if the system has been started. (Note: this will still be true after stop is called)
  64643. * @returns True if it has been started, otherwise false.
  64644. */
  64645. isStarted(): boolean;
  64646. /**
  64647. * Starts the particle system and begins to emit
  64648. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  64649. */
  64650. start(delay?: number): void;
  64651. /**
  64652. * Stops the particle system.
  64653. */
  64654. stop(): void;
  64655. /**
  64656. * Remove all active particles
  64657. */
  64658. reset(): void;
  64659. /**
  64660. * Returns the string "GPUParticleSystem"
  64661. * @returns a string containing the class name
  64662. */
  64663. getClassName(): string;
  64664. private _colorGradientsTexture;
  64665. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  64666. /**
  64667. * Adds a new color gradient
  64668. * @param gradient defines the gradient to use (between 0 and 1)
  64669. * @param color1 defines the color to affect to the specified gradient
  64670. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  64671. * @returns the current particle system
  64672. */
  64673. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  64674. /**
  64675. * Remove a specific color gradient
  64676. * @param gradient defines the gradient to remove
  64677. * @returns the current particle system
  64678. */
  64679. removeColorGradient(gradient: number): GPUParticleSystem;
  64680. private _angularSpeedGradientsTexture;
  64681. private _sizeGradientsTexture;
  64682. private _velocityGradientsTexture;
  64683. private _limitVelocityGradientsTexture;
  64684. private _dragGradientsTexture;
  64685. private _addFactorGradient;
  64686. /**
  64687. * Adds a new size gradient
  64688. * @param gradient defines the gradient to use (between 0 and 1)
  64689. * @param factor defines the size factor to affect to the specified gradient
  64690. * @returns the current particle system
  64691. */
  64692. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  64693. /**
  64694. * Remove a specific size gradient
  64695. * @param gradient defines the gradient to remove
  64696. * @returns the current particle system
  64697. */
  64698. removeSizeGradient(gradient: number): GPUParticleSystem;
  64699. /**
  64700. * Adds a new angular speed gradient
  64701. * @param gradient defines the gradient to use (between 0 and 1)
  64702. * @param factor defines the angular speed to affect to the specified gradient
  64703. * @returns the current particle system
  64704. */
  64705. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  64706. /**
  64707. * Remove a specific angular speed gradient
  64708. * @param gradient defines the gradient to remove
  64709. * @returns the current particle system
  64710. */
  64711. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  64712. /**
  64713. * Adds a new velocity gradient
  64714. * @param gradient defines the gradient to use (between 0 and 1)
  64715. * @param factor defines the velocity to affect to the specified gradient
  64716. * @returns the current particle system
  64717. */
  64718. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64719. /**
  64720. * Remove a specific velocity gradient
  64721. * @param gradient defines the gradient to remove
  64722. * @returns the current particle system
  64723. */
  64724. removeVelocityGradient(gradient: number): GPUParticleSystem;
  64725. /**
  64726. * Adds a new limit velocity gradient
  64727. * @param gradient defines the gradient to use (between 0 and 1)
  64728. * @param factor defines the limit velocity value to affect to the specified gradient
  64729. * @returns the current particle system
  64730. */
  64731. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64732. /**
  64733. * Remove a specific limit velocity gradient
  64734. * @param gradient defines the gradient to remove
  64735. * @returns the current particle system
  64736. */
  64737. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  64738. /**
  64739. * Adds a new drag gradient
  64740. * @param gradient defines the gradient to use (between 0 and 1)
  64741. * @param factor defines the drag value to affect to the specified gradient
  64742. * @returns the current particle system
  64743. */
  64744. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  64745. /**
  64746. * Remove a specific drag gradient
  64747. * @param gradient defines the gradient to remove
  64748. * @returns the current particle system
  64749. */
  64750. removeDragGradient(gradient: number): GPUParticleSystem;
  64751. /**
  64752. * Not supported by GPUParticleSystem
  64753. * @param gradient defines the gradient to use (between 0 and 1)
  64754. * @param factor defines the emit rate value to affect to the specified gradient
  64755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64756. * @returns the current particle system
  64757. */
  64758. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64759. /**
  64760. * Not supported by GPUParticleSystem
  64761. * @param gradient defines the gradient to remove
  64762. * @returns the current particle system
  64763. */
  64764. removeEmitRateGradient(gradient: number): IParticleSystem;
  64765. /**
  64766. * Not supported by GPUParticleSystem
  64767. * @param gradient defines the gradient to use (between 0 and 1)
  64768. * @param factor defines the start size value to affect to the specified gradient
  64769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64770. * @returns the current particle system
  64771. */
  64772. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64773. /**
  64774. * Not supported by GPUParticleSystem
  64775. * @param gradient defines the gradient to remove
  64776. * @returns the current particle system
  64777. */
  64778. removeStartSizeGradient(gradient: number): IParticleSystem;
  64779. /**
  64780. * Not supported by GPUParticleSystem
  64781. * @param gradient defines the gradient to use (between 0 and 1)
  64782. * @param min defines the color remap minimal range
  64783. * @param max defines the color remap maximal range
  64784. * @returns the current particle system
  64785. */
  64786. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64787. /**
  64788. * Not supported by GPUParticleSystem
  64789. * @param gradient defines the gradient to remove
  64790. * @returns the current particle system
  64791. */
  64792. removeColorRemapGradient(): IParticleSystem;
  64793. /**
  64794. * Not supported by GPUParticleSystem
  64795. * @param gradient defines the gradient to use (between 0 and 1)
  64796. * @param min defines the alpha remap minimal range
  64797. * @param max defines the alpha remap maximal range
  64798. * @returns the current particle system
  64799. */
  64800. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64801. /**
  64802. * Not supported by GPUParticleSystem
  64803. * @param gradient defines the gradient to remove
  64804. * @returns the current particle system
  64805. */
  64806. removeAlphaRemapGradient(): IParticleSystem;
  64807. /**
  64808. * Not supported by GPUParticleSystem
  64809. * @param gradient defines the gradient to use (between 0 and 1)
  64810. * @param color defines the color to affect to the specified gradient
  64811. * @returns the current particle system
  64812. */
  64813. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  64814. /**
  64815. * Not supported by GPUParticleSystem
  64816. * @param gradient defines the gradient to remove
  64817. * @returns the current particle system
  64818. */
  64819. removeRampGradient(): IParticleSystem;
  64820. /**
  64821. * Not supported by GPUParticleSystem
  64822. * @returns the list of ramp gradients
  64823. */
  64824. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64825. /**
  64826. * Not supported by GPUParticleSystem
  64827. * Gets or sets a boolean indicating that ramp gradients must be used
  64828. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64829. */
  64830. get useRampGradients(): boolean;
  64831. set useRampGradients(value: boolean);
  64832. /**
  64833. * Not supported by GPUParticleSystem
  64834. * @param gradient defines the gradient to use (between 0 and 1)
  64835. * @param factor defines the life time factor to affect to the specified gradient
  64836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64837. * @returns the current particle system
  64838. */
  64839. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64840. /**
  64841. * Not supported by GPUParticleSystem
  64842. * @param gradient defines the gradient to remove
  64843. * @returns the current particle system
  64844. */
  64845. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64846. /**
  64847. * Instantiates a GPU particle system.
  64848. * 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.
  64849. * @param name The name of the particle system
  64850. * @param options The options used to create the system
  64851. * @param scene The scene the particle system belongs to
  64852. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64853. */
  64854. constructor(name: string, options: Partial<{
  64855. capacity: number;
  64856. randomTextureSize: number;
  64857. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64858. protected _reset(): void;
  64859. private _createUpdateVAO;
  64860. private _createRenderVAO;
  64861. private _initialize;
  64862. /** @hidden */
  64863. _recreateUpdateEffect(): void;
  64864. /** @hidden */
  64865. _recreateRenderEffect(): void;
  64866. /**
  64867. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64868. * @param preWarm defines if we are in the pre-warmimg phase
  64869. */
  64870. animate(preWarm?: boolean): void;
  64871. private _createFactorGradientTexture;
  64872. private _createSizeGradientTexture;
  64873. private _createAngularSpeedGradientTexture;
  64874. private _createVelocityGradientTexture;
  64875. private _createLimitVelocityGradientTexture;
  64876. private _createDragGradientTexture;
  64877. private _createColorGradientTexture;
  64878. /**
  64879. * Renders the particle system in its current state
  64880. * @param preWarm defines if the system should only update the particles but not render them
  64881. * @returns the current number of particles
  64882. */
  64883. render(preWarm?: boolean): number;
  64884. /**
  64885. * Rebuilds the particle system
  64886. */
  64887. rebuild(): void;
  64888. private _releaseBuffers;
  64889. private _releaseVAOs;
  64890. /**
  64891. * Disposes the particle system and free the associated resources
  64892. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64893. */
  64894. dispose(disposeTexture?: boolean): void;
  64895. /**
  64896. * Clones the particle system.
  64897. * @param name The name of the cloned object
  64898. * @param newEmitter The new emitter to use
  64899. * @returns the cloned particle system
  64900. */
  64901. clone(name: string, newEmitter: any): GPUParticleSystem;
  64902. /**
  64903. * Serializes the particle system to a JSON object.
  64904. * @returns the JSON object
  64905. */
  64906. serialize(): any;
  64907. /**
  64908. * Parses a JSON object to create a GPU particle system.
  64909. * @param parsedParticleSystem The JSON object to parse
  64910. * @param scene The scene to create the particle system in
  64911. * @param rootUrl The root url to use to load external dependencies like texture
  64912. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64913. * @returns the parsed GPU particle system
  64914. */
  64915. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64916. }
  64917. }
  64918. declare module "babylonjs/Particles/particleSystemSet" {
  64919. import { Nullable } from "babylonjs/types";
  64920. import { Color3 } from "babylonjs/Maths/math.color";
  64921. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64923. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64924. import { Scene, IDisposable } from "babylonjs/scene";
  64925. /**
  64926. * Represents a set of particle systems working together to create a specific effect
  64927. */
  64928. export class ParticleSystemSet implements IDisposable {
  64929. /**
  64930. * Gets or sets base Assets URL
  64931. */
  64932. static BaseAssetsUrl: string;
  64933. private _emitterCreationOptions;
  64934. private _emitterNode;
  64935. /**
  64936. * Gets the particle system list
  64937. */
  64938. systems: IParticleSystem[];
  64939. /**
  64940. * Gets the emitter node used with this set
  64941. */
  64942. get emitterNode(): Nullable<TransformNode>;
  64943. /**
  64944. * Creates a new emitter mesh as a sphere
  64945. * @param options defines the options used to create the sphere
  64946. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64947. * @param scene defines the hosting scene
  64948. */
  64949. setEmitterAsSphere(options: {
  64950. diameter: number;
  64951. segments: number;
  64952. color: Color3;
  64953. }, renderingGroupId: number, scene: Scene): void;
  64954. /**
  64955. * Starts all particle systems of the set
  64956. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64957. */
  64958. start(emitter?: AbstractMesh): void;
  64959. /**
  64960. * Release all associated resources
  64961. */
  64962. dispose(): void;
  64963. /**
  64964. * Serialize the set into a JSON compatible object
  64965. * @returns a JSON compatible representation of the set
  64966. */
  64967. serialize(): any;
  64968. /**
  64969. * Parse a new ParticleSystemSet from a serialized source
  64970. * @param data defines a JSON compatible representation of the set
  64971. * @param scene defines the hosting scene
  64972. * @param gpu defines if we want GPU particles or CPU particles
  64973. * @returns a new ParticleSystemSet
  64974. */
  64975. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64976. }
  64977. }
  64978. declare module "babylonjs/Particles/particleHelper" {
  64979. import { Nullable } from "babylonjs/types";
  64980. import { Scene } from "babylonjs/scene";
  64981. import { Vector3 } from "babylonjs/Maths/math.vector";
  64982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64983. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64984. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  64985. /**
  64986. * This class is made for on one-liner static method to help creating particle system set.
  64987. */
  64988. export class ParticleHelper {
  64989. /**
  64990. * Gets or sets base Assets URL
  64991. */
  64992. static BaseAssetsUrl: string;
  64993. /**
  64994. * Create a default particle system that you can tweak
  64995. * @param emitter defines the emitter to use
  64996. * @param capacity defines the system capacity (default is 500 particles)
  64997. * @param scene defines the hosting scene
  64998. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64999. * @returns the new Particle system
  65000. */
  65001. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65002. /**
  65003. * This is the main static method (one-liner) of this helper to create different particle systems
  65004. * @param type This string represents the type to the particle system to create
  65005. * @param scene The scene where the particle system should live
  65006. * @param gpu If the system will use gpu
  65007. * @returns the ParticleSystemSet created
  65008. */
  65009. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65010. /**
  65011. * Static function used to export a particle system to a ParticleSystemSet variable.
  65012. * Please note that the emitter shape is not exported
  65013. * @param systems defines the particle systems to export
  65014. * @returns the created particle system set
  65015. */
  65016. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  65017. }
  65018. }
  65019. declare module "babylonjs/Particles/particleSystemComponent" {
  65020. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65021. import { Effect } from "babylonjs/Materials/effect";
  65022. import "babylonjs/Shaders/particles.vertex";
  65023. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65024. module "babylonjs/Engines/engine" {
  65025. interface Engine {
  65026. /**
  65027. * Create an effect to use with particle systems.
  65028. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  65029. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  65030. * @param uniformsNames defines a list of attribute names
  65031. * @param samplers defines an array of string used to represent textures
  65032. * @param defines defines the string containing the defines to use to compile the shaders
  65033. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  65034. * @param onCompiled defines a function to call when the effect creation is successful
  65035. * @param onError defines a function to call when the effect creation has failed
  65036. * @returns the new Effect
  65037. */
  65038. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  65039. }
  65040. }
  65041. module "babylonjs/Meshes/mesh" {
  65042. interface Mesh {
  65043. /**
  65044. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  65045. * @returns an array of IParticleSystem
  65046. */
  65047. getEmittedParticleSystems(): IParticleSystem[];
  65048. /**
  65049. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  65050. * @returns an array of IParticleSystem
  65051. */
  65052. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  65053. }
  65054. }
  65055. /**
  65056. * @hidden
  65057. */
  65058. export var _IDoNeedToBeInTheBuild: number;
  65059. }
  65060. declare module "babylonjs/Particles/pointsCloudSystem" {
  65061. import { Color4 } from "babylonjs/Maths/math";
  65062. import { Mesh } from "babylonjs/Meshes/mesh";
  65063. import { Scene, IDisposable } from "babylonjs/scene";
  65064. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  65065. /** Defines the 4 color options */
  65066. export enum PointColor {
  65067. /** color value */
  65068. Color = 2,
  65069. /** uv value */
  65070. UV = 1,
  65071. /** random value */
  65072. Random = 0,
  65073. /** stated value */
  65074. Stated = 3
  65075. }
  65076. /**
  65077. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  65078. * 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.
  65079. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  65080. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  65081. *
  65082. * Full documentation here : TO BE ENTERED
  65083. */
  65084. export class PointsCloudSystem implements IDisposable {
  65085. /**
  65086. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  65087. * Example : var p = SPS.particles[i];
  65088. */
  65089. particles: CloudPoint[];
  65090. /**
  65091. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  65092. */
  65093. nbParticles: number;
  65094. /**
  65095. * This a counter for your own usage. It's not set by any SPS functions.
  65096. */
  65097. counter: number;
  65098. /**
  65099. * The PCS name. This name is also given to the underlying mesh.
  65100. */
  65101. name: string;
  65102. /**
  65103. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  65104. */
  65105. mesh: Mesh;
  65106. /**
  65107. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  65108. * Please read :
  65109. */
  65110. vars: any;
  65111. /**
  65112. * @hidden
  65113. */
  65114. _size: number;
  65115. private _scene;
  65116. private _promises;
  65117. private _positions;
  65118. private _indices;
  65119. private _normals;
  65120. private _colors;
  65121. private _uvs;
  65122. private _indices32;
  65123. private _positions32;
  65124. private _colors32;
  65125. private _uvs32;
  65126. private _updatable;
  65127. private _isVisibilityBoxLocked;
  65128. private _alwaysVisible;
  65129. private _groups;
  65130. private _groupCounter;
  65131. private _computeParticleColor;
  65132. private _computeParticleTexture;
  65133. private _computeParticleRotation;
  65134. private _computeBoundingBox;
  65135. private _isReady;
  65136. /**
  65137. * Creates a PCS (Points Cloud System) object
  65138. * @param name (String) is the PCS name, this will be the underlying mesh name
  65139. * @param pointSize (number) is the size for each point
  65140. * @param scene (Scene) is the scene in which the PCS is added
  65141. * @param options defines the options of the PCS e.g.
  65142. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  65143. */
  65144. constructor(name: string, pointSize: number, scene: Scene, options?: {
  65145. updatable?: boolean;
  65146. });
  65147. /**
  65148. * Builds the PCS underlying mesh. Returns a standard Mesh.
  65149. * If no points were added to the PCS, the returned mesh is just a single point.
  65150. * @returns a promise for the created mesh
  65151. */
  65152. buildMeshAsync(): Promise<Mesh>;
  65153. /**
  65154. * @hidden
  65155. */
  65156. private _buildMesh;
  65157. private _addParticle;
  65158. private _randomUnitVector;
  65159. private _getColorIndicesForCoord;
  65160. private _setPointsColorOrUV;
  65161. private _colorFromTexture;
  65162. private _calculateDensity;
  65163. /**
  65164. * Adds points to the PCS in random positions within a unit sphere
  65165. * @param nb (positive integer) the number of particles to be created from this model
  65166. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  65167. * @returns the number of groups in the system
  65168. */
  65169. addPoints(nb: number, pointFunction?: any): number;
  65170. /**
  65171. * Adds points to the PCS from the surface of the model shape
  65172. * @param mesh is any Mesh object that will be used as a surface model for the points
  65173. * @param nb (positive integer) the number of particles to be created from this model
  65174. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65175. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65176. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65177. * @returns the number of groups in the system
  65178. */
  65179. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65180. /**
  65181. * Adds points to the PCS inside the model shape
  65182. * @param mesh is any Mesh object that will be used as a surface model for the points
  65183. * @param nb (positive integer) the number of particles to be created from this model
  65184. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65185. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65186. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65187. * @returns the number of groups in the system
  65188. */
  65189. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65190. /**
  65191. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  65192. * This method calls `updateParticle()` for each particle of the SPS.
  65193. * For an animated SPS, it is usually called within the render loop.
  65194. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  65195. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  65196. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  65197. * @returns the PCS.
  65198. */
  65199. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  65200. /**
  65201. * Disposes the PCS.
  65202. */
  65203. dispose(): void;
  65204. /**
  65205. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  65206. * doc :
  65207. * @returns the PCS.
  65208. */
  65209. refreshVisibleSize(): PointsCloudSystem;
  65210. /**
  65211. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  65212. * @param size the size (float) of the visibility box
  65213. * note : this doesn't lock the PCS mesh bounding box.
  65214. * doc :
  65215. */
  65216. setVisibilityBox(size: number): void;
  65217. /**
  65218. * Gets whether the PCS is always visible or not
  65219. * doc :
  65220. */
  65221. get isAlwaysVisible(): boolean;
  65222. /**
  65223. * Sets the PCS as always visible or not
  65224. * doc :
  65225. */
  65226. set isAlwaysVisible(val: boolean);
  65227. /**
  65228. * Tells to `setParticles()` to compute the particle rotations or not
  65229. * Default value : false. The PCS is faster when it's set to false
  65230. * Note : particle rotations are only applied to parent particles
  65231. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  65232. */
  65233. set computeParticleRotation(val: boolean);
  65234. /**
  65235. * Tells to `setParticles()` to compute the particle colors or not.
  65236. * Default value : true. The PCS is faster when it's set to false.
  65237. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65238. */
  65239. set computeParticleColor(val: boolean);
  65240. set computeParticleTexture(val: boolean);
  65241. /**
  65242. * Gets if `setParticles()` computes the particle colors or not.
  65243. * Default value : false. The PCS is faster when it's set to false.
  65244. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65245. */
  65246. get computeParticleColor(): boolean;
  65247. /**
  65248. * Gets if `setParticles()` computes the particle textures or not.
  65249. * Default value : false. The PCS is faster when it's set to false.
  65250. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  65251. */
  65252. get computeParticleTexture(): boolean;
  65253. /**
  65254. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  65255. */
  65256. set computeBoundingBox(val: boolean);
  65257. /**
  65258. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  65259. */
  65260. get computeBoundingBox(): boolean;
  65261. /**
  65262. * This function does nothing. It may be overwritten to set all the particle first values.
  65263. * The PCS doesn't call this function, you may have to call it by your own.
  65264. * doc :
  65265. */
  65266. initParticles(): void;
  65267. /**
  65268. * This function does nothing. It may be overwritten to recycle a particle
  65269. * The PCS doesn't call this function, you can to call it
  65270. * doc :
  65271. * @param particle The particle to recycle
  65272. * @returns the recycled particle
  65273. */
  65274. recycleParticle(particle: CloudPoint): CloudPoint;
  65275. /**
  65276. * Updates a particle : this function should be overwritten by the user.
  65277. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  65278. * doc :
  65279. * @example : just set a particle position or velocity and recycle conditions
  65280. * @param particle The particle to update
  65281. * @returns the updated particle
  65282. */
  65283. updateParticle(particle: CloudPoint): CloudPoint;
  65284. /**
  65285. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  65286. * This does nothing and may be overwritten by the user.
  65287. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65288. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65289. * @param update the boolean update value actually passed to setParticles()
  65290. */
  65291. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65292. /**
  65293. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  65294. * This will be passed three parameters.
  65295. * This does nothing and may be overwritten by the user.
  65296. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65297. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65298. * @param update the boolean update value actually passed to setParticles()
  65299. */
  65300. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65301. }
  65302. }
  65303. declare module "babylonjs/Particles/cloudPoint" {
  65304. import { Nullable } from "babylonjs/types";
  65305. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  65306. import { Mesh } from "babylonjs/Meshes/mesh";
  65307. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  65308. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  65309. /**
  65310. * Represents one particle of a points cloud system.
  65311. */
  65312. export class CloudPoint {
  65313. /**
  65314. * particle global index
  65315. */
  65316. idx: number;
  65317. /**
  65318. * The color of the particle
  65319. */
  65320. color: Nullable<Color4>;
  65321. /**
  65322. * The world space position of the particle.
  65323. */
  65324. position: Vector3;
  65325. /**
  65326. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  65327. */
  65328. rotation: Vector3;
  65329. /**
  65330. * The world space rotation quaternion of the particle.
  65331. */
  65332. rotationQuaternion: Nullable<Quaternion>;
  65333. /**
  65334. * The uv of the particle.
  65335. */
  65336. uv: Nullable<Vector2>;
  65337. /**
  65338. * The current speed of the particle.
  65339. */
  65340. velocity: Vector3;
  65341. /**
  65342. * The pivot point in the particle local space.
  65343. */
  65344. pivot: Vector3;
  65345. /**
  65346. * Must the particle be translated from its pivot point in its local space ?
  65347. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  65348. * Default : false
  65349. */
  65350. translateFromPivot: boolean;
  65351. /**
  65352. * Index of this particle in the global "positions" array (Internal use)
  65353. * @hidden
  65354. */
  65355. _pos: number;
  65356. /**
  65357. * @hidden Index of this particle in the global "indices" array (Internal use)
  65358. */
  65359. _ind: number;
  65360. /**
  65361. * Group this particle belongs to
  65362. */
  65363. _group: PointsGroup;
  65364. /**
  65365. * Group id of this particle
  65366. */
  65367. groupId: number;
  65368. /**
  65369. * Index of the particle in its group id (Internal use)
  65370. */
  65371. idxInGroup: number;
  65372. /**
  65373. * @hidden Particle BoundingInfo object (Internal use)
  65374. */
  65375. _boundingInfo: BoundingInfo;
  65376. /**
  65377. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  65378. */
  65379. _pcs: PointsCloudSystem;
  65380. /**
  65381. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  65382. */
  65383. _stillInvisible: boolean;
  65384. /**
  65385. * @hidden Last computed particle rotation matrix
  65386. */
  65387. _rotationMatrix: number[];
  65388. /**
  65389. * Parent particle Id, if any.
  65390. * Default null.
  65391. */
  65392. parentId: Nullable<number>;
  65393. /**
  65394. * @hidden Internal global position in the PCS.
  65395. */
  65396. _globalPosition: Vector3;
  65397. /**
  65398. * Creates a Point Cloud object.
  65399. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  65400. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  65401. * @param group (PointsGroup) is the group the particle belongs to
  65402. * @param groupId (integer) is the group identifier in the PCS.
  65403. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  65404. * @param pcs defines the PCS it is associated to
  65405. */
  65406. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  65407. /**
  65408. * get point size
  65409. */
  65410. get size(): Vector3;
  65411. /**
  65412. * Set point size
  65413. */
  65414. set size(scale: Vector3);
  65415. /**
  65416. * Legacy support, changed quaternion to rotationQuaternion
  65417. */
  65418. get quaternion(): Nullable<Quaternion>;
  65419. /**
  65420. * Legacy support, changed quaternion to rotationQuaternion
  65421. */
  65422. set quaternion(q: Nullable<Quaternion>);
  65423. /**
  65424. * Returns a boolean. True if the particle intersects a mesh, else false
  65425. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  65426. * @param target is the object (point or mesh) what the intersection is computed against
  65427. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  65428. * @returns true if it intersects
  65429. */
  65430. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  65431. /**
  65432. * get the rotation matrix of the particle
  65433. * @hidden
  65434. */
  65435. getRotationMatrix(m: Matrix): void;
  65436. }
  65437. /**
  65438. * Represents a group of points in a points cloud system
  65439. * * PCS internal tool, don't use it manually.
  65440. */
  65441. export class PointsGroup {
  65442. /**
  65443. * The group id
  65444. * @hidden
  65445. */
  65446. groupID: number;
  65447. /**
  65448. * image data for group (internal use)
  65449. * @hidden
  65450. */
  65451. _groupImageData: Nullable<ArrayBufferView>;
  65452. /**
  65453. * Image Width (internal use)
  65454. * @hidden
  65455. */
  65456. _groupImgWidth: number;
  65457. /**
  65458. * Image Height (internal use)
  65459. * @hidden
  65460. */
  65461. _groupImgHeight: number;
  65462. /**
  65463. * Custom position function (internal use)
  65464. * @hidden
  65465. */
  65466. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  65467. /**
  65468. * density per facet for surface points
  65469. * @hidden
  65470. */
  65471. _groupDensity: number[];
  65472. /**
  65473. * Only when points are colored by texture carries pointer to texture list array
  65474. * @hidden
  65475. */
  65476. _textureNb: number;
  65477. /**
  65478. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  65479. * PCS internal tool, don't use it manually.
  65480. * @hidden
  65481. */
  65482. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  65483. }
  65484. }
  65485. declare module "babylonjs/Particles/index" {
  65486. export * from "babylonjs/Particles/baseParticleSystem";
  65487. export * from "babylonjs/Particles/EmitterTypes/index";
  65488. export * from "babylonjs/Particles/gpuParticleSystem";
  65489. export * from "babylonjs/Particles/IParticleSystem";
  65490. export * from "babylonjs/Particles/particle";
  65491. export * from "babylonjs/Particles/particleHelper";
  65492. export * from "babylonjs/Particles/particleSystem";
  65493. export * from "babylonjs/Particles/particleSystemComponent";
  65494. export * from "babylonjs/Particles/particleSystemSet";
  65495. export * from "babylonjs/Particles/solidParticle";
  65496. export * from "babylonjs/Particles/solidParticleSystem";
  65497. export * from "babylonjs/Particles/cloudPoint";
  65498. export * from "babylonjs/Particles/pointsCloudSystem";
  65499. export * from "babylonjs/Particles/subEmitter";
  65500. }
  65501. declare module "babylonjs/Physics/physicsEngineComponent" {
  65502. import { Nullable } from "babylonjs/types";
  65503. import { Observable, Observer } from "babylonjs/Misc/observable";
  65504. import { Vector3 } from "babylonjs/Maths/math.vector";
  65505. import { Mesh } from "babylonjs/Meshes/mesh";
  65506. import { ISceneComponent } from "babylonjs/sceneComponent";
  65507. import { Scene } from "babylonjs/scene";
  65508. import { Node } from "babylonjs/node";
  65509. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  65510. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65511. module "babylonjs/scene" {
  65512. interface Scene {
  65513. /** @hidden (Backing field) */
  65514. _physicsEngine: Nullable<IPhysicsEngine>;
  65515. /** @hidden */
  65516. _physicsTimeAccumulator: number;
  65517. /**
  65518. * Gets the current physics engine
  65519. * @returns a IPhysicsEngine or null if none attached
  65520. */
  65521. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  65522. /**
  65523. * Enables physics to the current scene
  65524. * @param gravity defines the scene's gravity for the physics engine
  65525. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  65526. * @return a boolean indicating if the physics engine was initialized
  65527. */
  65528. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  65529. /**
  65530. * Disables and disposes the physics engine associated with the scene
  65531. */
  65532. disablePhysicsEngine(): void;
  65533. /**
  65534. * Gets a boolean indicating if there is an active physics engine
  65535. * @returns a boolean indicating if there is an active physics engine
  65536. */
  65537. isPhysicsEnabled(): boolean;
  65538. /**
  65539. * Deletes a physics compound impostor
  65540. * @param compound defines the compound to delete
  65541. */
  65542. deleteCompoundImpostor(compound: any): void;
  65543. /**
  65544. * An event triggered when physic simulation is about to be run
  65545. */
  65546. onBeforePhysicsObservable: Observable<Scene>;
  65547. /**
  65548. * An event triggered when physic simulation has been done
  65549. */
  65550. onAfterPhysicsObservable: Observable<Scene>;
  65551. }
  65552. }
  65553. module "babylonjs/Meshes/abstractMesh" {
  65554. interface AbstractMesh {
  65555. /** @hidden */
  65556. _physicsImpostor: Nullable<PhysicsImpostor>;
  65557. /**
  65558. * Gets or sets impostor used for physic simulation
  65559. * @see http://doc.babylonjs.com/features/physics_engine
  65560. */
  65561. physicsImpostor: Nullable<PhysicsImpostor>;
  65562. /**
  65563. * Gets the current physics impostor
  65564. * @see http://doc.babylonjs.com/features/physics_engine
  65565. * @returns a physics impostor or null
  65566. */
  65567. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  65568. /** Apply a physic impulse to the mesh
  65569. * @param force defines the force to apply
  65570. * @param contactPoint defines where to apply the force
  65571. * @returns the current mesh
  65572. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  65573. */
  65574. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  65575. /**
  65576. * Creates a physic joint between two meshes
  65577. * @param otherMesh defines the other mesh to use
  65578. * @param pivot1 defines the pivot to use on this mesh
  65579. * @param pivot2 defines the pivot to use on the other mesh
  65580. * @param options defines additional options (can be plugin dependent)
  65581. * @returns the current mesh
  65582. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  65583. */
  65584. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  65585. /** @hidden */
  65586. _disposePhysicsObserver: Nullable<Observer<Node>>;
  65587. }
  65588. }
  65589. /**
  65590. * Defines the physics engine scene component responsible to manage a physics engine
  65591. */
  65592. export class PhysicsEngineSceneComponent implements ISceneComponent {
  65593. /**
  65594. * The component name helpful to identify the component in the list of scene components.
  65595. */
  65596. readonly name: string;
  65597. /**
  65598. * The scene the component belongs to.
  65599. */
  65600. scene: Scene;
  65601. /**
  65602. * Creates a new instance of the component for the given scene
  65603. * @param scene Defines the scene to register the component in
  65604. */
  65605. constructor(scene: Scene);
  65606. /**
  65607. * Registers the component in a given scene
  65608. */
  65609. register(): void;
  65610. /**
  65611. * Rebuilds the elements related to this component in case of
  65612. * context lost for instance.
  65613. */
  65614. rebuild(): void;
  65615. /**
  65616. * Disposes the component and the associated ressources
  65617. */
  65618. dispose(): void;
  65619. }
  65620. }
  65621. declare module "babylonjs/Physics/physicsHelper" {
  65622. import { Nullable } from "babylonjs/types";
  65623. import { Vector3 } from "babylonjs/Maths/math.vector";
  65624. import { Mesh } from "babylonjs/Meshes/mesh";
  65625. import { Scene } from "babylonjs/scene";
  65626. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65627. /**
  65628. * A helper for physics simulations
  65629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65630. */
  65631. export class PhysicsHelper {
  65632. private _scene;
  65633. private _physicsEngine;
  65634. /**
  65635. * Initializes the Physics helper
  65636. * @param scene Babylon.js scene
  65637. */
  65638. constructor(scene: Scene);
  65639. /**
  65640. * Applies a radial explosion impulse
  65641. * @param origin the origin of the explosion
  65642. * @param radiusOrEventOptions the radius or the options of radial explosion
  65643. * @param strength the explosion strength
  65644. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65645. * @returns A physics radial explosion event, or null
  65646. */
  65647. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65648. /**
  65649. * Applies a radial explosion force
  65650. * @param origin the origin of the explosion
  65651. * @param radiusOrEventOptions the radius or the options of radial explosion
  65652. * @param strength the explosion strength
  65653. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65654. * @returns A physics radial explosion event, or null
  65655. */
  65656. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65657. /**
  65658. * Creates a gravitational field
  65659. * @param origin the origin of the explosion
  65660. * @param radiusOrEventOptions the radius or the options of radial explosion
  65661. * @param strength the explosion strength
  65662. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65663. * @returns A physics gravitational field event, or null
  65664. */
  65665. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  65666. /**
  65667. * Creates a physics updraft event
  65668. * @param origin the origin of the updraft
  65669. * @param radiusOrEventOptions the radius or the options of the updraft
  65670. * @param strength the strength of the updraft
  65671. * @param height the height of the updraft
  65672. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  65673. * @returns A physics updraft event, or null
  65674. */
  65675. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  65676. /**
  65677. * Creates a physics vortex event
  65678. * @param origin the of the vortex
  65679. * @param radiusOrEventOptions the radius or the options of the vortex
  65680. * @param strength the strength of the vortex
  65681. * @param height the height of the vortex
  65682. * @returns a Physics vortex event, or null
  65683. * A physics vortex event or null
  65684. */
  65685. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  65686. }
  65687. /**
  65688. * Represents a physics radial explosion event
  65689. */
  65690. class PhysicsRadialExplosionEvent {
  65691. private _scene;
  65692. private _options;
  65693. private _sphere;
  65694. private _dataFetched;
  65695. /**
  65696. * Initializes a radial explosioin event
  65697. * @param _scene BabylonJS scene
  65698. * @param _options The options for the vortex event
  65699. */
  65700. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  65701. /**
  65702. * Returns the data related to the radial explosion event (sphere).
  65703. * @returns The radial explosion event data
  65704. */
  65705. getData(): PhysicsRadialExplosionEventData;
  65706. /**
  65707. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  65708. * @param impostor A physics imposter
  65709. * @param origin the origin of the explosion
  65710. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  65711. */
  65712. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  65713. /**
  65714. * Triggers affecterd impostors callbacks
  65715. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  65716. */
  65717. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  65718. /**
  65719. * Disposes the sphere.
  65720. * @param force Specifies if the sphere should be disposed by force
  65721. */
  65722. dispose(force?: boolean): void;
  65723. /*** Helpers ***/
  65724. private _prepareSphere;
  65725. private _intersectsWithSphere;
  65726. }
  65727. /**
  65728. * Represents a gravitational field event
  65729. */
  65730. class PhysicsGravitationalFieldEvent {
  65731. private _physicsHelper;
  65732. private _scene;
  65733. private _origin;
  65734. private _options;
  65735. private _tickCallback;
  65736. private _sphere;
  65737. private _dataFetched;
  65738. /**
  65739. * Initializes the physics gravitational field event
  65740. * @param _physicsHelper A physics helper
  65741. * @param _scene BabylonJS scene
  65742. * @param _origin The origin position of the gravitational field event
  65743. * @param _options The options for the vortex event
  65744. */
  65745. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  65746. /**
  65747. * Returns the data related to the gravitational field event (sphere).
  65748. * @returns A gravitational field event
  65749. */
  65750. getData(): PhysicsGravitationalFieldEventData;
  65751. /**
  65752. * Enables the gravitational field.
  65753. */
  65754. enable(): void;
  65755. /**
  65756. * Disables the gravitational field.
  65757. */
  65758. disable(): void;
  65759. /**
  65760. * Disposes the sphere.
  65761. * @param force The force to dispose from the gravitational field event
  65762. */
  65763. dispose(force?: boolean): void;
  65764. private _tick;
  65765. }
  65766. /**
  65767. * Represents a physics updraft event
  65768. */
  65769. class PhysicsUpdraftEvent {
  65770. private _scene;
  65771. private _origin;
  65772. private _options;
  65773. private _physicsEngine;
  65774. private _originTop;
  65775. private _originDirection;
  65776. private _tickCallback;
  65777. private _cylinder;
  65778. private _cylinderPosition;
  65779. private _dataFetched;
  65780. /**
  65781. * Initializes the physics updraft event
  65782. * @param _scene BabylonJS scene
  65783. * @param _origin The origin position of the updraft
  65784. * @param _options The options for the updraft event
  65785. */
  65786. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  65787. /**
  65788. * Returns the data related to the updraft event (cylinder).
  65789. * @returns A physics updraft event
  65790. */
  65791. getData(): PhysicsUpdraftEventData;
  65792. /**
  65793. * Enables the updraft.
  65794. */
  65795. enable(): void;
  65796. /**
  65797. * Disables the updraft.
  65798. */
  65799. disable(): void;
  65800. /**
  65801. * Disposes the cylinder.
  65802. * @param force Specifies if the updraft should be disposed by force
  65803. */
  65804. dispose(force?: boolean): void;
  65805. private getImpostorHitData;
  65806. private _tick;
  65807. /*** Helpers ***/
  65808. private _prepareCylinder;
  65809. private _intersectsWithCylinder;
  65810. }
  65811. /**
  65812. * Represents a physics vortex event
  65813. */
  65814. class PhysicsVortexEvent {
  65815. private _scene;
  65816. private _origin;
  65817. private _options;
  65818. private _physicsEngine;
  65819. private _originTop;
  65820. private _tickCallback;
  65821. private _cylinder;
  65822. private _cylinderPosition;
  65823. private _dataFetched;
  65824. /**
  65825. * Initializes the physics vortex event
  65826. * @param _scene The BabylonJS scene
  65827. * @param _origin The origin position of the vortex
  65828. * @param _options The options for the vortex event
  65829. */
  65830. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65831. /**
  65832. * Returns the data related to the vortex event (cylinder).
  65833. * @returns The physics vortex event data
  65834. */
  65835. getData(): PhysicsVortexEventData;
  65836. /**
  65837. * Enables the vortex.
  65838. */
  65839. enable(): void;
  65840. /**
  65841. * Disables the cortex.
  65842. */
  65843. disable(): void;
  65844. /**
  65845. * Disposes the sphere.
  65846. * @param force
  65847. */
  65848. dispose(force?: boolean): void;
  65849. private getImpostorHitData;
  65850. private _tick;
  65851. /*** Helpers ***/
  65852. private _prepareCylinder;
  65853. private _intersectsWithCylinder;
  65854. }
  65855. /**
  65856. * Options fot the radial explosion event
  65857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65858. */
  65859. export class PhysicsRadialExplosionEventOptions {
  65860. /**
  65861. * The radius of the sphere for the radial explosion.
  65862. */
  65863. radius: number;
  65864. /**
  65865. * The strenth of the explosion.
  65866. */
  65867. strength: number;
  65868. /**
  65869. * The strenght of the force in correspondence to the distance of the affected object
  65870. */
  65871. falloff: PhysicsRadialImpulseFalloff;
  65872. /**
  65873. * Sphere options for the radial explosion.
  65874. */
  65875. sphere: {
  65876. segments: number;
  65877. diameter: number;
  65878. };
  65879. /**
  65880. * Sphere options for the radial explosion.
  65881. */
  65882. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65883. }
  65884. /**
  65885. * Options fot the updraft event
  65886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65887. */
  65888. export class PhysicsUpdraftEventOptions {
  65889. /**
  65890. * The radius of the cylinder for the vortex
  65891. */
  65892. radius: number;
  65893. /**
  65894. * The strenth of the updraft.
  65895. */
  65896. strength: number;
  65897. /**
  65898. * The height of the cylinder for the updraft.
  65899. */
  65900. height: number;
  65901. /**
  65902. * The mode for the the updraft.
  65903. */
  65904. updraftMode: PhysicsUpdraftMode;
  65905. }
  65906. /**
  65907. * Options fot the vortex event
  65908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65909. */
  65910. export class PhysicsVortexEventOptions {
  65911. /**
  65912. * The radius of the cylinder for the vortex
  65913. */
  65914. radius: number;
  65915. /**
  65916. * The strenth of the vortex.
  65917. */
  65918. strength: number;
  65919. /**
  65920. * The height of the cylinder for the vortex.
  65921. */
  65922. height: number;
  65923. /**
  65924. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65925. */
  65926. centripetalForceThreshold: number;
  65927. /**
  65928. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65929. */
  65930. centripetalForceMultiplier: number;
  65931. /**
  65932. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65933. */
  65934. centrifugalForceMultiplier: number;
  65935. /**
  65936. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65937. */
  65938. updraftForceMultiplier: number;
  65939. }
  65940. /**
  65941. * The strenght of the force in correspondence to the distance of the affected object
  65942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65943. */
  65944. export enum PhysicsRadialImpulseFalloff {
  65945. /** Defines that impulse is constant in strength across it's whole radius */
  65946. Constant = 0,
  65947. /** Defines that impulse gets weaker if it's further from the origin */
  65948. Linear = 1
  65949. }
  65950. /**
  65951. * The strength of the force in correspondence to the distance of the affected object
  65952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65953. */
  65954. export enum PhysicsUpdraftMode {
  65955. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65956. Center = 0,
  65957. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65958. Perpendicular = 1
  65959. }
  65960. /**
  65961. * Interface for a physics hit data
  65962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65963. */
  65964. export interface PhysicsHitData {
  65965. /**
  65966. * The force applied at the contact point
  65967. */
  65968. force: Vector3;
  65969. /**
  65970. * The contact point
  65971. */
  65972. contactPoint: Vector3;
  65973. /**
  65974. * The distance from the origin to the contact point
  65975. */
  65976. distanceFromOrigin: number;
  65977. }
  65978. /**
  65979. * Interface for radial explosion event data
  65980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65981. */
  65982. export interface PhysicsRadialExplosionEventData {
  65983. /**
  65984. * A sphere used for the radial explosion event
  65985. */
  65986. sphere: Mesh;
  65987. }
  65988. /**
  65989. * Interface for gravitational field event data
  65990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65991. */
  65992. export interface PhysicsGravitationalFieldEventData {
  65993. /**
  65994. * A sphere mesh used for the gravitational field event
  65995. */
  65996. sphere: Mesh;
  65997. }
  65998. /**
  65999. * Interface for updraft event data
  66000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66001. */
  66002. export interface PhysicsUpdraftEventData {
  66003. /**
  66004. * A cylinder used for the updraft event
  66005. */
  66006. cylinder: Mesh;
  66007. }
  66008. /**
  66009. * Interface for vortex event data
  66010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66011. */
  66012. export interface PhysicsVortexEventData {
  66013. /**
  66014. * A cylinder used for the vortex event
  66015. */
  66016. cylinder: Mesh;
  66017. }
  66018. /**
  66019. * Interface for an affected physics impostor
  66020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66021. */
  66022. export interface PhysicsAffectedImpostorWithData {
  66023. /**
  66024. * The impostor affected by the effect
  66025. */
  66026. impostor: PhysicsImpostor;
  66027. /**
  66028. * The data about the hit/horce from the explosion
  66029. */
  66030. hitData: PhysicsHitData;
  66031. }
  66032. }
  66033. declare module "babylonjs/Physics/Plugins/index" {
  66034. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  66035. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  66036. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  66037. }
  66038. declare module "babylonjs/Physics/index" {
  66039. export * from "babylonjs/Physics/IPhysicsEngine";
  66040. export * from "babylonjs/Physics/physicsEngine";
  66041. export * from "babylonjs/Physics/physicsEngineComponent";
  66042. export * from "babylonjs/Physics/physicsHelper";
  66043. export * from "babylonjs/Physics/physicsImpostor";
  66044. export * from "babylonjs/Physics/physicsJoint";
  66045. export * from "babylonjs/Physics/Plugins/index";
  66046. }
  66047. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  66048. /** @hidden */
  66049. export var blackAndWhitePixelShader: {
  66050. name: string;
  66051. shader: string;
  66052. };
  66053. }
  66054. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  66055. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66056. import { Camera } from "babylonjs/Cameras/camera";
  66057. import { Engine } from "babylonjs/Engines/engine";
  66058. import "babylonjs/Shaders/blackAndWhite.fragment";
  66059. /**
  66060. * Post process used to render in black and white
  66061. */
  66062. export class BlackAndWhitePostProcess extends PostProcess {
  66063. /**
  66064. * Linear about to convert he result to black and white (default: 1)
  66065. */
  66066. degree: number;
  66067. /**
  66068. * Creates a black and white post process
  66069. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  66070. * @param name The name of the effect.
  66071. * @param options The required width/height ratio to downsize to before computing the render pass.
  66072. * @param camera The camera to apply the render pass to.
  66073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66074. * @param engine The engine which the post process will be applied. (default: current engine)
  66075. * @param reusable If the post process can be reused on the same frame. (default: false)
  66076. */
  66077. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66078. }
  66079. }
  66080. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  66081. import { Nullable } from "babylonjs/types";
  66082. import { Camera } from "babylonjs/Cameras/camera";
  66083. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66084. import { Engine } from "babylonjs/Engines/engine";
  66085. /**
  66086. * This represents a set of one or more post processes in Babylon.
  66087. * A post process can be used to apply a shader to a texture after it is rendered.
  66088. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66089. */
  66090. export class PostProcessRenderEffect {
  66091. private _postProcesses;
  66092. private _getPostProcesses;
  66093. private _singleInstance;
  66094. private _cameras;
  66095. private _indicesForCamera;
  66096. /**
  66097. * Name of the effect
  66098. * @hidden
  66099. */
  66100. _name: string;
  66101. /**
  66102. * Instantiates a post process render effect.
  66103. * A post process can be used to apply a shader to a texture after it is rendered.
  66104. * @param engine The engine the effect is tied to
  66105. * @param name The name of the effect
  66106. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  66107. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  66108. */
  66109. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  66110. /**
  66111. * Checks if all the post processes in the effect are supported.
  66112. */
  66113. get isSupported(): boolean;
  66114. /**
  66115. * Updates the current state of the effect
  66116. * @hidden
  66117. */
  66118. _update(): void;
  66119. /**
  66120. * Attaches the effect on cameras
  66121. * @param cameras The camera to attach to.
  66122. * @hidden
  66123. */
  66124. _attachCameras(cameras: Camera): void;
  66125. /**
  66126. * Attaches the effect on cameras
  66127. * @param cameras The camera to attach to.
  66128. * @hidden
  66129. */
  66130. _attachCameras(cameras: Camera[]): void;
  66131. /**
  66132. * Detaches the effect on cameras
  66133. * @param cameras The camera to detatch from.
  66134. * @hidden
  66135. */
  66136. _detachCameras(cameras: Camera): void;
  66137. /**
  66138. * Detatches the effect on cameras
  66139. * @param cameras The camera to detatch from.
  66140. * @hidden
  66141. */
  66142. _detachCameras(cameras: Camera[]): void;
  66143. /**
  66144. * Enables the effect on given cameras
  66145. * @param cameras The camera to enable.
  66146. * @hidden
  66147. */
  66148. _enable(cameras: Camera): void;
  66149. /**
  66150. * Enables the effect on given cameras
  66151. * @param cameras The camera to enable.
  66152. * @hidden
  66153. */
  66154. _enable(cameras: Nullable<Camera[]>): void;
  66155. /**
  66156. * Disables the effect on the given cameras
  66157. * @param cameras The camera to disable.
  66158. * @hidden
  66159. */
  66160. _disable(cameras: Camera): void;
  66161. /**
  66162. * Disables the effect on the given cameras
  66163. * @param cameras The camera to disable.
  66164. * @hidden
  66165. */
  66166. _disable(cameras: Nullable<Camera[]>): void;
  66167. /**
  66168. * Gets a list of the post processes contained in the effect.
  66169. * @param camera The camera to get the post processes on.
  66170. * @returns The list of the post processes in the effect.
  66171. */
  66172. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  66173. }
  66174. }
  66175. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  66176. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66177. /** @hidden */
  66178. export var extractHighlightsPixelShader: {
  66179. name: string;
  66180. shader: string;
  66181. };
  66182. }
  66183. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  66184. import { Nullable } from "babylonjs/types";
  66185. import { Camera } from "babylonjs/Cameras/camera";
  66186. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66187. import { Engine } from "babylonjs/Engines/engine";
  66188. import "babylonjs/Shaders/extractHighlights.fragment";
  66189. /**
  66190. * 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.
  66191. */
  66192. export class ExtractHighlightsPostProcess extends PostProcess {
  66193. /**
  66194. * The luminance threshold, pixels below this value will be set to black.
  66195. */
  66196. threshold: number;
  66197. /** @hidden */
  66198. _exposure: number;
  66199. /**
  66200. * Post process which has the input texture to be used when performing highlight extraction
  66201. * @hidden
  66202. */
  66203. _inputPostProcess: Nullable<PostProcess>;
  66204. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66205. }
  66206. }
  66207. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  66208. /** @hidden */
  66209. export var bloomMergePixelShader: {
  66210. name: string;
  66211. shader: string;
  66212. };
  66213. }
  66214. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  66215. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66216. import { Nullable } from "babylonjs/types";
  66217. import { Engine } from "babylonjs/Engines/engine";
  66218. import { Camera } from "babylonjs/Cameras/camera";
  66219. import "babylonjs/Shaders/bloomMerge.fragment";
  66220. /**
  66221. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66222. */
  66223. export class BloomMergePostProcess extends PostProcess {
  66224. /** Weight of the bloom to be added to the original input. */
  66225. weight: number;
  66226. /**
  66227. * Creates a new instance of @see BloomMergePostProcess
  66228. * @param name The name of the effect.
  66229. * @param originalFromInput Post process which's input will be used for the merge.
  66230. * @param blurred Blurred highlights post process which's output will be used.
  66231. * @param weight Weight of the bloom to be added to the original input.
  66232. * @param options The required width/height ratio to downsize to before computing the render pass.
  66233. * @param camera The camera to apply the render pass to.
  66234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66235. * @param engine The engine which the post process will be applied. (default: current engine)
  66236. * @param reusable If the post process can be reused on the same frame. (default: false)
  66237. * @param textureType Type of textures used when performing the post process. (default: 0)
  66238. * @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)
  66239. */
  66240. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  66241. /** Weight of the bloom to be added to the original input. */
  66242. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66243. }
  66244. }
  66245. declare module "babylonjs/PostProcesses/bloomEffect" {
  66246. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66247. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66248. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66249. import { Camera } from "babylonjs/Cameras/camera";
  66250. import { Scene } from "babylonjs/scene";
  66251. /**
  66252. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  66253. */
  66254. export class BloomEffect extends PostProcessRenderEffect {
  66255. private bloomScale;
  66256. /**
  66257. * @hidden Internal
  66258. */
  66259. _effects: Array<PostProcess>;
  66260. /**
  66261. * @hidden Internal
  66262. */
  66263. _downscale: ExtractHighlightsPostProcess;
  66264. private _blurX;
  66265. private _blurY;
  66266. private _merge;
  66267. /**
  66268. * The luminance threshold to find bright areas of the image to bloom.
  66269. */
  66270. get threshold(): number;
  66271. set threshold(value: number);
  66272. /**
  66273. * The strength of the bloom.
  66274. */
  66275. get weight(): number;
  66276. set weight(value: number);
  66277. /**
  66278. * Specifies the size of the bloom blur kernel, relative to the final output size
  66279. */
  66280. get kernel(): number;
  66281. set kernel(value: number);
  66282. /**
  66283. * Creates a new instance of @see BloomEffect
  66284. * @param scene The scene the effect belongs to.
  66285. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  66286. * @param bloomKernel The size of the kernel to be used when applying the blur.
  66287. * @param bloomWeight The the strength of bloom.
  66288. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66289. * @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)
  66290. */
  66291. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  66292. /**
  66293. * Disposes each of the internal effects for a given camera.
  66294. * @param camera The camera to dispose the effect on.
  66295. */
  66296. disposeEffects(camera: Camera): void;
  66297. /**
  66298. * @hidden Internal
  66299. */
  66300. _updateEffects(): void;
  66301. /**
  66302. * Internal
  66303. * @returns if all the contained post processes are ready.
  66304. * @hidden
  66305. */
  66306. _isReady(): boolean;
  66307. }
  66308. }
  66309. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  66310. /** @hidden */
  66311. export var chromaticAberrationPixelShader: {
  66312. name: string;
  66313. shader: string;
  66314. };
  66315. }
  66316. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  66317. import { Vector2 } from "babylonjs/Maths/math.vector";
  66318. import { Nullable } from "babylonjs/types";
  66319. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66320. import { Camera } from "babylonjs/Cameras/camera";
  66321. import { Engine } from "babylonjs/Engines/engine";
  66322. import "babylonjs/Shaders/chromaticAberration.fragment";
  66323. /**
  66324. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  66325. */
  66326. export class ChromaticAberrationPostProcess extends PostProcess {
  66327. /**
  66328. * The amount of seperation of rgb channels (default: 30)
  66329. */
  66330. aberrationAmount: number;
  66331. /**
  66332. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  66333. */
  66334. radialIntensity: number;
  66335. /**
  66336. * 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))
  66337. */
  66338. direction: Vector2;
  66339. /**
  66340. * 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))
  66341. */
  66342. centerPosition: Vector2;
  66343. /**
  66344. * Creates a new instance ChromaticAberrationPostProcess
  66345. * @param name The name of the effect.
  66346. * @param screenWidth The width of the screen to apply the effect on.
  66347. * @param screenHeight The height of the screen to apply the effect on.
  66348. * @param options The required width/height ratio to downsize to before computing the render pass.
  66349. * @param camera The camera to apply the render pass to.
  66350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66351. * @param engine The engine which the post process will be applied. (default: current engine)
  66352. * @param reusable If the post process can be reused on the same frame. (default: false)
  66353. * @param textureType Type of textures used when performing the post process. (default: 0)
  66354. * @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)
  66355. */
  66356. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66357. }
  66358. }
  66359. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  66360. /** @hidden */
  66361. export var circleOfConfusionPixelShader: {
  66362. name: string;
  66363. shader: string;
  66364. };
  66365. }
  66366. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  66367. import { Nullable } from "babylonjs/types";
  66368. import { Engine } from "babylonjs/Engines/engine";
  66369. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66370. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66371. import { Camera } from "babylonjs/Cameras/camera";
  66372. import "babylonjs/Shaders/circleOfConfusion.fragment";
  66373. /**
  66374. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  66375. */
  66376. export class CircleOfConfusionPostProcess extends PostProcess {
  66377. /**
  66378. * 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.
  66379. */
  66380. lensSize: number;
  66381. /**
  66382. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66383. */
  66384. fStop: number;
  66385. /**
  66386. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66387. */
  66388. focusDistance: number;
  66389. /**
  66390. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  66391. */
  66392. focalLength: number;
  66393. private _depthTexture;
  66394. /**
  66395. * Creates a new instance CircleOfConfusionPostProcess
  66396. * @param name The name of the effect.
  66397. * @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.
  66398. * @param options The required width/height ratio to downsize to before computing the render pass.
  66399. * @param camera The camera to apply the render pass to.
  66400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66401. * @param engine The engine which the post process will be applied. (default: current engine)
  66402. * @param reusable If the post process can be reused on the same frame. (default: false)
  66403. * @param textureType Type of textures used when performing the post process. (default: 0)
  66404. * @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)
  66405. */
  66406. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66407. /**
  66408. * 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.
  66409. */
  66410. set depthTexture(value: RenderTargetTexture);
  66411. }
  66412. }
  66413. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  66414. /** @hidden */
  66415. export var colorCorrectionPixelShader: {
  66416. name: string;
  66417. shader: string;
  66418. };
  66419. }
  66420. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  66421. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66422. import { Engine } from "babylonjs/Engines/engine";
  66423. import { Camera } from "babylonjs/Cameras/camera";
  66424. import "babylonjs/Shaders/colorCorrection.fragment";
  66425. /**
  66426. *
  66427. * This post-process allows the modification of rendered colors by using
  66428. * a 'look-up table' (LUT). This effect is also called Color Grading.
  66429. *
  66430. * The object needs to be provided an url to a texture containing the color
  66431. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  66432. * Use an image editing software to tweak the LUT to match your needs.
  66433. *
  66434. * For an example of a color LUT, see here:
  66435. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  66436. * For explanations on color grading, see here:
  66437. * @see http://udn.epicgames.com/Three/ColorGrading.html
  66438. *
  66439. */
  66440. export class ColorCorrectionPostProcess extends PostProcess {
  66441. private _colorTableTexture;
  66442. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66443. }
  66444. }
  66445. declare module "babylonjs/Shaders/convolution.fragment" {
  66446. /** @hidden */
  66447. export var convolutionPixelShader: {
  66448. name: string;
  66449. shader: string;
  66450. };
  66451. }
  66452. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  66453. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66454. import { Nullable } from "babylonjs/types";
  66455. import { Camera } from "babylonjs/Cameras/camera";
  66456. import { Engine } from "babylonjs/Engines/engine";
  66457. import "babylonjs/Shaders/convolution.fragment";
  66458. /**
  66459. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  66460. * input texture to perform effects such as edge detection or sharpening
  66461. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66462. */
  66463. export class ConvolutionPostProcess extends PostProcess {
  66464. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66465. kernel: number[];
  66466. /**
  66467. * Creates a new instance ConvolutionPostProcess
  66468. * @param name The name of the effect.
  66469. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  66470. * @param options The required width/height ratio to downsize to before computing the render pass.
  66471. * @param camera The camera to apply the render pass to.
  66472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66473. * @param engine The engine which the post process will be applied. (default: current engine)
  66474. * @param reusable If the post process can be reused on the same frame. (default: false)
  66475. * @param textureType Type of textures used when performing the post process. (default: 0)
  66476. */
  66477. constructor(name: string,
  66478. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66479. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66480. /**
  66481. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66482. */
  66483. static EdgeDetect0Kernel: number[];
  66484. /**
  66485. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66486. */
  66487. static EdgeDetect1Kernel: number[];
  66488. /**
  66489. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66490. */
  66491. static EdgeDetect2Kernel: number[];
  66492. /**
  66493. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66494. */
  66495. static SharpenKernel: number[];
  66496. /**
  66497. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66498. */
  66499. static EmbossKernel: number[];
  66500. /**
  66501. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66502. */
  66503. static GaussianKernel: number[];
  66504. }
  66505. }
  66506. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  66507. import { Nullable } from "babylonjs/types";
  66508. import { Vector2 } from "babylonjs/Maths/math.vector";
  66509. import { Camera } from "babylonjs/Cameras/camera";
  66510. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66511. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  66512. import { Engine } from "babylonjs/Engines/engine";
  66513. import { Scene } from "babylonjs/scene";
  66514. /**
  66515. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  66516. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  66517. * based on samples that have a large difference in distance than the center pixel.
  66518. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  66519. */
  66520. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  66521. direction: Vector2;
  66522. /**
  66523. * Creates a new instance CircleOfConfusionPostProcess
  66524. * @param name The name of the effect.
  66525. * @param scene The scene the effect belongs to.
  66526. * @param direction The direction the blur should be applied.
  66527. * @param kernel The size of the kernel used to blur.
  66528. * @param options The required width/height ratio to downsize to before computing the render pass.
  66529. * @param camera The camera to apply the render pass to.
  66530. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  66531. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  66532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66533. * @param engine The engine which the post process will be applied. (default: current engine)
  66534. * @param reusable If the post process can be reused on the same frame. (default: false)
  66535. * @param textureType Type of textures used when performing the post process. (default: 0)
  66536. * @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)
  66537. */
  66538. 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);
  66539. }
  66540. }
  66541. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  66542. /** @hidden */
  66543. export var depthOfFieldMergePixelShader: {
  66544. name: string;
  66545. shader: string;
  66546. };
  66547. }
  66548. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  66549. import { Nullable } from "babylonjs/types";
  66550. import { Camera } from "babylonjs/Cameras/camera";
  66551. import { Effect } from "babylonjs/Materials/effect";
  66552. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66553. import { Engine } from "babylonjs/Engines/engine";
  66554. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  66555. /**
  66556. * Options to be set when merging outputs from the default pipeline.
  66557. */
  66558. export class DepthOfFieldMergePostProcessOptions {
  66559. /**
  66560. * The original image to merge on top of
  66561. */
  66562. originalFromInput: PostProcess;
  66563. /**
  66564. * Parameters to perform the merge of the depth of field effect
  66565. */
  66566. depthOfField?: {
  66567. circleOfConfusion: PostProcess;
  66568. blurSteps: Array<PostProcess>;
  66569. };
  66570. /**
  66571. * Parameters to perform the merge of bloom effect
  66572. */
  66573. bloom?: {
  66574. blurred: PostProcess;
  66575. weight: number;
  66576. };
  66577. }
  66578. /**
  66579. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66580. */
  66581. export class DepthOfFieldMergePostProcess extends PostProcess {
  66582. private blurSteps;
  66583. /**
  66584. * Creates a new instance of DepthOfFieldMergePostProcess
  66585. * @param name The name of the effect.
  66586. * @param originalFromInput Post process which's input will be used for the merge.
  66587. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  66588. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  66589. * @param options The required width/height ratio to downsize to before computing the render pass.
  66590. * @param camera The camera to apply the render pass to.
  66591. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66592. * @param engine The engine which the post process will be applied. (default: current engine)
  66593. * @param reusable If the post process can be reused on the same frame. (default: false)
  66594. * @param textureType Type of textures used when performing the post process. (default: 0)
  66595. * @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)
  66596. */
  66597. 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);
  66598. /**
  66599. * Updates the effect with the current post process compile time values and recompiles the shader.
  66600. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66601. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66602. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66603. * @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
  66604. * @param onCompiled Called when the shader has been compiled.
  66605. * @param onError Called if there is an error when compiling a shader.
  66606. */
  66607. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66608. }
  66609. }
  66610. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  66611. import { Nullable } from "babylonjs/types";
  66612. import { Camera } from "babylonjs/Cameras/camera";
  66613. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66614. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66615. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66616. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66617. import { Scene } from "babylonjs/scene";
  66618. /**
  66619. * Specifies the level of max blur that should be applied when using the depth of field effect
  66620. */
  66621. export enum DepthOfFieldEffectBlurLevel {
  66622. /**
  66623. * Subtle blur
  66624. */
  66625. Low = 0,
  66626. /**
  66627. * Medium blur
  66628. */
  66629. Medium = 1,
  66630. /**
  66631. * Large blur
  66632. */
  66633. High = 2
  66634. }
  66635. /**
  66636. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  66637. */
  66638. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  66639. private _circleOfConfusion;
  66640. /**
  66641. * @hidden Internal, blurs from high to low
  66642. */
  66643. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  66644. private _depthOfFieldBlurY;
  66645. private _dofMerge;
  66646. /**
  66647. * @hidden Internal post processes in depth of field effect
  66648. */
  66649. _effects: Array<PostProcess>;
  66650. /**
  66651. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  66652. */
  66653. set focalLength(value: number);
  66654. get focalLength(): number;
  66655. /**
  66656. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66657. */
  66658. set fStop(value: number);
  66659. get fStop(): number;
  66660. /**
  66661. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66662. */
  66663. set focusDistance(value: number);
  66664. get focusDistance(): number;
  66665. /**
  66666. * 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.
  66667. */
  66668. set lensSize(value: number);
  66669. get lensSize(): number;
  66670. /**
  66671. * Creates a new instance DepthOfFieldEffect
  66672. * @param scene The scene the effect belongs to.
  66673. * @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.
  66674. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66675. * @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)
  66676. */
  66677. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  66678. /**
  66679. * Get the current class name of the current effet
  66680. * @returns "DepthOfFieldEffect"
  66681. */
  66682. getClassName(): string;
  66683. /**
  66684. * 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.
  66685. */
  66686. set depthTexture(value: RenderTargetTexture);
  66687. /**
  66688. * Disposes each of the internal effects for a given camera.
  66689. * @param camera The camera to dispose the effect on.
  66690. */
  66691. disposeEffects(camera: Camera): void;
  66692. /**
  66693. * @hidden Internal
  66694. */
  66695. _updateEffects(): void;
  66696. /**
  66697. * Internal
  66698. * @returns if all the contained post processes are ready.
  66699. * @hidden
  66700. */
  66701. _isReady(): boolean;
  66702. }
  66703. }
  66704. declare module "babylonjs/Shaders/displayPass.fragment" {
  66705. /** @hidden */
  66706. export var displayPassPixelShader: {
  66707. name: string;
  66708. shader: string;
  66709. };
  66710. }
  66711. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  66712. import { Nullable } from "babylonjs/types";
  66713. import { Camera } from "babylonjs/Cameras/camera";
  66714. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66715. import { Engine } from "babylonjs/Engines/engine";
  66716. import "babylonjs/Shaders/displayPass.fragment";
  66717. /**
  66718. * DisplayPassPostProcess which produces an output the same as it's input
  66719. */
  66720. export class DisplayPassPostProcess extends PostProcess {
  66721. /**
  66722. * Creates the DisplayPassPostProcess
  66723. * @param name The name of the effect.
  66724. * @param options The required width/height ratio to downsize to before computing the render pass.
  66725. * @param camera The camera to apply the render pass to.
  66726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66727. * @param engine The engine which the post process will be applied. (default: current engine)
  66728. * @param reusable If the post process can be reused on the same frame. (default: false)
  66729. */
  66730. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66731. }
  66732. }
  66733. declare module "babylonjs/Shaders/filter.fragment" {
  66734. /** @hidden */
  66735. export var filterPixelShader: {
  66736. name: string;
  66737. shader: string;
  66738. };
  66739. }
  66740. declare module "babylonjs/PostProcesses/filterPostProcess" {
  66741. import { Nullable } from "babylonjs/types";
  66742. import { Matrix } from "babylonjs/Maths/math.vector";
  66743. import { Camera } from "babylonjs/Cameras/camera";
  66744. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66745. import { Engine } from "babylonjs/Engines/engine";
  66746. import "babylonjs/Shaders/filter.fragment";
  66747. /**
  66748. * Applies a kernel filter to the image
  66749. */
  66750. export class FilterPostProcess extends PostProcess {
  66751. /** The matrix to be applied to the image */
  66752. kernelMatrix: Matrix;
  66753. /**
  66754. *
  66755. * @param name The name of the effect.
  66756. * @param kernelMatrix The matrix to be applied to the image
  66757. * @param options The required width/height ratio to downsize to before computing the render pass.
  66758. * @param camera The camera to apply the render pass to.
  66759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66760. * @param engine The engine which the post process will be applied. (default: current engine)
  66761. * @param reusable If the post process can be reused on the same frame. (default: false)
  66762. */
  66763. constructor(name: string,
  66764. /** The matrix to be applied to the image */
  66765. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66766. }
  66767. }
  66768. declare module "babylonjs/Shaders/fxaa.fragment" {
  66769. /** @hidden */
  66770. export var fxaaPixelShader: {
  66771. name: string;
  66772. shader: string;
  66773. };
  66774. }
  66775. declare module "babylonjs/Shaders/fxaa.vertex" {
  66776. /** @hidden */
  66777. export var fxaaVertexShader: {
  66778. name: string;
  66779. shader: string;
  66780. };
  66781. }
  66782. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  66783. import { Nullable } from "babylonjs/types";
  66784. import { Camera } from "babylonjs/Cameras/camera";
  66785. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66786. import { Engine } from "babylonjs/Engines/engine";
  66787. import "babylonjs/Shaders/fxaa.fragment";
  66788. import "babylonjs/Shaders/fxaa.vertex";
  66789. /**
  66790. * Fxaa post process
  66791. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  66792. */
  66793. export class FxaaPostProcess extends PostProcess {
  66794. /** @hidden */
  66795. texelWidth: number;
  66796. /** @hidden */
  66797. texelHeight: number;
  66798. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66799. private _getDefines;
  66800. }
  66801. }
  66802. declare module "babylonjs/Shaders/grain.fragment" {
  66803. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66804. /** @hidden */
  66805. export var grainPixelShader: {
  66806. name: string;
  66807. shader: string;
  66808. };
  66809. }
  66810. declare module "babylonjs/PostProcesses/grainPostProcess" {
  66811. import { Nullable } from "babylonjs/types";
  66812. import { Camera } from "babylonjs/Cameras/camera";
  66813. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66814. import { Engine } from "babylonjs/Engines/engine";
  66815. import "babylonjs/Shaders/grain.fragment";
  66816. /**
  66817. * The GrainPostProcess adds noise to the image at mid luminance levels
  66818. */
  66819. export class GrainPostProcess extends PostProcess {
  66820. /**
  66821. * The intensity of the grain added (default: 30)
  66822. */
  66823. intensity: number;
  66824. /**
  66825. * If the grain should be randomized on every frame
  66826. */
  66827. animated: boolean;
  66828. /**
  66829. * Creates a new instance of @see GrainPostProcess
  66830. * @param name The name of the effect.
  66831. * @param options The required width/height ratio to downsize to before computing the render pass.
  66832. * @param camera The camera to apply the render pass to.
  66833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66834. * @param engine The engine which the post process will be applied. (default: current engine)
  66835. * @param reusable If the post process can be reused on the same frame. (default: false)
  66836. * @param textureType Type of textures used when performing the post process. (default: 0)
  66837. * @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)
  66838. */
  66839. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66840. }
  66841. }
  66842. declare module "babylonjs/Shaders/highlights.fragment" {
  66843. /** @hidden */
  66844. export var highlightsPixelShader: {
  66845. name: string;
  66846. shader: string;
  66847. };
  66848. }
  66849. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  66850. import { Nullable } from "babylonjs/types";
  66851. import { Camera } from "babylonjs/Cameras/camera";
  66852. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66853. import { Engine } from "babylonjs/Engines/engine";
  66854. import "babylonjs/Shaders/highlights.fragment";
  66855. /**
  66856. * Extracts highlights from the image
  66857. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66858. */
  66859. export class HighlightsPostProcess extends PostProcess {
  66860. /**
  66861. * Extracts highlights from the image
  66862. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66863. * @param name The name of the effect.
  66864. * @param options The required width/height ratio to downsize to before computing the render pass.
  66865. * @param camera The camera to apply the render pass to.
  66866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66867. * @param engine The engine which the post process will be applied. (default: current engine)
  66868. * @param reusable If the post process can be reused on the same frame. (default: false)
  66869. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66870. */
  66871. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66872. }
  66873. }
  66874. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  66875. /** @hidden */
  66876. export var mrtFragmentDeclaration: {
  66877. name: string;
  66878. shader: string;
  66879. };
  66880. }
  66881. declare module "babylonjs/Shaders/geometry.fragment" {
  66882. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  66883. /** @hidden */
  66884. export var geometryPixelShader: {
  66885. name: string;
  66886. shader: string;
  66887. };
  66888. }
  66889. declare module "babylonjs/Shaders/geometry.vertex" {
  66890. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66891. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66892. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66893. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66895. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66896. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66897. /** @hidden */
  66898. export var geometryVertexShader: {
  66899. name: string;
  66900. shader: string;
  66901. };
  66902. }
  66903. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  66904. import { Matrix } from "babylonjs/Maths/math.vector";
  66905. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66906. import { Mesh } from "babylonjs/Meshes/mesh";
  66907. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  66908. import { Effect } from "babylonjs/Materials/effect";
  66909. import { Scene } from "babylonjs/scene";
  66910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66911. import "babylonjs/Shaders/geometry.fragment";
  66912. import "babylonjs/Shaders/geometry.vertex";
  66913. /** @hidden */
  66914. interface ISavedTransformationMatrix {
  66915. world: Matrix;
  66916. viewProjection: Matrix;
  66917. }
  66918. /**
  66919. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66920. */
  66921. export class GeometryBufferRenderer {
  66922. /**
  66923. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66924. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66925. */
  66926. static readonly POSITION_TEXTURE_TYPE: number;
  66927. /**
  66928. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66929. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66930. */
  66931. static readonly VELOCITY_TEXTURE_TYPE: number;
  66932. /**
  66933. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66934. * in order to compute objects velocities when enableVelocity is set to "true"
  66935. * @hidden
  66936. */
  66937. _previousTransformationMatrices: {
  66938. [index: number]: ISavedTransformationMatrix;
  66939. };
  66940. /**
  66941. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66942. * in order to compute objects velocities when enableVelocity is set to "true"
  66943. * @hidden
  66944. */
  66945. _previousBonesTransformationMatrices: {
  66946. [index: number]: Float32Array;
  66947. };
  66948. /**
  66949. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66950. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66951. */
  66952. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66953. private _scene;
  66954. private _multiRenderTarget;
  66955. private _ratio;
  66956. private _enablePosition;
  66957. private _enableVelocity;
  66958. private _positionIndex;
  66959. private _velocityIndex;
  66960. protected _effect: Effect;
  66961. protected _cachedDefines: string;
  66962. /**
  66963. * Set the render list (meshes to be rendered) used in the G buffer.
  66964. */
  66965. set renderList(meshes: Mesh[]);
  66966. /**
  66967. * Gets wether or not G buffer are supported by the running hardware.
  66968. * This requires draw buffer supports
  66969. */
  66970. get isSupported(): boolean;
  66971. /**
  66972. * Returns the index of the given texture type in the G-Buffer textures array
  66973. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66974. * @returns the index of the given texture type in the G-Buffer textures array
  66975. */
  66976. getTextureIndex(textureType: number): number;
  66977. /**
  66978. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66979. */
  66980. get enablePosition(): boolean;
  66981. /**
  66982. * Sets whether or not objects positions are enabled for the G buffer.
  66983. */
  66984. set enablePosition(enable: boolean);
  66985. /**
  66986. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66987. */
  66988. get enableVelocity(): boolean;
  66989. /**
  66990. * Sets wether or not objects velocities are enabled for the G buffer.
  66991. */
  66992. set enableVelocity(enable: boolean);
  66993. /**
  66994. * Gets the scene associated with the buffer.
  66995. */
  66996. get scene(): Scene;
  66997. /**
  66998. * Gets the ratio used by the buffer during its creation.
  66999. * How big is the buffer related to the main canvas.
  67000. */
  67001. get ratio(): number;
  67002. /** @hidden */
  67003. static _SceneComponentInitialization: (scene: Scene) => void;
  67004. /**
  67005. * Creates a new G Buffer for the scene
  67006. * @param scene The scene the buffer belongs to
  67007. * @param ratio How big is the buffer related to the main canvas.
  67008. */
  67009. constructor(scene: Scene, ratio?: number);
  67010. /**
  67011. * Checks wether everything is ready to render a submesh to the G buffer.
  67012. * @param subMesh the submesh to check readiness for
  67013. * @param useInstances is the mesh drawn using instance or not
  67014. * @returns true if ready otherwise false
  67015. */
  67016. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67017. /**
  67018. * Gets the current underlying G Buffer.
  67019. * @returns the buffer
  67020. */
  67021. getGBuffer(): MultiRenderTarget;
  67022. /**
  67023. * Gets the number of samples used to render the buffer (anti aliasing).
  67024. */
  67025. get samples(): number;
  67026. /**
  67027. * Sets the number of samples used to render the buffer (anti aliasing).
  67028. */
  67029. set samples(value: number);
  67030. /**
  67031. * Disposes the renderer and frees up associated resources.
  67032. */
  67033. dispose(): void;
  67034. protected _createRenderTargets(): void;
  67035. private _copyBonesTransformationMatrices;
  67036. }
  67037. }
  67038. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  67039. import { Nullable } from "babylonjs/types";
  67040. import { Scene } from "babylonjs/scene";
  67041. import { ISceneComponent } from "babylonjs/sceneComponent";
  67042. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  67043. module "babylonjs/scene" {
  67044. interface Scene {
  67045. /** @hidden (Backing field) */
  67046. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67047. /**
  67048. * Gets or Sets the current geometry buffer associated to the scene.
  67049. */
  67050. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67051. /**
  67052. * Enables a GeometryBufferRender and associates it with the scene
  67053. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67054. * @returns the GeometryBufferRenderer
  67055. */
  67056. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67057. /**
  67058. * Disables the GeometryBufferRender associated with the scene
  67059. */
  67060. disableGeometryBufferRenderer(): void;
  67061. }
  67062. }
  67063. /**
  67064. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67065. * in several rendering techniques.
  67066. */
  67067. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67068. /**
  67069. * The component name helpful to identify the component in the list of scene components.
  67070. */
  67071. readonly name: string;
  67072. /**
  67073. * The scene the component belongs to.
  67074. */
  67075. scene: Scene;
  67076. /**
  67077. * Creates a new instance of the component for the given scene
  67078. * @param scene Defines the scene to register the component in
  67079. */
  67080. constructor(scene: Scene);
  67081. /**
  67082. * Registers the component in a given scene
  67083. */
  67084. register(): void;
  67085. /**
  67086. * Rebuilds the elements related to this component in case of
  67087. * context lost for instance.
  67088. */
  67089. rebuild(): void;
  67090. /**
  67091. * Disposes the component and the associated ressources
  67092. */
  67093. dispose(): void;
  67094. private _gatherRenderTargets;
  67095. }
  67096. }
  67097. declare module "babylonjs/Shaders/motionBlur.fragment" {
  67098. /** @hidden */
  67099. export var motionBlurPixelShader: {
  67100. name: string;
  67101. shader: string;
  67102. };
  67103. }
  67104. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  67105. import { Nullable } from "babylonjs/types";
  67106. import { Camera } from "babylonjs/Cameras/camera";
  67107. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67108. import { Scene } from "babylonjs/scene";
  67109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67110. import "babylonjs/Animations/animatable";
  67111. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  67112. import "babylonjs/Shaders/motionBlur.fragment";
  67113. import { Engine } from "babylonjs/Engines/engine";
  67114. /**
  67115. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67116. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67117. * As an example, all you have to do is to create the post-process:
  67118. * var mb = new BABYLON.MotionBlurPostProcess(
  67119. * 'mb', // The name of the effect.
  67120. * scene, // The scene containing the objects to blur according to their velocity.
  67121. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67122. * camera // The camera to apply the render pass to.
  67123. * );
  67124. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67125. */
  67126. export class MotionBlurPostProcess extends PostProcess {
  67127. /**
  67128. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67129. */
  67130. motionStrength: number;
  67131. /**
  67132. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67133. */
  67134. get motionBlurSamples(): number;
  67135. /**
  67136. * Sets the number of iterations to be used for motion blur quality
  67137. */
  67138. set motionBlurSamples(samples: number);
  67139. private _motionBlurSamples;
  67140. private _geometryBufferRenderer;
  67141. /**
  67142. * Creates a new instance MotionBlurPostProcess
  67143. * @param name The name of the effect.
  67144. * @param scene The scene containing the objects to blur according to their velocity.
  67145. * @param options The required width/height ratio to downsize to before computing the render pass.
  67146. * @param camera The camera to apply the render pass to.
  67147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67148. * @param engine The engine which the post process will be applied. (default: current engine)
  67149. * @param reusable If the post process can be reused on the same frame. (default: false)
  67150. * @param textureType Type of textures used when performing the post process. (default: 0)
  67151. * @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)
  67152. */
  67153. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67154. /**
  67155. * Excludes the given skinned mesh from computing bones velocities.
  67156. * 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.
  67157. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  67158. */
  67159. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67160. /**
  67161. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  67162. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  67163. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  67164. */
  67165. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67166. /**
  67167. * Disposes the post process.
  67168. * @param camera The camera to dispose the post process on.
  67169. */
  67170. dispose(camera?: Camera): void;
  67171. }
  67172. }
  67173. declare module "babylonjs/Shaders/refraction.fragment" {
  67174. /** @hidden */
  67175. export var refractionPixelShader: {
  67176. name: string;
  67177. shader: string;
  67178. };
  67179. }
  67180. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  67181. import { Color3 } from "babylonjs/Maths/math.color";
  67182. import { Camera } from "babylonjs/Cameras/camera";
  67183. import { Texture } from "babylonjs/Materials/Textures/texture";
  67184. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67185. import { Engine } from "babylonjs/Engines/engine";
  67186. import "babylonjs/Shaders/refraction.fragment";
  67187. /**
  67188. * Post process which applies a refractin texture
  67189. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67190. */
  67191. export class RefractionPostProcess extends PostProcess {
  67192. /** the base color of the refraction (used to taint the rendering) */
  67193. color: Color3;
  67194. /** simulated refraction depth */
  67195. depth: number;
  67196. /** the coefficient of the base color (0 to remove base color tainting) */
  67197. colorLevel: number;
  67198. private _refTexture;
  67199. private _ownRefractionTexture;
  67200. /**
  67201. * Gets or sets the refraction texture
  67202. * Please note that you are responsible for disposing the texture if you set it manually
  67203. */
  67204. get refractionTexture(): Texture;
  67205. set refractionTexture(value: Texture);
  67206. /**
  67207. * Initializes the RefractionPostProcess
  67208. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67209. * @param name The name of the effect.
  67210. * @param refractionTextureUrl Url of the refraction texture to use
  67211. * @param color the base color of the refraction (used to taint the rendering)
  67212. * @param depth simulated refraction depth
  67213. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  67214. * @param camera The camera to apply the render pass to.
  67215. * @param options The required width/height ratio to downsize to before computing the render pass.
  67216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67217. * @param engine The engine which the post process will be applied. (default: current engine)
  67218. * @param reusable If the post process can be reused on the same frame. (default: false)
  67219. */
  67220. constructor(name: string, refractionTextureUrl: string,
  67221. /** the base color of the refraction (used to taint the rendering) */
  67222. color: Color3,
  67223. /** simulated refraction depth */
  67224. depth: number,
  67225. /** the coefficient of the base color (0 to remove base color tainting) */
  67226. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67227. /**
  67228. * Disposes of the post process
  67229. * @param camera Camera to dispose post process on
  67230. */
  67231. dispose(camera: Camera): void;
  67232. }
  67233. }
  67234. declare module "babylonjs/Shaders/sharpen.fragment" {
  67235. /** @hidden */
  67236. export var sharpenPixelShader: {
  67237. name: string;
  67238. shader: string;
  67239. };
  67240. }
  67241. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  67242. import { Nullable } from "babylonjs/types";
  67243. import { Camera } from "babylonjs/Cameras/camera";
  67244. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67245. import "babylonjs/Shaders/sharpen.fragment";
  67246. import { Engine } from "babylonjs/Engines/engine";
  67247. /**
  67248. * The SharpenPostProcess applies a sharpen kernel to every pixel
  67249. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67250. */
  67251. export class SharpenPostProcess extends PostProcess {
  67252. /**
  67253. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  67254. */
  67255. colorAmount: number;
  67256. /**
  67257. * How much sharpness should be applied (default: 0.3)
  67258. */
  67259. edgeAmount: number;
  67260. /**
  67261. * Creates a new instance ConvolutionPostProcess
  67262. * @param name The name of the effect.
  67263. * @param options The required width/height ratio to downsize to before computing the render pass.
  67264. * @param camera The camera to apply the render pass to.
  67265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67266. * @param engine The engine which the post process will be applied. (default: current engine)
  67267. * @param reusable If the post process can be reused on the same frame. (default: false)
  67268. * @param textureType Type of textures used when performing the post process. (default: 0)
  67269. * @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)
  67270. */
  67271. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67272. }
  67273. }
  67274. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  67275. import { Nullable } from "babylonjs/types";
  67276. import { Camera } from "babylonjs/Cameras/camera";
  67277. import { Engine } from "babylonjs/Engines/engine";
  67278. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67279. import { IInspectable } from "babylonjs/Misc/iInspectable";
  67280. /**
  67281. * PostProcessRenderPipeline
  67282. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67283. */
  67284. export class PostProcessRenderPipeline {
  67285. private engine;
  67286. private _renderEffects;
  67287. private _renderEffectsForIsolatedPass;
  67288. /**
  67289. * List of inspectable custom properties (used by the Inspector)
  67290. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67291. */
  67292. inspectableCustomProperties: IInspectable[];
  67293. /**
  67294. * @hidden
  67295. */
  67296. protected _cameras: Camera[];
  67297. /** @hidden */
  67298. _name: string;
  67299. /**
  67300. * Gets pipeline name
  67301. */
  67302. get name(): string;
  67303. /** Gets the list of attached cameras */
  67304. get cameras(): Camera[];
  67305. /**
  67306. * Initializes a PostProcessRenderPipeline
  67307. * @param engine engine to add the pipeline to
  67308. * @param name name of the pipeline
  67309. */
  67310. constructor(engine: Engine, name: string);
  67311. /**
  67312. * Gets the class name
  67313. * @returns "PostProcessRenderPipeline"
  67314. */
  67315. getClassName(): string;
  67316. /**
  67317. * If all the render effects in the pipeline are supported
  67318. */
  67319. get isSupported(): boolean;
  67320. /**
  67321. * Adds an effect to the pipeline
  67322. * @param renderEffect the effect to add
  67323. */
  67324. addEffect(renderEffect: PostProcessRenderEffect): void;
  67325. /** @hidden */
  67326. _rebuild(): void;
  67327. /** @hidden */
  67328. _enableEffect(renderEffectName: string, cameras: Camera): void;
  67329. /** @hidden */
  67330. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  67331. /** @hidden */
  67332. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67333. /** @hidden */
  67334. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67335. /** @hidden */
  67336. _attachCameras(cameras: Camera, unique: boolean): void;
  67337. /** @hidden */
  67338. _attachCameras(cameras: Camera[], unique: boolean): void;
  67339. /** @hidden */
  67340. _detachCameras(cameras: Camera): void;
  67341. /** @hidden */
  67342. _detachCameras(cameras: Nullable<Camera[]>): void;
  67343. /** @hidden */
  67344. _update(): void;
  67345. /** @hidden */
  67346. _reset(): void;
  67347. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  67348. /**
  67349. * Disposes of the pipeline
  67350. */
  67351. dispose(): void;
  67352. }
  67353. }
  67354. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  67355. import { Camera } from "babylonjs/Cameras/camera";
  67356. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67357. /**
  67358. * PostProcessRenderPipelineManager class
  67359. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67360. */
  67361. export class PostProcessRenderPipelineManager {
  67362. private _renderPipelines;
  67363. /**
  67364. * Initializes a PostProcessRenderPipelineManager
  67365. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67366. */
  67367. constructor();
  67368. /**
  67369. * Gets the list of supported render pipelines
  67370. */
  67371. get supportedPipelines(): PostProcessRenderPipeline[];
  67372. /**
  67373. * Adds a pipeline to the manager
  67374. * @param renderPipeline The pipeline to add
  67375. */
  67376. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  67377. /**
  67378. * Attaches a camera to the pipeline
  67379. * @param renderPipelineName The name of the pipeline to attach to
  67380. * @param cameras the camera to attach
  67381. * @param unique if the camera can be attached multiple times to the pipeline
  67382. */
  67383. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  67384. /**
  67385. * Detaches a camera from the pipeline
  67386. * @param renderPipelineName The name of the pipeline to detach from
  67387. * @param cameras the camera to detach
  67388. */
  67389. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  67390. /**
  67391. * Enables an effect by name on a pipeline
  67392. * @param renderPipelineName the name of the pipeline to enable the effect in
  67393. * @param renderEffectName the name of the effect to enable
  67394. * @param cameras the cameras that the effect should be enabled on
  67395. */
  67396. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67397. /**
  67398. * Disables an effect by name on a pipeline
  67399. * @param renderPipelineName the name of the pipeline to disable the effect in
  67400. * @param renderEffectName the name of the effect to disable
  67401. * @param cameras the cameras that the effect should be disabled on
  67402. */
  67403. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67404. /**
  67405. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  67406. */
  67407. update(): void;
  67408. /** @hidden */
  67409. _rebuild(): void;
  67410. /**
  67411. * Disposes of the manager and pipelines
  67412. */
  67413. dispose(): void;
  67414. }
  67415. }
  67416. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  67417. import { ISceneComponent } from "babylonjs/sceneComponent";
  67418. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  67419. import { Scene } from "babylonjs/scene";
  67420. module "babylonjs/scene" {
  67421. interface Scene {
  67422. /** @hidden (Backing field) */
  67423. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67424. /**
  67425. * Gets the postprocess render pipeline manager
  67426. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67427. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67428. */
  67429. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67430. }
  67431. }
  67432. /**
  67433. * Defines the Render Pipeline scene component responsible to rendering pipelines
  67434. */
  67435. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  67436. /**
  67437. * The component name helpfull to identify the component in the list of scene components.
  67438. */
  67439. readonly name: string;
  67440. /**
  67441. * The scene the component belongs to.
  67442. */
  67443. scene: Scene;
  67444. /**
  67445. * Creates a new instance of the component for the given scene
  67446. * @param scene Defines the scene to register the component in
  67447. */
  67448. constructor(scene: Scene);
  67449. /**
  67450. * Registers the component in a given scene
  67451. */
  67452. register(): void;
  67453. /**
  67454. * Rebuilds the elements related to this component in case of
  67455. * context lost for instance.
  67456. */
  67457. rebuild(): void;
  67458. /**
  67459. * Disposes the component and the associated ressources
  67460. */
  67461. dispose(): void;
  67462. private _gatherRenderTargets;
  67463. }
  67464. }
  67465. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  67466. import { Nullable } from "babylonjs/types";
  67467. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67468. import { Camera } from "babylonjs/Cameras/camera";
  67469. import { IDisposable } from "babylonjs/scene";
  67470. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  67471. import { Scene } from "babylonjs/scene";
  67472. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  67473. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  67474. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  67475. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  67476. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  67477. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67478. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  67479. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67480. import { Animation } from "babylonjs/Animations/animation";
  67481. /**
  67482. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  67483. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67484. */
  67485. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67486. private _scene;
  67487. private _camerasToBeAttached;
  67488. /**
  67489. * ID of the sharpen post process,
  67490. */
  67491. private readonly SharpenPostProcessId;
  67492. /**
  67493. * @ignore
  67494. * ID of the image processing post process;
  67495. */
  67496. readonly ImageProcessingPostProcessId: string;
  67497. /**
  67498. * @ignore
  67499. * ID of the Fast Approximate Anti-Aliasing post process;
  67500. */
  67501. readonly FxaaPostProcessId: string;
  67502. /**
  67503. * ID of the chromatic aberration post process,
  67504. */
  67505. private readonly ChromaticAberrationPostProcessId;
  67506. /**
  67507. * ID of the grain post process
  67508. */
  67509. private readonly GrainPostProcessId;
  67510. /**
  67511. * Sharpen post process which will apply a sharpen convolution to enhance edges
  67512. */
  67513. sharpen: SharpenPostProcess;
  67514. private _sharpenEffect;
  67515. private bloom;
  67516. /**
  67517. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  67518. */
  67519. depthOfField: DepthOfFieldEffect;
  67520. /**
  67521. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67522. */
  67523. fxaa: FxaaPostProcess;
  67524. /**
  67525. * Image post processing pass used to perform operations such as tone mapping or color grading.
  67526. */
  67527. imageProcessing: ImageProcessingPostProcess;
  67528. /**
  67529. * Chromatic aberration post process which will shift rgb colors in the image
  67530. */
  67531. chromaticAberration: ChromaticAberrationPostProcess;
  67532. private _chromaticAberrationEffect;
  67533. /**
  67534. * Grain post process which add noise to the image
  67535. */
  67536. grain: GrainPostProcess;
  67537. private _grainEffect;
  67538. /**
  67539. * Glow post process which adds a glow to emissive areas of the image
  67540. */
  67541. private _glowLayer;
  67542. /**
  67543. * Animations which can be used to tweak settings over a period of time
  67544. */
  67545. animations: Animation[];
  67546. private _imageProcessingConfigurationObserver;
  67547. private _sharpenEnabled;
  67548. private _bloomEnabled;
  67549. private _depthOfFieldEnabled;
  67550. private _depthOfFieldBlurLevel;
  67551. private _fxaaEnabled;
  67552. private _imageProcessingEnabled;
  67553. private _defaultPipelineTextureType;
  67554. private _bloomScale;
  67555. private _chromaticAberrationEnabled;
  67556. private _grainEnabled;
  67557. private _buildAllowed;
  67558. /**
  67559. * Gets active scene
  67560. */
  67561. get scene(): Scene;
  67562. /**
  67563. * Enable or disable the sharpen process from the pipeline
  67564. */
  67565. set sharpenEnabled(enabled: boolean);
  67566. get sharpenEnabled(): boolean;
  67567. private _resizeObserver;
  67568. private _hardwareScaleLevel;
  67569. private _bloomKernel;
  67570. /**
  67571. * Specifies the size of the bloom blur kernel, relative to the final output size
  67572. */
  67573. get bloomKernel(): number;
  67574. set bloomKernel(value: number);
  67575. /**
  67576. * Specifies the weight of the bloom in the final rendering
  67577. */
  67578. private _bloomWeight;
  67579. /**
  67580. * Specifies the luma threshold for the area that will be blurred by the bloom
  67581. */
  67582. private _bloomThreshold;
  67583. private _hdr;
  67584. /**
  67585. * The strength of the bloom.
  67586. */
  67587. set bloomWeight(value: number);
  67588. get bloomWeight(): number;
  67589. /**
  67590. * The strength of the bloom.
  67591. */
  67592. set bloomThreshold(value: number);
  67593. get bloomThreshold(): number;
  67594. /**
  67595. * The scale of the bloom, lower value will provide better performance.
  67596. */
  67597. set bloomScale(value: number);
  67598. get bloomScale(): number;
  67599. /**
  67600. * Enable or disable the bloom from the pipeline
  67601. */
  67602. set bloomEnabled(enabled: boolean);
  67603. get bloomEnabled(): boolean;
  67604. private _rebuildBloom;
  67605. /**
  67606. * If the depth of field is enabled.
  67607. */
  67608. get depthOfFieldEnabled(): boolean;
  67609. set depthOfFieldEnabled(enabled: boolean);
  67610. /**
  67611. * Blur level of the depth of field effect. (Higher blur will effect performance)
  67612. */
  67613. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  67614. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  67615. /**
  67616. * If the anti aliasing is enabled.
  67617. */
  67618. set fxaaEnabled(enabled: boolean);
  67619. get fxaaEnabled(): boolean;
  67620. private _samples;
  67621. /**
  67622. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67623. */
  67624. set samples(sampleCount: number);
  67625. get samples(): number;
  67626. /**
  67627. * If image processing is enabled.
  67628. */
  67629. set imageProcessingEnabled(enabled: boolean);
  67630. get imageProcessingEnabled(): boolean;
  67631. /**
  67632. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  67633. */
  67634. set glowLayerEnabled(enabled: boolean);
  67635. get glowLayerEnabled(): boolean;
  67636. /**
  67637. * Gets the glow layer (or null if not defined)
  67638. */
  67639. get glowLayer(): Nullable<GlowLayer>;
  67640. /**
  67641. * Enable or disable the chromaticAberration process from the pipeline
  67642. */
  67643. set chromaticAberrationEnabled(enabled: boolean);
  67644. get chromaticAberrationEnabled(): boolean;
  67645. /**
  67646. * Enable or disable the grain process from the pipeline
  67647. */
  67648. set grainEnabled(enabled: boolean);
  67649. get grainEnabled(): boolean;
  67650. /**
  67651. * @constructor
  67652. * @param name - The rendering pipeline name (default: "")
  67653. * @param hdr - If high dynamic range textures should be used (default: true)
  67654. * @param scene - The scene linked to this pipeline (default: the last created scene)
  67655. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  67656. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  67657. */
  67658. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  67659. /**
  67660. * Get the class name
  67661. * @returns "DefaultRenderingPipeline"
  67662. */
  67663. getClassName(): string;
  67664. /**
  67665. * Force the compilation of the entire pipeline.
  67666. */
  67667. prepare(): void;
  67668. private _hasCleared;
  67669. private _prevPostProcess;
  67670. private _prevPrevPostProcess;
  67671. private _setAutoClearAndTextureSharing;
  67672. private _depthOfFieldSceneObserver;
  67673. private _buildPipeline;
  67674. private _disposePostProcesses;
  67675. /**
  67676. * Adds a camera to the pipeline
  67677. * @param camera the camera to be added
  67678. */
  67679. addCamera(camera: Camera): void;
  67680. /**
  67681. * Removes a camera from the pipeline
  67682. * @param camera the camera to remove
  67683. */
  67684. removeCamera(camera: Camera): void;
  67685. /**
  67686. * Dispose of the pipeline and stop all post processes
  67687. */
  67688. dispose(): void;
  67689. /**
  67690. * Serialize the rendering pipeline (Used when exporting)
  67691. * @returns the serialized object
  67692. */
  67693. serialize(): any;
  67694. /**
  67695. * Parse the serialized pipeline
  67696. * @param source Source pipeline.
  67697. * @param scene The scene to load the pipeline to.
  67698. * @param rootUrl The URL of the serialized pipeline.
  67699. * @returns An instantiated pipeline from the serialized object.
  67700. */
  67701. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  67702. }
  67703. }
  67704. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  67705. /** @hidden */
  67706. export var lensHighlightsPixelShader: {
  67707. name: string;
  67708. shader: string;
  67709. };
  67710. }
  67711. declare module "babylonjs/Shaders/depthOfField.fragment" {
  67712. /** @hidden */
  67713. export var depthOfFieldPixelShader: {
  67714. name: string;
  67715. shader: string;
  67716. };
  67717. }
  67718. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  67719. import { Camera } from "babylonjs/Cameras/camera";
  67720. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67721. import { Scene } from "babylonjs/scene";
  67722. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67723. import "babylonjs/Shaders/chromaticAberration.fragment";
  67724. import "babylonjs/Shaders/lensHighlights.fragment";
  67725. import "babylonjs/Shaders/depthOfField.fragment";
  67726. /**
  67727. * BABYLON.JS Chromatic Aberration GLSL Shader
  67728. * Author: Olivier Guyot
  67729. * Separates very slightly R, G and B colors on the edges of the screen
  67730. * Inspired by Francois Tarlier & Martins Upitis
  67731. */
  67732. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  67733. /**
  67734. * @ignore
  67735. * The chromatic aberration PostProcess id in the pipeline
  67736. */
  67737. LensChromaticAberrationEffect: string;
  67738. /**
  67739. * @ignore
  67740. * The highlights enhancing PostProcess id in the pipeline
  67741. */
  67742. HighlightsEnhancingEffect: string;
  67743. /**
  67744. * @ignore
  67745. * The depth-of-field PostProcess id in the pipeline
  67746. */
  67747. LensDepthOfFieldEffect: string;
  67748. private _scene;
  67749. private _depthTexture;
  67750. private _grainTexture;
  67751. private _chromaticAberrationPostProcess;
  67752. private _highlightsPostProcess;
  67753. private _depthOfFieldPostProcess;
  67754. private _edgeBlur;
  67755. private _grainAmount;
  67756. private _chromaticAberration;
  67757. private _distortion;
  67758. private _highlightsGain;
  67759. private _highlightsThreshold;
  67760. private _dofDistance;
  67761. private _dofAperture;
  67762. private _dofDarken;
  67763. private _dofPentagon;
  67764. private _blurNoise;
  67765. /**
  67766. * @constructor
  67767. *
  67768. * Effect parameters are as follow:
  67769. * {
  67770. * chromatic_aberration: number; // from 0 to x (1 for realism)
  67771. * edge_blur: number; // from 0 to x (1 for realism)
  67772. * distortion: number; // from 0 to x (1 for realism)
  67773. * grain_amount: number; // from 0 to 1
  67774. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  67775. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  67776. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  67777. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  67778. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  67779. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  67780. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  67781. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  67782. * }
  67783. * Note: if an effect parameter is unset, effect is disabled
  67784. *
  67785. * @param name The rendering pipeline name
  67786. * @param parameters - An object containing all parameters (see above)
  67787. * @param scene The scene linked to this pipeline
  67788. * @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)
  67789. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67790. */
  67791. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  67792. /**
  67793. * Get the class name
  67794. * @returns "LensRenderingPipeline"
  67795. */
  67796. getClassName(): string;
  67797. /**
  67798. * Gets associated scene
  67799. */
  67800. get scene(): Scene;
  67801. /**
  67802. * Gets or sets the edge blur
  67803. */
  67804. get edgeBlur(): number;
  67805. set edgeBlur(value: number);
  67806. /**
  67807. * Gets or sets the grain amount
  67808. */
  67809. get grainAmount(): number;
  67810. set grainAmount(value: number);
  67811. /**
  67812. * Gets or sets the chromatic aberration amount
  67813. */
  67814. get chromaticAberration(): number;
  67815. set chromaticAberration(value: number);
  67816. /**
  67817. * Gets or sets the depth of field aperture
  67818. */
  67819. get dofAperture(): number;
  67820. set dofAperture(value: number);
  67821. /**
  67822. * Gets or sets the edge distortion
  67823. */
  67824. get edgeDistortion(): number;
  67825. set edgeDistortion(value: number);
  67826. /**
  67827. * Gets or sets the depth of field distortion
  67828. */
  67829. get dofDistortion(): number;
  67830. set dofDistortion(value: number);
  67831. /**
  67832. * Gets or sets the darken out of focus amount
  67833. */
  67834. get darkenOutOfFocus(): number;
  67835. set darkenOutOfFocus(value: number);
  67836. /**
  67837. * Gets or sets a boolean indicating if blur noise is enabled
  67838. */
  67839. get blurNoise(): boolean;
  67840. set blurNoise(value: boolean);
  67841. /**
  67842. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67843. */
  67844. get pentagonBokeh(): boolean;
  67845. set pentagonBokeh(value: boolean);
  67846. /**
  67847. * Gets or sets the highlight grain amount
  67848. */
  67849. get highlightsGain(): number;
  67850. set highlightsGain(value: number);
  67851. /**
  67852. * Gets or sets the highlight threshold
  67853. */
  67854. get highlightsThreshold(): number;
  67855. set highlightsThreshold(value: number);
  67856. /**
  67857. * Sets the amount of blur at the edges
  67858. * @param amount blur amount
  67859. */
  67860. setEdgeBlur(amount: number): void;
  67861. /**
  67862. * Sets edge blur to 0
  67863. */
  67864. disableEdgeBlur(): void;
  67865. /**
  67866. * Sets the amout of grain
  67867. * @param amount Amount of grain
  67868. */
  67869. setGrainAmount(amount: number): void;
  67870. /**
  67871. * Set grain amount to 0
  67872. */
  67873. disableGrain(): void;
  67874. /**
  67875. * Sets the chromatic aberration amount
  67876. * @param amount amount of chromatic aberration
  67877. */
  67878. setChromaticAberration(amount: number): void;
  67879. /**
  67880. * Sets chromatic aberration amount to 0
  67881. */
  67882. disableChromaticAberration(): void;
  67883. /**
  67884. * Sets the EdgeDistortion amount
  67885. * @param amount amount of EdgeDistortion
  67886. */
  67887. setEdgeDistortion(amount: number): void;
  67888. /**
  67889. * Sets edge distortion to 0
  67890. */
  67891. disableEdgeDistortion(): void;
  67892. /**
  67893. * Sets the FocusDistance amount
  67894. * @param amount amount of FocusDistance
  67895. */
  67896. setFocusDistance(amount: number): void;
  67897. /**
  67898. * Disables depth of field
  67899. */
  67900. disableDepthOfField(): void;
  67901. /**
  67902. * Sets the Aperture amount
  67903. * @param amount amount of Aperture
  67904. */
  67905. setAperture(amount: number): void;
  67906. /**
  67907. * Sets the DarkenOutOfFocus amount
  67908. * @param amount amount of DarkenOutOfFocus
  67909. */
  67910. setDarkenOutOfFocus(amount: number): void;
  67911. private _pentagonBokehIsEnabled;
  67912. /**
  67913. * Creates a pentagon bokeh effect
  67914. */
  67915. enablePentagonBokeh(): void;
  67916. /**
  67917. * Disables the pentagon bokeh effect
  67918. */
  67919. disablePentagonBokeh(): void;
  67920. /**
  67921. * Enables noise blur
  67922. */
  67923. enableNoiseBlur(): void;
  67924. /**
  67925. * Disables noise blur
  67926. */
  67927. disableNoiseBlur(): void;
  67928. /**
  67929. * Sets the HighlightsGain amount
  67930. * @param amount amount of HighlightsGain
  67931. */
  67932. setHighlightsGain(amount: number): void;
  67933. /**
  67934. * Sets the HighlightsThreshold amount
  67935. * @param amount amount of HighlightsThreshold
  67936. */
  67937. setHighlightsThreshold(amount: number): void;
  67938. /**
  67939. * Disables highlights
  67940. */
  67941. disableHighlights(): void;
  67942. /**
  67943. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67944. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67945. */
  67946. dispose(disableDepthRender?: boolean): void;
  67947. private _createChromaticAberrationPostProcess;
  67948. private _createHighlightsPostProcess;
  67949. private _createDepthOfFieldPostProcess;
  67950. private _createGrainTexture;
  67951. }
  67952. }
  67953. declare module "babylonjs/Shaders/ssao2.fragment" {
  67954. /** @hidden */
  67955. export var ssao2PixelShader: {
  67956. name: string;
  67957. shader: string;
  67958. };
  67959. }
  67960. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  67961. /** @hidden */
  67962. export var ssaoCombinePixelShader: {
  67963. name: string;
  67964. shader: string;
  67965. };
  67966. }
  67967. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  67968. import { Camera } from "babylonjs/Cameras/camera";
  67969. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67970. import { Scene } from "babylonjs/scene";
  67971. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67972. import "babylonjs/Shaders/ssao2.fragment";
  67973. import "babylonjs/Shaders/ssaoCombine.fragment";
  67974. /**
  67975. * Render pipeline to produce ssao effect
  67976. */
  67977. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67978. /**
  67979. * @ignore
  67980. * The PassPostProcess id in the pipeline that contains the original scene color
  67981. */
  67982. SSAOOriginalSceneColorEffect: string;
  67983. /**
  67984. * @ignore
  67985. * The SSAO PostProcess id in the pipeline
  67986. */
  67987. SSAORenderEffect: string;
  67988. /**
  67989. * @ignore
  67990. * The horizontal blur PostProcess id in the pipeline
  67991. */
  67992. SSAOBlurHRenderEffect: string;
  67993. /**
  67994. * @ignore
  67995. * The vertical blur PostProcess id in the pipeline
  67996. */
  67997. SSAOBlurVRenderEffect: string;
  67998. /**
  67999. * @ignore
  68000. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68001. */
  68002. SSAOCombineRenderEffect: string;
  68003. /**
  68004. * The output strength of the SSAO post-process. Default value is 1.0.
  68005. */
  68006. totalStrength: number;
  68007. /**
  68008. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68009. */
  68010. maxZ: number;
  68011. /**
  68012. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68013. */
  68014. minZAspect: number;
  68015. private _samples;
  68016. /**
  68017. * Number of samples used for the SSAO calculations. Default value is 8
  68018. */
  68019. set samples(n: number);
  68020. get samples(): number;
  68021. private _textureSamples;
  68022. /**
  68023. * Number of samples to use for antialiasing
  68024. */
  68025. set textureSamples(n: number);
  68026. get textureSamples(): number;
  68027. /**
  68028. * Ratio object used for SSAO ratio and blur ratio
  68029. */
  68030. private _ratio;
  68031. /**
  68032. * Dynamically generated sphere sampler.
  68033. */
  68034. private _sampleSphere;
  68035. /**
  68036. * Blur filter offsets
  68037. */
  68038. private _samplerOffsets;
  68039. private _expensiveBlur;
  68040. /**
  68041. * If bilateral blur should be used
  68042. */
  68043. set expensiveBlur(b: boolean);
  68044. get expensiveBlur(): boolean;
  68045. /**
  68046. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  68047. */
  68048. radius: number;
  68049. /**
  68050. * The base color of the SSAO post-process
  68051. * The final result is "base + ssao" between [0, 1]
  68052. */
  68053. base: number;
  68054. /**
  68055. * Support test.
  68056. */
  68057. static get IsSupported(): boolean;
  68058. private _scene;
  68059. private _depthTexture;
  68060. private _normalTexture;
  68061. private _randomTexture;
  68062. private _originalColorPostProcess;
  68063. private _ssaoPostProcess;
  68064. private _blurHPostProcess;
  68065. private _blurVPostProcess;
  68066. private _ssaoCombinePostProcess;
  68067. /**
  68068. * Gets active scene
  68069. */
  68070. get scene(): Scene;
  68071. /**
  68072. * @constructor
  68073. * @param name The rendering pipeline name
  68074. * @param scene The scene linked to this pipeline
  68075. * @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 }
  68076. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68077. */
  68078. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68079. /**
  68080. * Get the class name
  68081. * @returns "SSAO2RenderingPipeline"
  68082. */
  68083. getClassName(): string;
  68084. /**
  68085. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68086. */
  68087. dispose(disableGeometryBufferRenderer?: boolean): void;
  68088. private _createBlurPostProcess;
  68089. /** @hidden */
  68090. _rebuild(): void;
  68091. private _bits;
  68092. private _radicalInverse_VdC;
  68093. private _hammersley;
  68094. private _hemisphereSample_uniform;
  68095. private _generateHemisphere;
  68096. private _createSSAOPostProcess;
  68097. private _createSSAOCombinePostProcess;
  68098. private _createRandomTexture;
  68099. /**
  68100. * Serialize the rendering pipeline (Used when exporting)
  68101. * @returns the serialized object
  68102. */
  68103. serialize(): any;
  68104. /**
  68105. * Parse the serialized pipeline
  68106. * @param source Source pipeline.
  68107. * @param scene The scene to load the pipeline to.
  68108. * @param rootUrl The URL of the serialized pipeline.
  68109. * @returns An instantiated pipeline from the serialized object.
  68110. */
  68111. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68112. }
  68113. }
  68114. declare module "babylonjs/Shaders/ssao.fragment" {
  68115. /** @hidden */
  68116. export var ssaoPixelShader: {
  68117. name: string;
  68118. shader: string;
  68119. };
  68120. }
  68121. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  68122. import { Camera } from "babylonjs/Cameras/camera";
  68123. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68124. import { Scene } from "babylonjs/scene";
  68125. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68126. import "babylonjs/Shaders/ssao.fragment";
  68127. import "babylonjs/Shaders/ssaoCombine.fragment";
  68128. /**
  68129. * Render pipeline to produce ssao effect
  68130. */
  68131. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68132. /**
  68133. * @ignore
  68134. * The PassPostProcess id in the pipeline that contains the original scene color
  68135. */
  68136. SSAOOriginalSceneColorEffect: string;
  68137. /**
  68138. * @ignore
  68139. * The SSAO PostProcess id in the pipeline
  68140. */
  68141. SSAORenderEffect: string;
  68142. /**
  68143. * @ignore
  68144. * The horizontal blur PostProcess id in the pipeline
  68145. */
  68146. SSAOBlurHRenderEffect: string;
  68147. /**
  68148. * @ignore
  68149. * The vertical blur PostProcess id in the pipeline
  68150. */
  68151. SSAOBlurVRenderEffect: string;
  68152. /**
  68153. * @ignore
  68154. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68155. */
  68156. SSAOCombineRenderEffect: string;
  68157. /**
  68158. * The output strength of the SSAO post-process. Default value is 1.0.
  68159. */
  68160. totalStrength: number;
  68161. /**
  68162. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68163. */
  68164. radius: number;
  68165. /**
  68166. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68167. * Must not be equal to fallOff and superior to fallOff.
  68168. * Default value is 0.0075
  68169. */
  68170. area: number;
  68171. /**
  68172. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68173. * Must not be equal to area and inferior to area.
  68174. * Default value is 0.000001
  68175. */
  68176. fallOff: number;
  68177. /**
  68178. * The base color of the SSAO post-process
  68179. * The final result is "base + ssao" between [0, 1]
  68180. */
  68181. base: number;
  68182. private _scene;
  68183. private _depthTexture;
  68184. private _randomTexture;
  68185. private _originalColorPostProcess;
  68186. private _ssaoPostProcess;
  68187. private _blurHPostProcess;
  68188. private _blurVPostProcess;
  68189. private _ssaoCombinePostProcess;
  68190. private _firstUpdate;
  68191. /**
  68192. * Gets active scene
  68193. */
  68194. get scene(): Scene;
  68195. /**
  68196. * @constructor
  68197. * @param name - The rendering pipeline name
  68198. * @param scene - The scene linked to this pipeline
  68199. * @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 }
  68200. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  68201. */
  68202. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68203. /**
  68204. * Get the class name
  68205. * @returns "SSAORenderingPipeline"
  68206. */
  68207. getClassName(): string;
  68208. /**
  68209. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68210. */
  68211. dispose(disableDepthRender?: boolean): void;
  68212. private _createBlurPostProcess;
  68213. /** @hidden */
  68214. _rebuild(): void;
  68215. private _createSSAOPostProcess;
  68216. private _createSSAOCombinePostProcess;
  68217. private _createRandomTexture;
  68218. }
  68219. }
  68220. declare module "babylonjs/Shaders/standard.fragment" {
  68221. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68222. /** @hidden */
  68223. export var standardPixelShader: {
  68224. name: string;
  68225. shader: string;
  68226. };
  68227. }
  68228. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  68229. import { Nullable } from "babylonjs/types";
  68230. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68231. import { Camera } from "babylonjs/Cameras/camera";
  68232. import { Texture } from "babylonjs/Materials/Textures/texture";
  68233. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68234. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68235. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68236. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68237. import { IDisposable } from "babylonjs/scene";
  68238. import { SpotLight } from "babylonjs/Lights/spotLight";
  68239. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  68240. import { Scene } from "babylonjs/scene";
  68241. import { Animation } from "babylonjs/Animations/animation";
  68242. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68243. import "babylonjs/Shaders/standard.fragment";
  68244. /**
  68245. * Standard rendering pipeline
  68246. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68247. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  68248. */
  68249. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68250. /**
  68251. * Public members
  68252. */
  68253. /**
  68254. * Post-process which contains the original scene color before the pipeline applies all the effects
  68255. */
  68256. originalPostProcess: Nullable<PostProcess>;
  68257. /**
  68258. * Post-process used to down scale an image x4
  68259. */
  68260. downSampleX4PostProcess: Nullable<PostProcess>;
  68261. /**
  68262. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  68263. */
  68264. brightPassPostProcess: Nullable<PostProcess>;
  68265. /**
  68266. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  68267. */
  68268. blurHPostProcesses: PostProcess[];
  68269. /**
  68270. * Post-process array storing all the vertical blur post-processes used by the pipeline
  68271. */
  68272. blurVPostProcesses: PostProcess[];
  68273. /**
  68274. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  68275. */
  68276. textureAdderPostProcess: Nullable<PostProcess>;
  68277. /**
  68278. * Post-process used to create volumetric lighting effect
  68279. */
  68280. volumetricLightPostProcess: Nullable<PostProcess>;
  68281. /**
  68282. * Post-process used to smooth the previous volumetric light post-process on the X axis
  68283. */
  68284. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  68285. /**
  68286. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  68287. */
  68288. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  68289. /**
  68290. * Post-process used to merge the volumetric light effect and the real scene color
  68291. */
  68292. volumetricLightMergePostProces: Nullable<PostProcess>;
  68293. /**
  68294. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  68295. */
  68296. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  68297. /**
  68298. * Base post-process used to calculate the average luminance of the final image for HDR
  68299. */
  68300. luminancePostProcess: Nullable<PostProcess>;
  68301. /**
  68302. * Post-processes used to create down sample post-processes in order to get
  68303. * the average luminance of the final image for HDR
  68304. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  68305. */
  68306. luminanceDownSamplePostProcesses: PostProcess[];
  68307. /**
  68308. * Post-process used to create a HDR effect (light adaptation)
  68309. */
  68310. hdrPostProcess: Nullable<PostProcess>;
  68311. /**
  68312. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  68313. */
  68314. textureAdderFinalPostProcess: Nullable<PostProcess>;
  68315. /**
  68316. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  68317. */
  68318. lensFlareFinalPostProcess: Nullable<PostProcess>;
  68319. /**
  68320. * Post-process used to merge the final HDR post-process and the real scene color
  68321. */
  68322. hdrFinalPostProcess: Nullable<PostProcess>;
  68323. /**
  68324. * Post-process used to create a lens flare effect
  68325. */
  68326. lensFlarePostProcess: Nullable<PostProcess>;
  68327. /**
  68328. * Post-process that merges the result of the lens flare post-process and the real scene color
  68329. */
  68330. lensFlareComposePostProcess: Nullable<PostProcess>;
  68331. /**
  68332. * Post-process used to create a motion blur effect
  68333. */
  68334. motionBlurPostProcess: Nullable<PostProcess>;
  68335. /**
  68336. * Post-process used to create a depth of field effect
  68337. */
  68338. depthOfFieldPostProcess: Nullable<PostProcess>;
  68339. /**
  68340. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68341. */
  68342. fxaaPostProcess: Nullable<FxaaPostProcess>;
  68343. /**
  68344. * Represents the brightness threshold in order to configure the illuminated surfaces
  68345. */
  68346. brightThreshold: number;
  68347. /**
  68348. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  68349. */
  68350. blurWidth: number;
  68351. /**
  68352. * Sets if the blur for highlighted surfaces must be only horizontal
  68353. */
  68354. horizontalBlur: boolean;
  68355. /**
  68356. * Gets the overall exposure used by the pipeline
  68357. */
  68358. get exposure(): number;
  68359. /**
  68360. * Sets the overall exposure used by the pipeline
  68361. */
  68362. set exposure(value: number);
  68363. /**
  68364. * Texture used typically to simulate "dirty" on camera lens
  68365. */
  68366. lensTexture: Nullable<Texture>;
  68367. /**
  68368. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  68369. */
  68370. volumetricLightCoefficient: number;
  68371. /**
  68372. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  68373. */
  68374. volumetricLightPower: number;
  68375. /**
  68376. * Used the set the blur intensity to smooth the volumetric lights
  68377. */
  68378. volumetricLightBlurScale: number;
  68379. /**
  68380. * Light (spot or directional) used to generate the volumetric lights rays
  68381. * The source light must have a shadow generate so the pipeline can get its
  68382. * depth map
  68383. */
  68384. sourceLight: Nullable<SpotLight | DirectionalLight>;
  68385. /**
  68386. * For eye adaptation, represents the minimum luminance the eye can see
  68387. */
  68388. hdrMinimumLuminance: number;
  68389. /**
  68390. * For eye adaptation, represents the decrease luminance speed
  68391. */
  68392. hdrDecreaseRate: number;
  68393. /**
  68394. * For eye adaptation, represents the increase luminance speed
  68395. */
  68396. hdrIncreaseRate: number;
  68397. /**
  68398. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68399. */
  68400. get hdrAutoExposure(): boolean;
  68401. /**
  68402. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68403. */
  68404. set hdrAutoExposure(value: boolean);
  68405. /**
  68406. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  68407. */
  68408. lensColorTexture: Nullable<Texture>;
  68409. /**
  68410. * The overall strengh for the lens flare effect
  68411. */
  68412. lensFlareStrength: number;
  68413. /**
  68414. * Dispersion coefficient for lens flare ghosts
  68415. */
  68416. lensFlareGhostDispersal: number;
  68417. /**
  68418. * Main lens flare halo width
  68419. */
  68420. lensFlareHaloWidth: number;
  68421. /**
  68422. * Based on the lens distortion effect, defines how much the lens flare result
  68423. * is distorted
  68424. */
  68425. lensFlareDistortionStrength: number;
  68426. /**
  68427. * Configures the blur intensity used for for lens flare (halo)
  68428. */
  68429. lensFlareBlurWidth: number;
  68430. /**
  68431. * Lens star texture must be used to simulate rays on the flares and is available
  68432. * in the documentation
  68433. */
  68434. lensStarTexture: Nullable<Texture>;
  68435. /**
  68436. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  68437. * flare effect by taking account of the dirt texture
  68438. */
  68439. lensFlareDirtTexture: Nullable<Texture>;
  68440. /**
  68441. * Represents the focal length for the depth of field effect
  68442. */
  68443. depthOfFieldDistance: number;
  68444. /**
  68445. * Represents the blur intensity for the blurred part of the depth of field effect
  68446. */
  68447. depthOfFieldBlurWidth: number;
  68448. /**
  68449. * Gets how much the image is blurred by the movement while using the motion blur post-process
  68450. */
  68451. get motionStrength(): number;
  68452. /**
  68453. * Sets how much the image is blurred by the movement while using the motion blur post-process
  68454. */
  68455. set motionStrength(strength: number);
  68456. /**
  68457. * Gets wether or not the motion blur post-process is object based or screen based.
  68458. */
  68459. get objectBasedMotionBlur(): boolean;
  68460. /**
  68461. * Sets wether or not the motion blur post-process should be object based or screen based
  68462. */
  68463. set objectBasedMotionBlur(value: boolean);
  68464. /**
  68465. * List of animations for the pipeline (IAnimatable implementation)
  68466. */
  68467. animations: Animation[];
  68468. /**
  68469. * Private members
  68470. */
  68471. private _scene;
  68472. private _currentDepthOfFieldSource;
  68473. private _basePostProcess;
  68474. private _fixedExposure;
  68475. private _currentExposure;
  68476. private _hdrAutoExposure;
  68477. private _hdrCurrentLuminance;
  68478. private _motionStrength;
  68479. private _isObjectBasedMotionBlur;
  68480. private _floatTextureType;
  68481. private _camerasToBeAttached;
  68482. private _ratio;
  68483. private _bloomEnabled;
  68484. private _depthOfFieldEnabled;
  68485. private _vlsEnabled;
  68486. private _lensFlareEnabled;
  68487. private _hdrEnabled;
  68488. private _motionBlurEnabled;
  68489. private _fxaaEnabled;
  68490. private _motionBlurSamples;
  68491. private _volumetricLightStepsCount;
  68492. private _samples;
  68493. /**
  68494. * @ignore
  68495. * Specifies if the bloom pipeline is enabled
  68496. */
  68497. get BloomEnabled(): boolean;
  68498. set BloomEnabled(enabled: boolean);
  68499. /**
  68500. * @ignore
  68501. * Specifies if the depth of field pipeline is enabed
  68502. */
  68503. get DepthOfFieldEnabled(): boolean;
  68504. set DepthOfFieldEnabled(enabled: boolean);
  68505. /**
  68506. * @ignore
  68507. * Specifies if the lens flare pipeline is enabed
  68508. */
  68509. get LensFlareEnabled(): boolean;
  68510. set LensFlareEnabled(enabled: boolean);
  68511. /**
  68512. * @ignore
  68513. * Specifies if the HDR pipeline is enabled
  68514. */
  68515. get HDREnabled(): boolean;
  68516. set HDREnabled(enabled: boolean);
  68517. /**
  68518. * @ignore
  68519. * Specifies if the volumetric lights scattering effect is enabled
  68520. */
  68521. get VLSEnabled(): boolean;
  68522. set VLSEnabled(enabled: boolean);
  68523. /**
  68524. * @ignore
  68525. * Specifies if the motion blur effect is enabled
  68526. */
  68527. get MotionBlurEnabled(): boolean;
  68528. set MotionBlurEnabled(enabled: boolean);
  68529. /**
  68530. * Specifies if anti-aliasing is enabled
  68531. */
  68532. get fxaaEnabled(): boolean;
  68533. set fxaaEnabled(enabled: boolean);
  68534. /**
  68535. * Specifies the number of steps used to calculate the volumetric lights
  68536. * Typically in interval [50, 200]
  68537. */
  68538. get volumetricLightStepsCount(): number;
  68539. set volumetricLightStepsCount(count: number);
  68540. /**
  68541. * Specifies the number of samples used for the motion blur effect
  68542. * Typically in interval [16, 64]
  68543. */
  68544. get motionBlurSamples(): number;
  68545. set motionBlurSamples(samples: number);
  68546. /**
  68547. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68548. */
  68549. get samples(): number;
  68550. set samples(sampleCount: number);
  68551. /**
  68552. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68553. * @constructor
  68554. * @param name The rendering pipeline name
  68555. * @param scene The scene linked to this pipeline
  68556. * @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)
  68557. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  68558. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68559. */
  68560. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  68561. private _buildPipeline;
  68562. private _createDownSampleX4PostProcess;
  68563. private _createBrightPassPostProcess;
  68564. private _createBlurPostProcesses;
  68565. private _createTextureAdderPostProcess;
  68566. private _createVolumetricLightPostProcess;
  68567. private _createLuminancePostProcesses;
  68568. private _createHdrPostProcess;
  68569. private _createLensFlarePostProcess;
  68570. private _createDepthOfFieldPostProcess;
  68571. private _createMotionBlurPostProcess;
  68572. private _getDepthTexture;
  68573. private _disposePostProcesses;
  68574. /**
  68575. * Dispose of the pipeline and stop all post processes
  68576. */
  68577. dispose(): void;
  68578. /**
  68579. * Serialize the rendering pipeline (Used when exporting)
  68580. * @returns the serialized object
  68581. */
  68582. serialize(): any;
  68583. /**
  68584. * Parse the serialized pipeline
  68585. * @param source Source pipeline.
  68586. * @param scene The scene to load the pipeline to.
  68587. * @param rootUrl The URL of the serialized pipeline.
  68588. * @returns An instantiated pipeline from the serialized object.
  68589. */
  68590. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  68591. /**
  68592. * Luminance steps
  68593. */
  68594. static LuminanceSteps: number;
  68595. }
  68596. }
  68597. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  68598. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  68599. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  68600. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  68601. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  68602. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  68603. }
  68604. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  68605. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  68606. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68607. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68608. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68609. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68610. }
  68611. declare module "babylonjs/Shaders/tonemap.fragment" {
  68612. /** @hidden */
  68613. export var tonemapPixelShader: {
  68614. name: string;
  68615. shader: string;
  68616. };
  68617. }
  68618. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  68619. import { Camera } from "babylonjs/Cameras/camera";
  68620. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68621. import "babylonjs/Shaders/tonemap.fragment";
  68622. import { Engine } from "babylonjs/Engines/engine";
  68623. /** Defines operator used for tonemapping */
  68624. export enum TonemappingOperator {
  68625. /** Hable */
  68626. Hable = 0,
  68627. /** Reinhard */
  68628. Reinhard = 1,
  68629. /** HejiDawson */
  68630. HejiDawson = 2,
  68631. /** Photographic */
  68632. Photographic = 3
  68633. }
  68634. /**
  68635. * Defines a post process to apply tone mapping
  68636. */
  68637. export class TonemapPostProcess extends PostProcess {
  68638. private _operator;
  68639. /** Defines the required exposure adjustement */
  68640. exposureAdjustment: number;
  68641. /**
  68642. * Creates a new TonemapPostProcess
  68643. * @param name defines the name of the postprocess
  68644. * @param _operator defines the operator to use
  68645. * @param exposureAdjustment defines the required exposure adjustement
  68646. * @param camera defines the camera to use (can be null)
  68647. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  68648. * @param engine defines the hosting engine (can be ignore if camera is set)
  68649. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  68650. */
  68651. constructor(name: string, _operator: TonemappingOperator,
  68652. /** Defines the required exposure adjustement */
  68653. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  68654. }
  68655. }
  68656. declare module "babylonjs/Shaders/depth.vertex" {
  68657. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68658. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68659. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68660. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68661. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68662. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68663. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68664. /** @hidden */
  68665. export var depthVertexShader: {
  68666. name: string;
  68667. shader: string;
  68668. };
  68669. }
  68670. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  68671. /** @hidden */
  68672. export var volumetricLightScatteringPixelShader: {
  68673. name: string;
  68674. shader: string;
  68675. };
  68676. }
  68677. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  68678. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68679. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68680. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68681. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68682. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68683. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68684. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68685. /** @hidden */
  68686. export var volumetricLightScatteringPassVertexShader: {
  68687. name: string;
  68688. shader: string;
  68689. };
  68690. }
  68691. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  68692. /** @hidden */
  68693. export var volumetricLightScatteringPassPixelShader: {
  68694. name: string;
  68695. shader: string;
  68696. };
  68697. }
  68698. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  68699. import { Vector3 } from "babylonjs/Maths/math.vector";
  68700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68701. import { Mesh } from "babylonjs/Meshes/mesh";
  68702. import { Camera } from "babylonjs/Cameras/camera";
  68703. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68704. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68705. import { Scene } from "babylonjs/scene";
  68706. import "babylonjs/Meshes/Builders/planeBuilder";
  68707. import "babylonjs/Shaders/depth.vertex";
  68708. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  68709. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  68710. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  68711. import { Engine } from "babylonjs/Engines/engine";
  68712. /**
  68713. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  68714. */
  68715. export class VolumetricLightScatteringPostProcess extends PostProcess {
  68716. private _volumetricLightScatteringPass;
  68717. private _volumetricLightScatteringRTT;
  68718. private _viewPort;
  68719. private _screenCoordinates;
  68720. private _cachedDefines;
  68721. /**
  68722. * If not undefined, the mesh position is computed from the attached node position
  68723. */
  68724. attachedNode: {
  68725. position: Vector3;
  68726. };
  68727. /**
  68728. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  68729. */
  68730. customMeshPosition: Vector3;
  68731. /**
  68732. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  68733. */
  68734. useCustomMeshPosition: boolean;
  68735. /**
  68736. * If the post-process should inverse the light scattering direction
  68737. */
  68738. invert: boolean;
  68739. /**
  68740. * The internal mesh used by the post-process
  68741. */
  68742. mesh: Mesh;
  68743. /**
  68744. * @hidden
  68745. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  68746. */
  68747. get useDiffuseColor(): boolean;
  68748. set useDiffuseColor(useDiffuseColor: boolean);
  68749. /**
  68750. * Array containing the excluded meshes not rendered in the internal pass
  68751. */
  68752. excludedMeshes: AbstractMesh[];
  68753. /**
  68754. * Controls the overall intensity of the post-process
  68755. */
  68756. exposure: number;
  68757. /**
  68758. * Dissipates each sample's contribution in range [0, 1]
  68759. */
  68760. decay: number;
  68761. /**
  68762. * Controls the overall intensity of each sample
  68763. */
  68764. weight: number;
  68765. /**
  68766. * Controls the density of each sample
  68767. */
  68768. density: number;
  68769. /**
  68770. * @constructor
  68771. * @param name The post-process name
  68772. * @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)
  68773. * @param camera The camera that the post-process will be attached to
  68774. * @param mesh The mesh used to create the light scattering
  68775. * @param samples The post-process quality, default 100
  68776. * @param samplingModeThe post-process filtering mode
  68777. * @param engine The babylon engine
  68778. * @param reusable If the post-process is reusable
  68779. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  68780. */
  68781. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  68782. /**
  68783. * Returns the string "VolumetricLightScatteringPostProcess"
  68784. * @returns "VolumetricLightScatteringPostProcess"
  68785. */
  68786. getClassName(): string;
  68787. private _isReady;
  68788. /**
  68789. * Sets the new light position for light scattering effect
  68790. * @param position The new custom light position
  68791. */
  68792. setCustomMeshPosition(position: Vector3): void;
  68793. /**
  68794. * Returns the light position for light scattering effect
  68795. * @return Vector3 The custom light position
  68796. */
  68797. getCustomMeshPosition(): Vector3;
  68798. /**
  68799. * Disposes the internal assets and detaches the post-process from the camera
  68800. */
  68801. dispose(camera: Camera): void;
  68802. /**
  68803. * Returns the render target texture used by the post-process
  68804. * @return the render target texture used by the post-process
  68805. */
  68806. getPass(): RenderTargetTexture;
  68807. private _meshExcluded;
  68808. private _createPass;
  68809. private _updateMeshScreenCoordinates;
  68810. /**
  68811. * Creates a default mesh for the Volumeric Light Scattering post-process
  68812. * @param name The mesh name
  68813. * @param scene The scene where to create the mesh
  68814. * @return the default mesh
  68815. */
  68816. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  68817. }
  68818. }
  68819. declare module "babylonjs/PostProcesses/index" {
  68820. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  68821. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  68822. export * from "babylonjs/PostProcesses/bloomEffect";
  68823. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  68824. export * from "babylonjs/PostProcesses/blurPostProcess";
  68825. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68826. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  68827. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  68828. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  68829. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68830. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  68831. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  68832. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  68833. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68834. export * from "babylonjs/PostProcesses/filterPostProcess";
  68835. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  68836. export * from "babylonjs/PostProcesses/grainPostProcess";
  68837. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  68838. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68839. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  68840. export * from "babylonjs/PostProcesses/passPostProcess";
  68841. export * from "babylonjs/PostProcesses/postProcess";
  68842. export * from "babylonjs/PostProcesses/postProcessManager";
  68843. export * from "babylonjs/PostProcesses/refractionPostProcess";
  68844. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  68845. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  68846. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  68847. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  68848. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  68849. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  68850. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  68851. }
  68852. declare module "babylonjs/Probes/index" {
  68853. export * from "babylonjs/Probes/reflectionProbe";
  68854. }
  68855. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  68856. import { Scene } from "babylonjs/scene";
  68857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68858. import { SmartArray } from "babylonjs/Misc/smartArray";
  68859. import { ISceneComponent } from "babylonjs/sceneComponent";
  68860. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  68861. import "babylonjs/Meshes/Builders/boxBuilder";
  68862. import "babylonjs/Shaders/color.fragment";
  68863. import "babylonjs/Shaders/color.vertex";
  68864. import { Color3 } from "babylonjs/Maths/math.color";
  68865. module "babylonjs/scene" {
  68866. interface Scene {
  68867. /** @hidden (Backing field) */
  68868. _boundingBoxRenderer: BoundingBoxRenderer;
  68869. /** @hidden (Backing field) */
  68870. _forceShowBoundingBoxes: boolean;
  68871. /**
  68872. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68873. */
  68874. forceShowBoundingBoxes: boolean;
  68875. /**
  68876. * Gets the bounding box renderer associated with the scene
  68877. * @returns a BoundingBoxRenderer
  68878. */
  68879. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68880. }
  68881. }
  68882. module "babylonjs/Meshes/abstractMesh" {
  68883. interface AbstractMesh {
  68884. /** @hidden (Backing field) */
  68885. _showBoundingBox: boolean;
  68886. /**
  68887. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68888. */
  68889. showBoundingBox: boolean;
  68890. }
  68891. }
  68892. /**
  68893. * Component responsible of rendering the bounding box of the meshes in a scene.
  68894. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68895. */
  68896. export class BoundingBoxRenderer implements ISceneComponent {
  68897. /**
  68898. * The component name helpfull to identify the component in the list of scene components.
  68899. */
  68900. readonly name: string;
  68901. /**
  68902. * The scene the component belongs to.
  68903. */
  68904. scene: Scene;
  68905. /**
  68906. * Color of the bounding box lines placed in front of an object
  68907. */
  68908. frontColor: Color3;
  68909. /**
  68910. * Color of the bounding box lines placed behind an object
  68911. */
  68912. backColor: Color3;
  68913. /**
  68914. * Defines if the renderer should show the back lines or not
  68915. */
  68916. showBackLines: boolean;
  68917. /**
  68918. * @hidden
  68919. */
  68920. renderList: SmartArray<BoundingBox>;
  68921. private _colorShader;
  68922. private _vertexBuffers;
  68923. private _indexBuffer;
  68924. private _fillIndexBuffer;
  68925. private _fillIndexData;
  68926. /**
  68927. * Instantiates a new bounding box renderer in a scene.
  68928. * @param scene the scene the renderer renders in
  68929. */
  68930. constructor(scene: Scene);
  68931. /**
  68932. * Registers the component in a given scene
  68933. */
  68934. register(): void;
  68935. private _evaluateSubMesh;
  68936. private _activeMesh;
  68937. private _prepareRessources;
  68938. private _createIndexBuffer;
  68939. /**
  68940. * Rebuilds the elements related to this component in case of
  68941. * context lost for instance.
  68942. */
  68943. rebuild(): void;
  68944. /**
  68945. * @hidden
  68946. */
  68947. reset(): void;
  68948. /**
  68949. * Render the bounding boxes of a specific rendering group
  68950. * @param renderingGroupId defines the rendering group to render
  68951. */
  68952. render(renderingGroupId: number): void;
  68953. /**
  68954. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68955. * @param mesh Define the mesh to render the occlusion bounding box for
  68956. */
  68957. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68958. /**
  68959. * Dispose and release the resources attached to this renderer.
  68960. */
  68961. dispose(): void;
  68962. }
  68963. }
  68964. declare module "babylonjs/Shaders/depth.fragment" {
  68965. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68966. /** @hidden */
  68967. export var depthPixelShader: {
  68968. name: string;
  68969. shader: string;
  68970. };
  68971. }
  68972. declare module "babylonjs/Rendering/depthRenderer" {
  68973. import { Nullable } from "babylonjs/types";
  68974. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68975. import { Scene } from "babylonjs/scene";
  68976. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68977. import { Camera } from "babylonjs/Cameras/camera";
  68978. import "babylonjs/Shaders/depth.fragment";
  68979. import "babylonjs/Shaders/depth.vertex";
  68980. /**
  68981. * This represents a depth renderer in Babylon.
  68982. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  68983. */
  68984. export class DepthRenderer {
  68985. private _scene;
  68986. private _depthMap;
  68987. private _effect;
  68988. private readonly _storeNonLinearDepth;
  68989. private readonly _clearColor;
  68990. /** Get if the depth renderer is using packed depth or not */
  68991. readonly isPacked: boolean;
  68992. private _cachedDefines;
  68993. private _camera;
  68994. /**
  68995. * Specifiess that the depth renderer will only be used within
  68996. * the camera it is created for.
  68997. * This can help forcing its rendering during the camera processing.
  68998. */
  68999. useOnlyInActiveCamera: boolean;
  69000. /** @hidden */
  69001. static _SceneComponentInitialization: (scene: Scene) => void;
  69002. /**
  69003. * Instantiates a depth renderer
  69004. * @param scene The scene the renderer belongs to
  69005. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  69006. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  69007. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69008. */
  69009. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  69010. /**
  69011. * Creates the depth rendering effect and checks if the effect is ready.
  69012. * @param subMesh The submesh to be used to render the depth map of
  69013. * @param useInstances If multiple world instances should be used
  69014. * @returns if the depth renderer is ready to render the depth map
  69015. */
  69016. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69017. /**
  69018. * Gets the texture which the depth map will be written to.
  69019. * @returns The depth map texture
  69020. */
  69021. getDepthMap(): RenderTargetTexture;
  69022. /**
  69023. * Disposes of the depth renderer.
  69024. */
  69025. dispose(): void;
  69026. }
  69027. }
  69028. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  69029. import { Nullable } from "babylonjs/types";
  69030. import { Scene } from "babylonjs/scene";
  69031. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  69032. import { Camera } from "babylonjs/Cameras/camera";
  69033. import { ISceneComponent } from "babylonjs/sceneComponent";
  69034. module "babylonjs/scene" {
  69035. interface Scene {
  69036. /** @hidden (Backing field) */
  69037. _depthRenderer: {
  69038. [id: string]: DepthRenderer;
  69039. };
  69040. /**
  69041. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69042. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69043. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69044. * @returns the created depth renderer
  69045. */
  69046. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69047. /**
  69048. * Disables a depth renderer for a given camera
  69049. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69050. */
  69051. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69052. }
  69053. }
  69054. /**
  69055. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69056. * in several rendering techniques.
  69057. */
  69058. export class DepthRendererSceneComponent implements ISceneComponent {
  69059. /**
  69060. * The component name helpfull to identify the component in the list of scene components.
  69061. */
  69062. readonly name: string;
  69063. /**
  69064. * The scene the component belongs to.
  69065. */
  69066. scene: Scene;
  69067. /**
  69068. * Creates a new instance of the component for the given scene
  69069. * @param scene Defines the scene to register the component in
  69070. */
  69071. constructor(scene: Scene);
  69072. /**
  69073. * Registers the component in a given scene
  69074. */
  69075. register(): void;
  69076. /**
  69077. * Rebuilds the elements related to this component in case of
  69078. * context lost for instance.
  69079. */
  69080. rebuild(): void;
  69081. /**
  69082. * Disposes the component and the associated ressources
  69083. */
  69084. dispose(): void;
  69085. private _gatherRenderTargets;
  69086. private _gatherActiveCameraRenderTargets;
  69087. }
  69088. }
  69089. declare module "babylonjs/Shaders/outline.fragment" {
  69090. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  69091. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  69092. /** @hidden */
  69093. export var outlinePixelShader: {
  69094. name: string;
  69095. shader: string;
  69096. };
  69097. }
  69098. declare module "babylonjs/Shaders/outline.vertex" {
  69099. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69100. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69101. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69102. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69103. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  69104. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69105. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69106. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69107. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  69108. /** @hidden */
  69109. export var outlineVertexShader: {
  69110. name: string;
  69111. shader: string;
  69112. };
  69113. }
  69114. declare module "babylonjs/Rendering/outlineRenderer" {
  69115. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69116. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  69117. import { Scene } from "babylonjs/scene";
  69118. import { ISceneComponent } from "babylonjs/sceneComponent";
  69119. import "babylonjs/Shaders/outline.fragment";
  69120. import "babylonjs/Shaders/outline.vertex";
  69121. module "babylonjs/scene" {
  69122. interface Scene {
  69123. /** @hidden */
  69124. _outlineRenderer: OutlineRenderer;
  69125. /**
  69126. * Gets the outline renderer associated with the scene
  69127. * @returns a OutlineRenderer
  69128. */
  69129. getOutlineRenderer(): OutlineRenderer;
  69130. }
  69131. }
  69132. module "babylonjs/Meshes/abstractMesh" {
  69133. interface AbstractMesh {
  69134. /** @hidden (Backing field) */
  69135. _renderOutline: boolean;
  69136. /**
  69137. * Gets or sets a boolean indicating if the outline must be rendered as well
  69138. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69139. */
  69140. renderOutline: boolean;
  69141. /** @hidden (Backing field) */
  69142. _renderOverlay: boolean;
  69143. /**
  69144. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69145. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69146. */
  69147. renderOverlay: boolean;
  69148. }
  69149. }
  69150. /**
  69151. * This class is responsible to draw bothe outline/overlay of meshes.
  69152. * It should not be used directly but through the available method on mesh.
  69153. */
  69154. export class OutlineRenderer implements ISceneComponent {
  69155. /**
  69156. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69157. */
  69158. private static _StencilReference;
  69159. /**
  69160. * The name of the component. Each component must have a unique name.
  69161. */
  69162. name: string;
  69163. /**
  69164. * The scene the component belongs to.
  69165. */
  69166. scene: Scene;
  69167. /**
  69168. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69169. */
  69170. zOffset: number;
  69171. private _engine;
  69172. private _effect;
  69173. private _cachedDefines;
  69174. private _savedDepthWrite;
  69175. /**
  69176. * Instantiates a new outline renderer. (There could be only one per scene).
  69177. * @param scene Defines the scene it belongs to
  69178. */
  69179. constructor(scene: Scene);
  69180. /**
  69181. * Register the component to one instance of a scene.
  69182. */
  69183. register(): void;
  69184. /**
  69185. * Rebuilds the elements related to this component in case of
  69186. * context lost for instance.
  69187. */
  69188. rebuild(): void;
  69189. /**
  69190. * Disposes the component and the associated ressources.
  69191. */
  69192. dispose(): void;
  69193. /**
  69194. * Renders the outline in the canvas.
  69195. * @param subMesh Defines the sumesh to render
  69196. * @param batch Defines the batch of meshes in case of instances
  69197. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69198. */
  69199. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69200. /**
  69201. * Returns whether or not the outline renderer is ready for a given submesh.
  69202. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69203. * @param subMesh Defines the submesh to check readyness for
  69204. * @param useInstances Defines wheter wee are trying to render instances or not
  69205. * @returns true if ready otherwise false
  69206. */
  69207. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69208. private _beforeRenderingMesh;
  69209. private _afterRenderingMesh;
  69210. }
  69211. }
  69212. declare module "babylonjs/Rendering/index" {
  69213. export * from "babylonjs/Rendering/boundingBoxRenderer";
  69214. export * from "babylonjs/Rendering/depthRenderer";
  69215. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  69216. export * from "babylonjs/Rendering/edgesRenderer";
  69217. export * from "babylonjs/Rendering/geometryBufferRenderer";
  69218. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  69219. export * from "babylonjs/Rendering/outlineRenderer";
  69220. export * from "babylonjs/Rendering/renderingGroup";
  69221. export * from "babylonjs/Rendering/renderingManager";
  69222. export * from "babylonjs/Rendering/utilityLayerRenderer";
  69223. }
  69224. declare module "babylonjs/Sprites/ISprites" {
  69225. /**
  69226. * Defines the basic options interface of a Sprite Frame Source Size.
  69227. */
  69228. export interface ISpriteJSONSpriteSourceSize {
  69229. /**
  69230. * number of the original width of the Frame
  69231. */
  69232. w: number;
  69233. /**
  69234. * number of the original height of the Frame
  69235. */
  69236. h: number;
  69237. }
  69238. /**
  69239. * Defines the basic options interface of a Sprite Frame Data.
  69240. */
  69241. export interface ISpriteJSONSpriteFrameData {
  69242. /**
  69243. * number of the x offset of the Frame
  69244. */
  69245. x: number;
  69246. /**
  69247. * number of the y offset of the Frame
  69248. */
  69249. y: number;
  69250. /**
  69251. * number of the width of the Frame
  69252. */
  69253. w: number;
  69254. /**
  69255. * number of the height of the Frame
  69256. */
  69257. h: number;
  69258. }
  69259. /**
  69260. * Defines the basic options interface of a JSON Sprite.
  69261. */
  69262. export interface ISpriteJSONSprite {
  69263. /**
  69264. * string name of the Frame
  69265. */
  69266. filename: string;
  69267. /**
  69268. * ISpriteJSONSpriteFrame basic object of the frame data
  69269. */
  69270. frame: ISpriteJSONSpriteFrameData;
  69271. /**
  69272. * boolean to flag is the frame was rotated.
  69273. */
  69274. rotated: boolean;
  69275. /**
  69276. * boolean to flag is the frame was trimmed.
  69277. */
  69278. trimmed: boolean;
  69279. /**
  69280. * ISpriteJSONSpriteFrame basic object of the source data
  69281. */
  69282. spriteSourceSize: ISpriteJSONSpriteFrameData;
  69283. /**
  69284. * ISpriteJSONSpriteFrame basic object of the source data
  69285. */
  69286. sourceSize: ISpriteJSONSpriteSourceSize;
  69287. }
  69288. /**
  69289. * Defines the basic options interface of a JSON atlas.
  69290. */
  69291. export interface ISpriteJSONAtlas {
  69292. /**
  69293. * Array of objects that contain the frame data.
  69294. */
  69295. frames: Array<ISpriteJSONSprite>;
  69296. /**
  69297. * object basic object containing the sprite meta data.
  69298. */
  69299. meta?: object;
  69300. }
  69301. }
  69302. declare module "babylonjs/Shaders/spriteMap.fragment" {
  69303. /** @hidden */
  69304. export var spriteMapPixelShader: {
  69305. name: string;
  69306. shader: string;
  69307. };
  69308. }
  69309. declare module "babylonjs/Shaders/spriteMap.vertex" {
  69310. /** @hidden */
  69311. export var spriteMapVertexShader: {
  69312. name: string;
  69313. shader: string;
  69314. };
  69315. }
  69316. declare module "babylonjs/Sprites/spriteMap" {
  69317. import { IDisposable, Scene } from "babylonjs/scene";
  69318. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  69319. import { Texture } from "babylonjs/Materials/Textures/texture";
  69320. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69321. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  69322. import "babylonjs/Meshes/Builders/planeBuilder";
  69323. import "babylonjs/Shaders/spriteMap.fragment";
  69324. import "babylonjs/Shaders/spriteMap.vertex";
  69325. /**
  69326. * Defines the basic options interface of a SpriteMap
  69327. */
  69328. export interface ISpriteMapOptions {
  69329. /**
  69330. * Vector2 of the number of cells in the grid.
  69331. */
  69332. stageSize?: Vector2;
  69333. /**
  69334. * Vector2 of the size of the output plane in World Units.
  69335. */
  69336. outputSize?: Vector2;
  69337. /**
  69338. * Vector3 of the position of the output plane in World Units.
  69339. */
  69340. outputPosition?: Vector3;
  69341. /**
  69342. * Vector3 of the rotation of the output plane.
  69343. */
  69344. outputRotation?: Vector3;
  69345. /**
  69346. * number of layers that the system will reserve in resources.
  69347. */
  69348. layerCount?: number;
  69349. /**
  69350. * number of max animation frames a single cell will reserve in resources.
  69351. */
  69352. maxAnimationFrames?: number;
  69353. /**
  69354. * number cell index of the base tile when the system compiles.
  69355. */
  69356. baseTile?: number;
  69357. /**
  69358. * boolean flip the sprite after its been repositioned by the framing data.
  69359. */
  69360. flipU?: boolean;
  69361. /**
  69362. * Vector3 scalar of the global RGB values of the SpriteMap.
  69363. */
  69364. colorMultiply?: Vector3;
  69365. }
  69366. /**
  69367. * Defines the IDisposable interface in order to be cleanable from resources.
  69368. */
  69369. export interface ISpriteMap extends IDisposable {
  69370. /**
  69371. * String name of the SpriteMap.
  69372. */
  69373. name: string;
  69374. /**
  69375. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  69376. */
  69377. atlasJSON: ISpriteJSONAtlas;
  69378. /**
  69379. * Texture of the SpriteMap.
  69380. */
  69381. spriteSheet: Texture;
  69382. /**
  69383. * The parameters to initialize the SpriteMap with.
  69384. */
  69385. options: ISpriteMapOptions;
  69386. }
  69387. /**
  69388. * Class used to manage a grid restricted sprite deployment on an Output plane.
  69389. */
  69390. export class SpriteMap implements ISpriteMap {
  69391. /** The Name of the spriteMap */
  69392. name: string;
  69393. /** The JSON file with the frame and meta data */
  69394. atlasJSON: ISpriteJSONAtlas;
  69395. /** The systems Sprite Sheet Texture */
  69396. spriteSheet: Texture;
  69397. /** Arguments passed with the Constructor */
  69398. options: ISpriteMapOptions;
  69399. /** Public Sprite Storage array, parsed from atlasJSON */
  69400. sprites: Array<ISpriteJSONSprite>;
  69401. /** Returns the Number of Sprites in the System */
  69402. get spriteCount(): number;
  69403. /** Returns the Position of Output Plane*/
  69404. get position(): Vector3;
  69405. /** Returns the Position of Output Plane*/
  69406. set position(v: Vector3);
  69407. /** Returns the Rotation of Output Plane*/
  69408. get rotation(): Vector3;
  69409. /** Returns the Rotation of Output Plane*/
  69410. set rotation(v: Vector3);
  69411. /** Sets the AnimationMap*/
  69412. get animationMap(): RawTexture;
  69413. /** Sets the AnimationMap*/
  69414. set animationMap(v: RawTexture);
  69415. /** Scene that the SpriteMap was created in */
  69416. private _scene;
  69417. /** Texture Buffer of Float32 that holds tile frame data*/
  69418. private _frameMap;
  69419. /** Texture Buffers of Float32 that holds tileMap data*/
  69420. private _tileMaps;
  69421. /** Texture Buffer of Float32 that holds Animation Data*/
  69422. private _animationMap;
  69423. /** Custom ShaderMaterial Central to the System*/
  69424. private _material;
  69425. /** Custom ShaderMaterial Central to the System*/
  69426. private _output;
  69427. /** Systems Time Ticker*/
  69428. private _time;
  69429. /**
  69430. * Creates a new SpriteMap
  69431. * @param name defines the SpriteMaps Name
  69432. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  69433. * @param spriteSheet is the Texture that the Sprites are on.
  69434. * @param options a basic deployment configuration
  69435. * @param scene The Scene that the map is deployed on
  69436. */
  69437. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  69438. /**
  69439. * Returns tileID location
  69440. * @returns Vector2 the cell position ID
  69441. */
  69442. getTileID(): Vector2;
  69443. /**
  69444. * Gets the UV location of the mouse over the SpriteMap.
  69445. * @returns Vector2 the UV position of the mouse interaction
  69446. */
  69447. getMousePosition(): Vector2;
  69448. /**
  69449. * Creates the "frame" texture Buffer
  69450. * -------------------------------------
  69451. * Structure of frames
  69452. * "filename": "Falling-Water-2.png",
  69453. * "frame": {"x":69,"y":103,"w":24,"h":32},
  69454. * "rotated": true,
  69455. * "trimmed": true,
  69456. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  69457. * "sourceSize": {"w":32,"h":32}
  69458. * @returns RawTexture of the frameMap
  69459. */
  69460. private _createFrameBuffer;
  69461. /**
  69462. * Creates the tileMap texture Buffer
  69463. * @param buffer normally and array of numbers, or a false to generate from scratch
  69464. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  69465. * @returns RawTexture of the tileMap
  69466. */
  69467. private _createTileBuffer;
  69468. /**
  69469. * Modifies the data of the tileMaps
  69470. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  69471. * @param pos is the iVector2 Coordinates of the Tile
  69472. * @param tile The SpriteIndex of the new Tile
  69473. */
  69474. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  69475. /**
  69476. * Creates the animationMap texture Buffer
  69477. * @param buffer normally and array of numbers, or a false to generate from scratch
  69478. * @returns RawTexture of the animationMap
  69479. */
  69480. private _createTileAnimationBuffer;
  69481. /**
  69482. * Modifies the data of the animationMap
  69483. * @param cellID is the Index of the Sprite
  69484. * @param _frame is the target Animation frame
  69485. * @param toCell is the Target Index of the next frame of the animation
  69486. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  69487. * @param speed is a global scalar of the time variable on the map.
  69488. */
  69489. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  69490. /**
  69491. * Exports the .tilemaps file
  69492. */
  69493. saveTileMaps(): void;
  69494. /**
  69495. * Imports the .tilemaps file
  69496. * @param url of the .tilemaps file
  69497. */
  69498. loadTileMaps(url: string): void;
  69499. /**
  69500. * Release associated resources
  69501. */
  69502. dispose(): void;
  69503. }
  69504. }
  69505. declare module "babylonjs/Sprites/spritePackedManager" {
  69506. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  69507. import { Scene } from "babylonjs/scene";
  69508. /**
  69509. * Class used to manage multiple sprites of different sizes on the same spritesheet
  69510. * @see http://doc.babylonjs.com/babylon101/sprites
  69511. */
  69512. export class SpritePackedManager extends SpriteManager {
  69513. /** defines the packed manager's name */
  69514. name: string;
  69515. /**
  69516. * Creates a new sprite manager from a packed sprite sheet
  69517. * @param name defines the manager's name
  69518. * @param imgUrl defines the sprite sheet url
  69519. * @param capacity defines the maximum allowed number of sprites
  69520. * @param scene defines the hosting scene
  69521. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  69522. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69523. * @param samplingMode defines the smapling mode to use with spritesheet
  69524. * @param fromPacked set to true; do not alter
  69525. */
  69526. constructor(
  69527. /** defines the packed manager's name */
  69528. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  69529. }
  69530. }
  69531. declare module "babylonjs/Sprites/index" {
  69532. export * from "babylonjs/Sprites/sprite";
  69533. export * from "babylonjs/Sprites/ISprites";
  69534. export * from "babylonjs/Sprites/spriteManager";
  69535. export * from "babylonjs/Sprites/spriteMap";
  69536. export * from "babylonjs/Sprites/spritePackedManager";
  69537. export * from "babylonjs/Sprites/spriteSceneComponent";
  69538. }
  69539. declare module "babylonjs/States/index" {
  69540. export * from "babylonjs/States/alphaCullingState";
  69541. export * from "babylonjs/States/depthCullingState";
  69542. export * from "babylonjs/States/stencilState";
  69543. }
  69544. declare module "babylonjs/Misc/assetsManager" {
  69545. import { Scene } from "babylonjs/scene";
  69546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69547. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69548. import { Skeleton } from "babylonjs/Bones/skeleton";
  69549. import { Observable } from "babylonjs/Misc/observable";
  69550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69551. import { Texture } from "babylonjs/Materials/Textures/texture";
  69552. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  69553. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  69554. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  69555. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  69556. /**
  69557. * Defines the list of states available for a task inside a AssetsManager
  69558. */
  69559. export enum AssetTaskState {
  69560. /**
  69561. * Initialization
  69562. */
  69563. INIT = 0,
  69564. /**
  69565. * Running
  69566. */
  69567. RUNNING = 1,
  69568. /**
  69569. * Done
  69570. */
  69571. DONE = 2,
  69572. /**
  69573. * Error
  69574. */
  69575. ERROR = 3
  69576. }
  69577. /**
  69578. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  69579. */
  69580. export abstract class AbstractAssetTask {
  69581. /**
  69582. * Task name
  69583. */ name: string;
  69584. /**
  69585. * Callback called when the task is successful
  69586. */
  69587. onSuccess: (task: any) => void;
  69588. /**
  69589. * Callback called when the task is not successful
  69590. */
  69591. onError: (task: any, message?: string, exception?: any) => void;
  69592. /**
  69593. * Creates a new AssetsManager
  69594. * @param name defines the name of the task
  69595. */
  69596. constructor(
  69597. /**
  69598. * Task name
  69599. */ name: string);
  69600. private _isCompleted;
  69601. private _taskState;
  69602. private _errorObject;
  69603. /**
  69604. * Get if the task is completed
  69605. */
  69606. get isCompleted(): boolean;
  69607. /**
  69608. * Gets the current state of the task
  69609. */
  69610. get taskState(): AssetTaskState;
  69611. /**
  69612. * Gets the current error object (if task is in error)
  69613. */
  69614. get errorObject(): {
  69615. message?: string;
  69616. exception?: any;
  69617. };
  69618. /**
  69619. * Internal only
  69620. * @hidden
  69621. */
  69622. _setErrorObject(message?: string, exception?: any): void;
  69623. /**
  69624. * Execute the current task
  69625. * @param scene defines the scene where you want your assets to be loaded
  69626. * @param onSuccess is a callback called when the task is successfully executed
  69627. * @param onError is a callback called if an error occurs
  69628. */
  69629. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69630. /**
  69631. * Execute the current task
  69632. * @param scene defines the scene where you want your assets to be loaded
  69633. * @param onSuccess is a callback called when the task is successfully executed
  69634. * @param onError is a callback called if an error occurs
  69635. */
  69636. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69637. /**
  69638. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  69639. * This can be used with failed tasks that have the reason for failure fixed.
  69640. */
  69641. reset(): void;
  69642. private onErrorCallback;
  69643. private onDoneCallback;
  69644. }
  69645. /**
  69646. * Define the interface used by progress events raised during assets loading
  69647. */
  69648. export interface IAssetsProgressEvent {
  69649. /**
  69650. * Defines the number of remaining tasks to process
  69651. */
  69652. remainingCount: number;
  69653. /**
  69654. * Defines the total number of tasks
  69655. */
  69656. totalCount: number;
  69657. /**
  69658. * Defines the task that was just processed
  69659. */
  69660. task: AbstractAssetTask;
  69661. }
  69662. /**
  69663. * Class used to share progress information about assets loading
  69664. */
  69665. export class AssetsProgressEvent implements IAssetsProgressEvent {
  69666. /**
  69667. * Defines the number of remaining tasks to process
  69668. */
  69669. remainingCount: number;
  69670. /**
  69671. * Defines the total number of tasks
  69672. */
  69673. totalCount: number;
  69674. /**
  69675. * Defines the task that was just processed
  69676. */
  69677. task: AbstractAssetTask;
  69678. /**
  69679. * Creates a AssetsProgressEvent
  69680. * @param remainingCount defines the number of remaining tasks to process
  69681. * @param totalCount defines the total number of tasks
  69682. * @param task defines the task that was just processed
  69683. */
  69684. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  69685. }
  69686. /**
  69687. * Define a task used by AssetsManager to load meshes
  69688. */
  69689. export class MeshAssetTask extends AbstractAssetTask {
  69690. /**
  69691. * Defines the name of the task
  69692. */
  69693. name: string;
  69694. /**
  69695. * Defines the list of mesh's names you want to load
  69696. */
  69697. meshesNames: any;
  69698. /**
  69699. * Defines the root url to use as a base to load your meshes and associated resources
  69700. */
  69701. rootUrl: string;
  69702. /**
  69703. * Defines the filename of the scene to load from
  69704. */
  69705. sceneFilename: string;
  69706. /**
  69707. * Gets the list of loaded meshes
  69708. */
  69709. loadedMeshes: Array<AbstractMesh>;
  69710. /**
  69711. * Gets the list of loaded particle systems
  69712. */
  69713. loadedParticleSystems: Array<IParticleSystem>;
  69714. /**
  69715. * Gets the list of loaded skeletons
  69716. */
  69717. loadedSkeletons: Array<Skeleton>;
  69718. /**
  69719. * Gets the list of loaded animation groups
  69720. */
  69721. loadedAnimationGroups: Array<AnimationGroup>;
  69722. /**
  69723. * Callback called when the task is successful
  69724. */
  69725. onSuccess: (task: MeshAssetTask) => void;
  69726. /**
  69727. * Callback called when the task is successful
  69728. */
  69729. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  69730. /**
  69731. * Creates a new MeshAssetTask
  69732. * @param name defines the name of the task
  69733. * @param meshesNames defines the list of mesh's names you want to load
  69734. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  69735. * @param sceneFilename defines the filename of the scene to load from
  69736. */
  69737. constructor(
  69738. /**
  69739. * Defines the name of the task
  69740. */
  69741. name: string,
  69742. /**
  69743. * Defines the list of mesh's names you want to load
  69744. */
  69745. meshesNames: any,
  69746. /**
  69747. * Defines the root url to use as a base to load your meshes and associated resources
  69748. */
  69749. rootUrl: string,
  69750. /**
  69751. * Defines the filename of the scene to load from
  69752. */
  69753. sceneFilename: string);
  69754. /**
  69755. * Execute the current task
  69756. * @param scene defines the scene where you want your assets to be loaded
  69757. * @param onSuccess is a callback called when the task is successfully executed
  69758. * @param onError is a callback called if an error occurs
  69759. */
  69760. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69761. }
  69762. /**
  69763. * Define a task used by AssetsManager to load text content
  69764. */
  69765. export class TextFileAssetTask extends AbstractAssetTask {
  69766. /**
  69767. * Defines the name of the task
  69768. */
  69769. name: string;
  69770. /**
  69771. * Defines the location of the file to load
  69772. */
  69773. url: string;
  69774. /**
  69775. * Gets the loaded text string
  69776. */
  69777. text: string;
  69778. /**
  69779. * Callback called when the task is successful
  69780. */
  69781. onSuccess: (task: TextFileAssetTask) => void;
  69782. /**
  69783. * Callback called when the task is successful
  69784. */
  69785. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  69786. /**
  69787. * Creates a new TextFileAssetTask object
  69788. * @param name defines the name of the task
  69789. * @param url defines the location of the file to load
  69790. */
  69791. constructor(
  69792. /**
  69793. * Defines the name of the task
  69794. */
  69795. name: string,
  69796. /**
  69797. * Defines the location of the file to load
  69798. */
  69799. url: string);
  69800. /**
  69801. * Execute the current task
  69802. * @param scene defines the scene where you want your assets to be loaded
  69803. * @param onSuccess is a callback called when the task is successfully executed
  69804. * @param onError is a callback called if an error occurs
  69805. */
  69806. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69807. }
  69808. /**
  69809. * Define a task used by AssetsManager to load binary data
  69810. */
  69811. export class BinaryFileAssetTask extends AbstractAssetTask {
  69812. /**
  69813. * Defines the name of the task
  69814. */
  69815. name: string;
  69816. /**
  69817. * Defines the location of the file to load
  69818. */
  69819. url: string;
  69820. /**
  69821. * Gets the lodaded data (as an array buffer)
  69822. */
  69823. data: ArrayBuffer;
  69824. /**
  69825. * Callback called when the task is successful
  69826. */
  69827. onSuccess: (task: BinaryFileAssetTask) => void;
  69828. /**
  69829. * Callback called when the task is successful
  69830. */
  69831. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69832. /**
  69833. * Creates a new BinaryFileAssetTask object
  69834. * @param name defines the name of the new task
  69835. * @param url defines the location of the file to load
  69836. */
  69837. constructor(
  69838. /**
  69839. * Defines the name of the task
  69840. */
  69841. name: string,
  69842. /**
  69843. * Defines the location of the file to load
  69844. */
  69845. url: string);
  69846. /**
  69847. * Execute the current task
  69848. * @param scene defines the scene where you want your assets to be loaded
  69849. * @param onSuccess is a callback called when the task is successfully executed
  69850. * @param onError is a callback called if an error occurs
  69851. */
  69852. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69853. }
  69854. /**
  69855. * Define a task used by AssetsManager to load images
  69856. */
  69857. export class ImageAssetTask extends AbstractAssetTask {
  69858. /**
  69859. * Defines the name of the task
  69860. */
  69861. name: string;
  69862. /**
  69863. * Defines the location of the image to load
  69864. */
  69865. url: string;
  69866. /**
  69867. * Gets the loaded images
  69868. */
  69869. image: HTMLImageElement;
  69870. /**
  69871. * Callback called when the task is successful
  69872. */
  69873. onSuccess: (task: ImageAssetTask) => void;
  69874. /**
  69875. * Callback called when the task is successful
  69876. */
  69877. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69878. /**
  69879. * Creates a new ImageAssetTask
  69880. * @param name defines the name of the task
  69881. * @param url defines the location of the image to load
  69882. */
  69883. constructor(
  69884. /**
  69885. * Defines the name of the task
  69886. */
  69887. name: string,
  69888. /**
  69889. * Defines the location of the image to load
  69890. */
  69891. url: string);
  69892. /**
  69893. * Execute the current task
  69894. * @param scene defines the scene where you want your assets to be loaded
  69895. * @param onSuccess is a callback called when the task is successfully executed
  69896. * @param onError is a callback called if an error occurs
  69897. */
  69898. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69899. }
  69900. /**
  69901. * Defines the interface used by texture loading tasks
  69902. */
  69903. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69904. /**
  69905. * Gets the loaded texture
  69906. */
  69907. texture: TEX;
  69908. }
  69909. /**
  69910. * Define a task used by AssetsManager to load 2D textures
  69911. */
  69912. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69913. /**
  69914. * Defines the name of the task
  69915. */
  69916. name: string;
  69917. /**
  69918. * Defines the location of the file to load
  69919. */
  69920. url: string;
  69921. /**
  69922. * Defines if mipmap should not be generated (default is false)
  69923. */
  69924. noMipmap?: boolean | undefined;
  69925. /**
  69926. * Defines if texture must be inverted on Y axis (default is false)
  69927. */
  69928. invertY?: boolean | undefined;
  69929. /**
  69930. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69931. */
  69932. samplingMode: number;
  69933. /**
  69934. * Gets the loaded texture
  69935. */
  69936. texture: Texture;
  69937. /**
  69938. * Callback called when the task is successful
  69939. */
  69940. onSuccess: (task: TextureAssetTask) => void;
  69941. /**
  69942. * Callback called when the task is successful
  69943. */
  69944. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69945. /**
  69946. * Creates a new TextureAssetTask object
  69947. * @param name defines the name of the task
  69948. * @param url defines the location of the file to load
  69949. * @param noMipmap defines if mipmap should not be generated (default is false)
  69950. * @param invertY defines if texture must be inverted on Y axis (default is false)
  69951. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69952. */
  69953. constructor(
  69954. /**
  69955. * Defines the name of the task
  69956. */
  69957. name: string,
  69958. /**
  69959. * Defines the location of the file to load
  69960. */
  69961. url: string,
  69962. /**
  69963. * Defines if mipmap should not be generated (default is false)
  69964. */
  69965. noMipmap?: boolean | undefined,
  69966. /**
  69967. * Defines if texture must be inverted on Y axis (default is false)
  69968. */
  69969. invertY?: boolean | undefined,
  69970. /**
  69971. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69972. */
  69973. samplingMode?: number);
  69974. /**
  69975. * Execute the current task
  69976. * @param scene defines the scene where you want your assets to be loaded
  69977. * @param onSuccess is a callback called when the task is successfully executed
  69978. * @param onError is a callback called if an error occurs
  69979. */
  69980. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69981. }
  69982. /**
  69983. * Define a task used by AssetsManager to load cube textures
  69984. */
  69985. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69986. /**
  69987. * Defines the name of the task
  69988. */
  69989. name: string;
  69990. /**
  69991. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69992. */
  69993. url: string;
  69994. /**
  69995. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69996. */
  69997. extensions?: string[] | undefined;
  69998. /**
  69999. * Defines if mipmaps should not be generated (default is false)
  70000. */
  70001. noMipmap?: boolean | undefined;
  70002. /**
  70003. * Defines the explicit list of files (undefined by default)
  70004. */
  70005. files?: string[] | undefined;
  70006. /**
  70007. * Gets the loaded texture
  70008. */
  70009. texture: CubeTexture;
  70010. /**
  70011. * Callback called when the task is successful
  70012. */
  70013. onSuccess: (task: CubeTextureAssetTask) => void;
  70014. /**
  70015. * Callback called when the task is successful
  70016. */
  70017. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70018. /**
  70019. * Creates a new CubeTextureAssetTask
  70020. * @param name defines the name of the task
  70021. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70022. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70023. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70024. * @param files defines the explicit list of files (undefined by default)
  70025. */
  70026. constructor(
  70027. /**
  70028. * Defines the name of the task
  70029. */
  70030. name: string,
  70031. /**
  70032. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70033. */
  70034. url: string,
  70035. /**
  70036. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70037. */
  70038. extensions?: string[] | undefined,
  70039. /**
  70040. * Defines if mipmaps should not be generated (default is false)
  70041. */
  70042. noMipmap?: boolean | undefined,
  70043. /**
  70044. * Defines the explicit list of files (undefined by default)
  70045. */
  70046. files?: string[] | undefined);
  70047. /**
  70048. * Execute the current task
  70049. * @param scene defines the scene where you want your assets to be loaded
  70050. * @param onSuccess is a callback called when the task is successfully executed
  70051. * @param onError is a callback called if an error occurs
  70052. */
  70053. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70054. }
  70055. /**
  70056. * Define a task used by AssetsManager to load HDR cube textures
  70057. */
  70058. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70059. /**
  70060. * Defines the name of the task
  70061. */
  70062. name: string;
  70063. /**
  70064. * Defines the location of the file to load
  70065. */
  70066. url: string;
  70067. /**
  70068. * Defines the desired size (the more it increases the longer the generation will be)
  70069. */
  70070. size: number;
  70071. /**
  70072. * Defines if mipmaps should not be generated (default is false)
  70073. */
  70074. noMipmap: boolean;
  70075. /**
  70076. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70077. */
  70078. generateHarmonics: boolean;
  70079. /**
  70080. * 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)
  70081. */
  70082. gammaSpace: boolean;
  70083. /**
  70084. * Internal Use Only
  70085. */
  70086. reserved: boolean;
  70087. /**
  70088. * Gets the loaded texture
  70089. */
  70090. texture: HDRCubeTexture;
  70091. /**
  70092. * Callback called when the task is successful
  70093. */
  70094. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70095. /**
  70096. * Callback called when the task is successful
  70097. */
  70098. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70099. /**
  70100. * Creates a new HDRCubeTextureAssetTask object
  70101. * @param name defines the name of the task
  70102. * @param url defines the location of the file to load
  70103. * @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.
  70104. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70105. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70106. * @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)
  70107. * @param reserved Internal use only
  70108. */
  70109. constructor(
  70110. /**
  70111. * Defines the name of the task
  70112. */
  70113. name: string,
  70114. /**
  70115. * Defines the location of the file to load
  70116. */
  70117. url: string,
  70118. /**
  70119. * Defines the desired size (the more it increases the longer the generation will be)
  70120. */
  70121. size: number,
  70122. /**
  70123. * Defines if mipmaps should not be generated (default is false)
  70124. */
  70125. noMipmap?: boolean,
  70126. /**
  70127. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70128. */
  70129. generateHarmonics?: boolean,
  70130. /**
  70131. * 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)
  70132. */
  70133. gammaSpace?: boolean,
  70134. /**
  70135. * Internal Use Only
  70136. */
  70137. reserved?: boolean);
  70138. /**
  70139. * Execute the current task
  70140. * @param scene defines the scene where you want your assets to be loaded
  70141. * @param onSuccess is a callback called when the task is successfully executed
  70142. * @param onError is a callback called if an error occurs
  70143. */
  70144. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70145. }
  70146. /**
  70147. * Define a task used by AssetsManager to load Equirectangular cube textures
  70148. */
  70149. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70150. /**
  70151. * Defines the name of the task
  70152. */
  70153. name: string;
  70154. /**
  70155. * Defines the location of the file to load
  70156. */
  70157. url: string;
  70158. /**
  70159. * Defines the desired size (the more it increases the longer the generation will be)
  70160. */
  70161. size: number;
  70162. /**
  70163. * Defines if mipmaps should not be generated (default is false)
  70164. */
  70165. noMipmap: boolean;
  70166. /**
  70167. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70168. * but the standard material would require them in Gamma space) (default is true)
  70169. */
  70170. gammaSpace: boolean;
  70171. /**
  70172. * Gets the loaded texture
  70173. */
  70174. texture: EquiRectangularCubeTexture;
  70175. /**
  70176. * Callback called when the task is successful
  70177. */
  70178. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70179. /**
  70180. * Callback called when the task is successful
  70181. */
  70182. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70183. /**
  70184. * Creates a new EquiRectangularCubeTextureAssetTask object
  70185. * @param name defines the name of the task
  70186. * @param url defines the location of the file to load
  70187. * @param size defines the desired size (the more it increases the longer the generation will be)
  70188. * If the size is omitted this implies you are using a preprocessed cubemap.
  70189. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70190. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70191. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70192. * (default is true)
  70193. */
  70194. constructor(
  70195. /**
  70196. * Defines the name of the task
  70197. */
  70198. name: string,
  70199. /**
  70200. * Defines the location of the file to load
  70201. */
  70202. url: string,
  70203. /**
  70204. * Defines the desired size (the more it increases the longer the generation will be)
  70205. */
  70206. size: number,
  70207. /**
  70208. * Defines if mipmaps should not be generated (default is false)
  70209. */
  70210. noMipmap?: boolean,
  70211. /**
  70212. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70213. * but the standard material would require them in Gamma space) (default is true)
  70214. */
  70215. gammaSpace?: boolean);
  70216. /**
  70217. * Execute the current task
  70218. * @param scene defines the scene where you want your assets to be loaded
  70219. * @param onSuccess is a callback called when the task is successfully executed
  70220. * @param onError is a callback called if an error occurs
  70221. */
  70222. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70223. }
  70224. /**
  70225. * This class can be used to easily import assets into a scene
  70226. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70227. */
  70228. export class AssetsManager {
  70229. private _scene;
  70230. private _isLoading;
  70231. protected _tasks: AbstractAssetTask[];
  70232. protected _waitingTasksCount: number;
  70233. protected _totalTasksCount: number;
  70234. /**
  70235. * Callback called when all tasks are processed
  70236. */
  70237. onFinish: (tasks: AbstractAssetTask[]) => void;
  70238. /**
  70239. * Callback called when a task is successful
  70240. */
  70241. onTaskSuccess: (task: AbstractAssetTask) => void;
  70242. /**
  70243. * Callback called when a task had an error
  70244. */
  70245. onTaskError: (task: AbstractAssetTask) => void;
  70246. /**
  70247. * Callback called when a task is done (whatever the result is)
  70248. */
  70249. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70250. /**
  70251. * Observable called when all tasks are processed
  70252. */
  70253. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70254. /**
  70255. * Observable called when a task had an error
  70256. */
  70257. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70258. /**
  70259. * Observable called when all tasks were executed
  70260. */
  70261. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70262. /**
  70263. * Observable called when a task is done (whatever the result is)
  70264. */
  70265. onProgressObservable: Observable<IAssetsProgressEvent>;
  70266. /**
  70267. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70268. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70269. */
  70270. useDefaultLoadingScreen: boolean;
  70271. /**
  70272. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70273. * when all assets have been downloaded.
  70274. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70275. */
  70276. autoHideLoadingUI: boolean;
  70277. /**
  70278. * Creates a new AssetsManager
  70279. * @param scene defines the scene to work on
  70280. */
  70281. constructor(scene: Scene);
  70282. /**
  70283. * Add a MeshAssetTask to the list of active tasks
  70284. * @param taskName defines the name of the new task
  70285. * @param meshesNames defines the name of meshes to load
  70286. * @param rootUrl defines the root url to use to locate files
  70287. * @param sceneFilename defines the filename of the scene file
  70288. * @returns a new MeshAssetTask object
  70289. */
  70290. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70291. /**
  70292. * Add a TextFileAssetTask to the list of active tasks
  70293. * @param taskName defines the name of the new task
  70294. * @param url defines the url of the file to load
  70295. * @returns a new TextFileAssetTask object
  70296. */
  70297. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70298. /**
  70299. * Add a BinaryFileAssetTask to the list of active tasks
  70300. * @param taskName defines the name of the new task
  70301. * @param url defines the url of the file to load
  70302. * @returns a new BinaryFileAssetTask object
  70303. */
  70304. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70305. /**
  70306. * Add a ImageAssetTask to the list of active tasks
  70307. * @param taskName defines the name of the new task
  70308. * @param url defines the url of the file to load
  70309. * @returns a new ImageAssetTask object
  70310. */
  70311. addImageTask(taskName: string, url: string): ImageAssetTask;
  70312. /**
  70313. * Add a TextureAssetTask to the list of active tasks
  70314. * @param taskName defines the name of the new task
  70315. * @param url defines the url of the file to load
  70316. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70317. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  70318. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  70319. * @returns a new TextureAssetTask object
  70320. */
  70321. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  70322. /**
  70323. * Add a CubeTextureAssetTask to the list of active tasks
  70324. * @param taskName defines the name of the new task
  70325. * @param url defines the url of the file to load
  70326. * @param extensions defines the extension to use to load the cube map (can be null)
  70327. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70328. * @param files defines the list of files to load (can be null)
  70329. * @returns a new CubeTextureAssetTask object
  70330. */
  70331. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  70332. /**
  70333. *
  70334. * Add a HDRCubeTextureAssetTask to the list of active tasks
  70335. * @param taskName defines the name of the new task
  70336. * @param url defines the url of the file to load
  70337. * @param size defines the size you want for the cubemap (can be null)
  70338. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70339. * @param generateHarmonics defines if you want to automatically generate (true by default)
  70340. * @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)
  70341. * @param reserved Internal use only
  70342. * @returns a new HDRCubeTextureAssetTask object
  70343. */
  70344. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  70345. /**
  70346. *
  70347. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  70348. * @param taskName defines the name of the new task
  70349. * @param url defines the url of the file to load
  70350. * @param size defines the size you want for the cubemap (can be null)
  70351. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70352. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  70353. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  70354. * @returns a new EquiRectangularCubeTextureAssetTask object
  70355. */
  70356. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  70357. /**
  70358. * Remove a task from the assets manager.
  70359. * @param task the task to remove
  70360. */
  70361. removeTask(task: AbstractAssetTask): void;
  70362. private _decreaseWaitingTasksCount;
  70363. private _runTask;
  70364. /**
  70365. * Reset the AssetsManager and remove all tasks
  70366. * @return the current instance of the AssetsManager
  70367. */
  70368. reset(): AssetsManager;
  70369. /**
  70370. * Start the loading process
  70371. * @return the current instance of the AssetsManager
  70372. */
  70373. load(): AssetsManager;
  70374. /**
  70375. * Start the loading process as an async operation
  70376. * @return a promise returning the list of failed tasks
  70377. */
  70378. loadAsync(): Promise<void>;
  70379. }
  70380. }
  70381. declare module "babylonjs/Misc/deferred" {
  70382. /**
  70383. * Wrapper class for promise with external resolve and reject.
  70384. */
  70385. export class Deferred<T> {
  70386. /**
  70387. * The promise associated with this deferred object.
  70388. */
  70389. readonly promise: Promise<T>;
  70390. private _resolve;
  70391. private _reject;
  70392. /**
  70393. * The resolve method of the promise associated with this deferred object.
  70394. */
  70395. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  70396. /**
  70397. * The reject method of the promise associated with this deferred object.
  70398. */
  70399. get reject(): (reason?: any) => void;
  70400. /**
  70401. * Constructor for this deferred object.
  70402. */
  70403. constructor();
  70404. }
  70405. }
  70406. declare module "babylonjs/Misc/meshExploder" {
  70407. import { Mesh } from "babylonjs/Meshes/mesh";
  70408. /**
  70409. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  70410. */
  70411. export class MeshExploder {
  70412. private _centerMesh;
  70413. private _meshes;
  70414. private _meshesOrigins;
  70415. private _toCenterVectors;
  70416. private _scaledDirection;
  70417. private _newPosition;
  70418. private _centerPosition;
  70419. /**
  70420. * Explodes meshes from a center mesh.
  70421. * @param meshes The meshes to explode.
  70422. * @param centerMesh The mesh to be center of explosion.
  70423. */
  70424. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  70425. private _setCenterMesh;
  70426. /**
  70427. * Get class name
  70428. * @returns "MeshExploder"
  70429. */
  70430. getClassName(): string;
  70431. /**
  70432. * "Exploded meshes"
  70433. * @returns Array of meshes with the centerMesh at index 0.
  70434. */
  70435. getMeshes(): Array<Mesh>;
  70436. /**
  70437. * Explodes meshes giving a specific direction
  70438. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  70439. */
  70440. explode(direction?: number): void;
  70441. }
  70442. }
  70443. declare module "babylonjs/Misc/filesInput" {
  70444. import { Engine } from "babylonjs/Engines/engine";
  70445. import { Scene } from "babylonjs/scene";
  70446. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  70447. /**
  70448. * Class used to help managing file picking and drag'n'drop
  70449. */
  70450. export class FilesInput {
  70451. /**
  70452. * List of files ready to be loaded
  70453. */
  70454. static get FilesToLoad(): {
  70455. [key: string]: File;
  70456. };
  70457. /**
  70458. * Callback called when a file is processed
  70459. */
  70460. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  70461. private _engine;
  70462. private _currentScene;
  70463. private _sceneLoadedCallback;
  70464. private _progressCallback;
  70465. private _additionalRenderLoopLogicCallback;
  70466. private _textureLoadingCallback;
  70467. private _startingProcessingFilesCallback;
  70468. private _onReloadCallback;
  70469. private _errorCallback;
  70470. private _elementToMonitor;
  70471. private _sceneFileToLoad;
  70472. private _filesToLoad;
  70473. /**
  70474. * Creates a new FilesInput
  70475. * @param engine defines the rendering engine
  70476. * @param scene defines the hosting scene
  70477. * @param sceneLoadedCallback callback called when scene is loaded
  70478. * @param progressCallback callback called to track progress
  70479. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  70480. * @param textureLoadingCallback callback called when a texture is loading
  70481. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  70482. * @param onReloadCallback callback called when a reload is requested
  70483. * @param errorCallback callback call if an error occurs
  70484. */
  70485. 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);
  70486. private _dragEnterHandler;
  70487. private _dragOverHandler;
  70488. private _dropHandler;
  70489. /**
  70490. * Calls this function to listen to drag'n'drop events on a specific DOM element
  70491. * @param elementToMonitor defines the DOM element to track
  70492. */
  70493. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  70494. /**
  70495. * Release all associated resources
  70496. */
  70497. dispose(): void;
  70498. private renderFunction;
  70499. private drag;
  70500. private drop;
  70501. private _traverseFolder;
  70502. private _processFiles;
  70503. /**
  70504. * Load files from a drop event
  70505. * @param event defines the drop event to use as source
  70506. */
  70507. loadFiles(event: any): void;
  70508. private _processReload;
  70509. /**
  70510. * Reload the current scene from the loaded files
  70511. */
  70512. reload(): void;
  70513. }
  70514. }
  70515. declare module "babylonjs/Misc/HighDynamicRange/index" {
  70516. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  70517. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  70518. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  70519. }
  70520. declare module "babylonjs/Misc/sceneOptimizer" {
  70521. import { Scene, IDisposable } from "babylonjs/scene";
  70522. import { Observable } from "babylonjs/Misc/observable";
  70523. /**
  70524. * Defines the root class used to create scene optimization to use with SceneOptimizer
  70525. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70526. */
  70527. export class SceneOptimization {
  70528. /**
  70529. * Defines the priority of this optimization (0 by default which means first in the list)
  70530. */
  70531. priority: number;
  70532. /**
  70533. * Gets a string describing the action executed by the current optimization
  70534. * @returns description string
  70535. */
  70536. getDescription(): string;
  70537. /**
  70538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70539. * @param scene defines the current scene where to apply this optimization
  70540. * @param optimizer defines the current optimizer
  70541. * @returns true if everything that can be done was applied
  70542. */
  70543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70544. /**
  70545. * Creates the SceneOptimization object
  70546. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70547. * @param desc defines the description associated with the optimization
  70548. */
  70549. constructor(
  70550. /**
  70551. * Defines the priority of this optimization (0 by default which means first in the list)
  70552. */
  70553. priority?: number);
  70554. }
  70555. /**
  70556. * Defines an optimization used to reduce the size of render target textures
  70557. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70558. */
  70559. export class TextureOptimization extends SceneOptimization {
  70560. /**
  70561. * Defines the priority of this optimization (0 by default which means first in the list)
  70562. */
  70563. priority: number;
  70564. /**
  70565. * 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
  70566. */
  70567. maximumSize: number;
  70568. /**
  70569. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70570. */
  70571. step: number;
  70572. /**
  70573. * Gets a string describing the action executed by the current optimization
  70574. * @returns description string
  70575. */
  70576. getDescription(): string;
  70577. /**
  70578. * Creates the TextureOptimization object
  70579. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70580. * @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
  70581. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70582. */
  70583. constructor(
  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 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
  70590. */
  70591. maximumSize?: number,
  70592. /**
  70593. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70594. */
  70595. step?: number);
  70596. /**
  70597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70598. * @param scene defines the current scene where to apply this optimization
  70599. * @param optimizer defines the current optimizer
  70600. * @returns true if everything that can be done was applied
  70601. */
  70602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70603. }
  70604. /**
  70605. * Defines an optimization used to increase or decrease the rendering resolution
  70606. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70607. */
  70608. export class HardwareScalingOptimization extends SceneOptimization {
  70609. /**
  70610. * Defines the priority of this optimization (0 by default which means first in the list)
  70611. */
  70612. priority: number;
  70613. /**
  70614. * Defines the maximum scale to use (2 by default)
  70615. */
  70616. maximumScale: number;
  70617. /**
  70618. * Defines the step to use between two passes (0.5 by default)
  70619. */
  70620. step: number;
  70621. private _currentScale;
  70622. private _directionOffset;
  70623. /**
  70624. * Gets a string describing the action executed by the current optimization
  70625. * @return description string
  70626. */
  70627. getDescription(): string;
  70628. /**
  70629. * Creates the HardwareScalingOptimization object
  70630. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70631. * @param maximumScale defines the maximum scale to use (2 by default)
  70632. * @param step defines the step to use between two passes (0.5 by default)
  70633. */
  70634. constructor(
  70635. /**
  70636. * Defines the priority of this optimization (0 by default which means first in the list)
  70637. */
  70638. priority?: number,
  70639. /**
  70640. * Defines the maximum scale to use (2 by default)
  70641. */
  70642. maximumScale?: number,
  70643. /**
  70644. * Defines the step to use between two passes (0.5 by default)
  70645. */
  70646. step?: number);
  70647. /**
  70648. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70649. * @param scene defines the current scene where to apply this optimization
  70650. * @param optimizer defines the current optimizer
  70651. * @returns true if everything that can be done was applied
  70652. */
  70653. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70654. }
  70655. /**
  70656. * Defines an optimization used to remove shadows
  70657. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70658. */
  70659. export class ShadowsOptimization extends SceneOptimization {
  70660. /**
  70661. * Gets a string describing the action executed by the current optimization
  70662. * @return description string
  70663. */
  70664. getDescription(): string;
  70665. /**
  70666. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70667. * @param scene defines the current scene where to apply this optimization
  70668. * @param optimizer defines the current optimizer
  70669. * @returns true if everything that can be done was applied
  70670. */
  70671. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70672. }
  70673. /**
  70674. * Defines an optimization used to turn post-processes off
  70675. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70676. */
  70677. export class PostProcessesOptimization extends SceneOptimization {
  70678. /**
  70679. * Gets a string describing the action executed by the current optimization
  70680. * @return description string
  70681. */
  70682. getDescription(): string;
  70683. /**
  70684. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70685. * @param scene defines the current scene where to apply this optimization
  70686. * @param optimizer defines the current optimizer
  70687. * @returns true if everything that can be done was applied
  70688. */
  70689. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70690. }
  70691. /**
  70692. * Defines an optimization used to turn lens flares off
  70693. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70694. */
  70695. export class LensFlaresOptimization extends SceneOptimization {
  70696. /**
  70697. * Gets a string describing the action executed by the current optimization
  70698. * @return description string
  70699. */
  70700. getDescription(): string;
  70701. /**
  70702. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70703. * @param scene defines the current scene where to apply this optimization
  70704. * @param optimizer defines the current optimizer
  70705. * @returns true if everything that can be done was applied
  70706. */
  70707. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70708. }
  70709. /**
  70710. * Defines an optimization based on user defined callback.
  70711. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70712. */
  70713. export class CustomOptimization extends SceneOptimization {
  70714. /**
  70715. * Callback called to apply the custom optimization.
  70716. */
  70717. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  70718. /**
  70719. * Callback called to get custom description
  70720. */
  70721. onGetDescription: () => string;
  70722. /**
  70723. * Gets a string describing the action executed by the current optimization
  70724. * @returns description string
  70725. */
  70726. getDescription(): string;
  70727. /**
  70728. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70729. * @param scene defines the current scene where to apply this optimization
  70730. * @param optimizer defines the current optimizer
  70731. * @returns true if everything that can be done was applied
  70732. */
  70733. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70734. }
  70735. /**
  70736. * Defines an optimization used to turn particles off
  70737. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70738. */
  70739. export class ParticlesOptimization extends SceneOptimization {
  70740. /**
  70741. * Gets a string describing the action executed by the current optimization
  70742. * @return description string
  70743. */
  70744. getDescription(): string;
  70745. /**
  70746. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70747. * @param scene defines the current scene where to apply this optimization
  70748. * @param optimizer defines the current optimizer
  70749. * @returns true if everything that can be done was applied
  70750. */
  70751. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70752. }
  70753. /**
  70754. * Defines an optimization used to turn render targets off
  70755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70756. */
  70757. export class RenderTargetsOptimization extends SceneOptimization {
  70758. /**
  70759. * Gets a string describing the action executed by the current optimization
  70760. * @return description string
  70761. */
  70762. getDescription(): string;
  70763. /**
  70764. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70765. * @param scene defines the current scene where to apply this optimization
  70766. * @param optimizer defines the current optimizer
  70767. * @returns true if everything that can be done was applied
  70768. */
  70769. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70770. }
  70771. /**
  70772. * Defines an optimization used to merge meshes with compatible materials
  70773. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70774. */
  70775. export class MergeMeshesOptimization extends SceneOptimization {
  70776. private static _UpdateSelectionTree;
  70777. /**
  70778. * Gets or sets a boolean which defines if optimization octree has to be updated
  70779. */
  70780. static get UpdateSelectionTree(): boolean;
  70781. /**
  70782. * Gets or sets a boolean which defines if optimization octree has to be updated
  70783. */
  70784. static set UpdateSelectionTree(value: boolean);
  70785. /**
  70786. * Gets a string describing the action executed by the current optimization
  70787. * @return description string
  70788. */
  70789. getDescription(): string;
  70790. private _canBeMerged;
  70791. /**
  70792. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70793. * @param scene defines the current scene where to apply this optimization
  70794. * @param optimizer defines the current optimizer
  70795. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  70796. * @returns true if everything that can be done was applied
  70797. */
  70798. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  70799. }
  70800. /**
  70801. * Defines a list of options used by SceneOptimizer
  70802. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70803. */
  70804. export class SceneOptimizerOptions {
  70805. /**
  70806. * Defines the target frame rate to reach (60 by default)
  70807. */
  70808. targetFrameRate: number;
  70809. /**
  70810. * Defines the interval between two checkes (2000ms by default)
  70811. */
  70812. trackerDuration: number;
  70813. /**
  70814. * Gets the list of optimizations to apply
  70815. */
  70816. optimizations: SceneOptimization[];
  70817. /**
  70818. * Creates a new list of options used by SceneOptimizer
  70819. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  70820. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  70821. */
  70822. constructor(
  70823. /**
  70824. * Defines the target frame rate to reach (60 by default)
  70825. */
  70826. targetFrameRate?: number,
  70827. /**
  70828. * Defines the interval between two checkes (2000ms by default)
  70829. */
  70830. trackerDuration?: number);
  70831. /**
  70832. * Add a new optimization
  70833. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70834. * @returns the current SceneOptimizerOptions
  70835. */
  70836. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70837. /**
  70838. * Add a new custom optimization
  70839. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70840. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70841. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70842. * @returns the current SceneOptimizerOptions
  70843. */
  70844. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70845. /**
  70846. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70847. * @param targetFrameRate defines the target frame rate (60 by default)
  70848. * @returns a SceneOptimizerOptions object
  70849. */
  70850. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70851. /**
  70852. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70853. * @param targetFrameRate defines the target frame rate (60 by default)
  70854. * @returns a SceneOptimizerOptions object
  70855. */
  70856. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70857. /**
  70858. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70859. * @param targetFrameRate defines the target frame rate (60 by default)
  70860. * @returns a SceneOptimizerOptions object
  70861. */
  70862. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70863. }
  70864. /**
  70865. * Class used to run optimizations in order to reach a target frame rate
  70866. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70867. */
  70868. export class SceneOptimizer implements IDisposable {
  70869. private _isRunning;
  70870. private _options;
  70871. private _scene;
  70872. private _currentPriorityLevel;
  70873. private _targetFrameRate;
  70874. private _trackerDuration;
  70875. private _currentFrameRate;
  70876. private _sceneDisposeObserver;
  70877. private _improvementMode;
  70878. /**
  70879. * Defines an observable called when the optimizer reaches the target frame rate
  70880. */
  70881. onSuccessObservable: Observable<SceneOptimizer>;
  70882. /**
  70883. * Defines an observable called when the optimizer enables an optimization
  70884. */
  70885. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70886. /**
  70887. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70888. */
  70889. onFailureObservable: Observable<SceneOptimizer>;
  70890. /**
  70891. * Gets a boolean indicating if the optimizer is in improvement mode
  70892. */
  70893. get isInImprovementMode(): boolean;
  70894. /**
  70895. * Gets the current priority level (0 at start)
  70896. */
  70897. get currentPriorityLevel(): number;
  70898. /**
  70899. * Gets the current frame rate checked by the SceneOptimizer
  70900. */
  70901. get currentFrameRate(): number;
  70902. /**
  70903. * Gets or sets the current target frame rate (60 by default)
  70904. */
  70905. get targetFrameRate(): number;
  70906. /**
  70907. * Gets or sets the current target frame rate (60 by default)
  70908. */
  70909. set targetFrameRate(value: number);
  70910. /**
  70911. * Gets or sets the current interval between two checks (every 2000ms by default)
  70912. */
  70913. get trackerDuration(): number;
  70914. /**
  70915. * Gets or sets the current interval between two checks (every 2000ms by default)
  70916. */
  70917. set trackerDuration(value: number);
  70918. /**
  70919. * Gets the list of active optimizations
  70920. */
  70921. get optimizations(): SceneOptimization[];
  70922. /**
  70923. * Creates a new SceneOptimizer
  70924. * @param scene defines the scene to work on
  70925. * @param options defines the options to use with the SceneOptimizer
  70926. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70927. * @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)
  70928. */
  70929. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70930. /**
  70931. * Stops the current optimizer
  70932. */
  70933. stop(): void;
  70934. /**
  70935. * Reset the optimizer to initial step (current priority level = 0)
  70936. */
  70937. reset(): void;
  70938. /**
  70939. * Start the optimizer. By default it will try to reach a specific framerate
  70940. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70941. */
  70942. start(): void;
  70943. private _checkCurrentState;
  70944. /**
  70945. * Release all resources
  70946. */
  70947. dispose(): void;
  70948. /**
  70949. * Helper function to create a SceneOptimizer with one single line of code
  70950. * @param scene defines the scene to work on
  70951. * @param options defines the options to use with the SceneOptimizer
  70952. * @param onSuccess defines a callback to call on success
  70953. * @param onFailure defines a callback to call on failure
  70954. * @returns the new SceneOptimizer object
  70955. */
  70956. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70957. }
  70958. }
  70959. declare module "babylonjs/Misc/sceneSerializer" {
  70960. import { Scene } from "babylonjs/scene";
  70961. /**
  70962. * Class used to serialize a scene into a string
  70963. */
  70964. export class SceneSerializer {
  70965. /**
  70966. * Clear cache used by a previous serialization
  70967. */
  70968. static ClearCache(): void;
  70969. /**
  70970. * Serialize a scene into a JSON compatible object
  70971. * @param scene defines the scene to serialize
  70972. * @returns a JSON compatible object
  70973. */
  70974. static Serialize(scene: Scene): any;
  70975. /**
  70976. * Serialize a mesh into a JSON compatible object
  70977. * @param toSerialize defines the mesh to serialize
  70978. * @param withParents defines if parents must be serialized as well
  70979. * @param withChildren defines if children must be serialized as well
  70980. * @returns a JSON compatible object
  70981. */
  70982. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70983. }
  70984. }
  70985. declare module "babylonjs/Misc/textureTools" {
  70986. import { Texture } from "babylonjs/Materials/Textures/texture";
  70987. /**
  70988. * Class used to host texture specific utilities
  70989. */
  70990. export class TextureTools {
  70991. /**
  70992. * Uses the GPU to create a copy texture rescaled at a given size
  70993. * @param texture Texture to copy from
  70994. * @param width defines the desired width
  70995. * @param height defines the desired height
  70996. * @param useBilinearMode defines if bilinear mode has to be used
  70997. * @return the generated texture
  70998. */
  70999. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71000. }
  71001. }
  71002. declare module "babylonjs/Misc/videoRecorder" {
  71003. import { Nullable } from "babylonjs/types";
  71004. import { Engine } from "babylonjs/Engines/engine";
  71005. /**
  71006. * This represents the different options available for the video capture.
  71007. */
  71008. export interface VideoRecorderOptions {
  71009. /** Defines the mime type of the video. */
  71010. mimeType: string;
  71011. /** Defines the FPS the video should be recorded at. */
  71012. fps: number;
  71013. /** Defines the chunk size for the recording data. */
  71014. recordChunckSize: number;
  71015. /** The audio tracks to attach to the recording. */
  71016. audioTracks?: MediaStreamTrack[];
  71017. }
  71018. /**
  71019. * This can help with recording videos from BabylonJS.
  71020. * This is based on the available WebRTC functionalities of the browser.
  71021. *
  71022. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71023. */
  71024. export class VideoRecorder {
  71025. private static readonly _defaultOptions;
  71026. /**
  71027. * Returns whether or not the VideoRecorder is available in your browser.
  71028. * @param engine Defines the Babylon Engine.
  71029. * @returns true if supported otherwise false.
  71030. */
  71031. static IsSupported(engine: Engine): boolean;
  71032. private readonly _options;
  71033. private _canvas;
  71034. private _mediaRecorder;
  71035. private _recordedChunks;
  71036. private _fileName;
  71037. private _resolve;
  71038. private _reject;
  71039. /**
  71040. * True when a recording is already in progress.
  71041. */
  71042. get isRecording(): boolean;
  71043. /**
  71044. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71045. * @param engine Defines the BabylonJS Engine you wish to record.
  71046. * @param options Defines options that can be used to customize the capture.
  71047. */
  71048. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71049. /**
  71050. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71051. */
  71052. stopRecording(): void;
  71053. /**
  71054. * Starts recording the canvas for a max duration specified in parameters.
  71055. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71056. * If null no automatic download will start and you can rely on the promise to get the data back.
  71057. * @param maxDuration Defines the maximum recording time in seconds.
  71058. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71059. * @return A promise callback at the end of the recording with the video data in Blob.
  71060. */
  71061. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71062. /**
  71063. * Releases internal resources used during the recording.
  71064. */
  71065. dispose(): void;
  71066. private _handleDataAvailable;
  71067. private _handleError;
  71068. private _handleStop;
  71069. }
  71070. }
  71071. declare module "babylonjs/Misc/screenshotTools" {
  71072. import { Camera } from "babylonjs/Cameras/camera";
  71073. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  71074. import { Engine } from "babylonjs/Engines/engine";
  71075. /**
  71076. * Class containing a set of static utilities functions for screenshots
  71077. */
  71078. export class ScreenshotTools {
  71079. /**
  71080. * Captures a screenshot of the current rendering
  71081. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71082. * @param engine defines the rendering engine
  71083. * @param camera defines the source camera
  71084. * @param size This parameter can be set to a single number or to an object with the
  71085. * following (optional) properties: precision, width, height. If a single number is passed,
  71086. * it will be used for both width and height. If an object is passed, the screenshot size
  71087. * will be derived from the parameters. The precision property is a multiplier allowing
  71088. * rendering at a higher or lower resolution
  71089. * @param successCallback defines the callback receives a single parameter which contains the
  71090. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71091. * src parameter of an <img> to display it
  71092. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71093. * Check your browser for supported MIME types
  71094. */
  71095. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71096. /**
  71097. * Captures a screenshot of the current rendering
  71098. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71099. * @param engine defines the rendering engine
  71100. * @param camera defines the source camera
  71101. * @param size This parameter can be set to a single number or to an object with the
  71102. * following (optional) properties: precision, width, height. If a single number is passed,
  71103. * it will be used for both width and height. If an object is passed, the screenshot size
  71104. * will be derived from the parameters. The precision property is a multiplier allowing
  71105. * rendering at a higher or lower resolution
  71106. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71107. * Check your browser for supported MIME types
  71108. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71109. * to the src parameter of an <img> to display it
  71110. */
  71111. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71112. /**
  71113. * Generates an image screenshot from the specified camera.
  71114. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71115. * @param engine The engine to use for rendering
  71116. * @param camera The camera to use for rendering
  71117. * @param size This parameter can be set to a single number or to an object with the
  71118. * following (optional) properties: precision, width, height. If a single number is passed,
  71119. * it will be used for both width and height. If an object is passed, the screenshot size
  71120. * will be derived from the parameters. The precision property is a multiplier allowing
  71121. * rendering at a higher or lower resolution
  71122. * @param successCallback The callback receives a single parameter which contains the
  71123. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71124. * src parameter of an <img> to display it
  71125. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71126. * Check your browser for supported MIME types
  71127. * @param samples Texture samples (default: 1)
  71128. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71129. * @param fileName A name for for the downloaded file.
  71130. */
  71131. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  71132. /**
  71133. * Generates an image screenshot from the specified camera.
  71134. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71135. * @param engine The engine to use for rendering
  71136. * @param camera The camera to use for rendering
  71137. * @param size This parameter can be set to a single number or to an object with the
  71138. * following (optional) properties: precision, width, height. If a single number is passed,
  71139. * it will be used for both width and height. If an object is passed, the screenshot size
  71140. * will be derived from the parameters. The precision property is a multiplier allowing
  71141. * rendering at a higher or lower resolution
  71142. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71143. * Check your browser for supported MIME types
  71144. * @param samples Texture samples (default: 1)
  71145. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71146. * @param fileName A name for for the downloaded file.
  71147. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71148. * to the src parameter of an <img> to display it
  71149. */
  71150. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  71151. /**
  71152. * Gets height and width for screenshot size
  71153. * @private
  71154. */
  71155. private static _getScreenshotSize;
  71156. }
  71157. }
  71158. declare module "babylonjs/Misc/dataReader" {
  71159. /**
  71160. * Interface for a data buffer
  71161. */
  71162. export interface IDataBuffer {
  71163. /**
  71164. * Reads bytes from the data buffer.
  71165. * @param byteOffset The byte offset to read
  71166. * @param byteLength The byte length to read
  71167. * @returns A promise that resolves when the bytes are read
  71168. */
  71169. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71170. /**
  71171. * The byte length of the buffer.
  71172. */
  71173. readonly byteLength: number;
  71174. }
  71175. /**
  71176. * Utility class for reading from a data buffer
  71177. */
  71178. export class DataReader {
  71179. /**
  71180. * The data buffer associated with this data reader.
  71181. */
  71182. readonly buffer: IDataBuffer;
  71183. /**
  71184. * The current byte offset from the beginning of the data buffer.
  71185. */
  71186. byteOffset: number;
  71187. private _dataView;
  71188. private _dataByteOffset;
  71189. /**
  71190. * Constructor
  71191. * @param buffer The buffer to read
  71192. */
  71193. constructor(buffer: IDataBuffer);
  71194. /**
  71195. * Loads the given byte length.
  71196. * @param byteLength The byte length to load
  71197. * @returns A promise that resolves when the load is complete
  71198. */
  71199. loadAsync(byteLength: number): Promise<void>;
  71200. /**
  71201. * Read a unsigned 32-bit integer from the currently loaded data range.
  71202. * @returns The 32-bit integer read
  71203. */
  71204. readUint32(): number;
  71205. /**
  71206. * Read a byte array from the currently loaded data range.
  71207. * @param byteLength The byte length to read
  71208. * @returns The byte array read
  71209. */
  71210. readUint8Array(byteLength: number): Uint8Array;
  71211. /**
  71212. * Read a string from the currently loaded data range.
  71213. * @param byteLength The byte length to read
  71214. * @returns The string read
  71215. */
  71216. readString(byteLength: number): string;
  71217. /**
  71218. * Skips the given byte length the currently loaded data range.
  71219. * @param byteLength The byte length to skip
  71220. */
  71221. skipBytes(byteLength: number): void;
  71222. }
  71223. }
  71224. declare module "babylonjs/Misc/index" {
  71225. export * from "babylonjs/Misc/andOrNotEvaluator";
  71226. export * from "babylonjs/Misc/assetsManager";
  71227. export * from "babylonjs/Misc/basis";
  71228. export * from "babylonjs/Misc/dds";
  71229. export * from "babylonjs/Misc/decorators";
  71230. export * from "babylonjs/Misc/deferred";
  71231. export * from "babylonjs/Misc/environmentTextureTools";
  71232. export * from "babylonjs/Misc/meshExploder";
  71233. export * from "babylonjs/Misc/filesInput";
  71234. export * from "babylonjs/Misc/HighDynamicRange/index";
  71235. export * from "babylonjs/Misc/khronosTextureContainer";
  71236. export * from "babylonjs/Misc/observable";
  71237. export * from "babylonjs/Misc/performanceMonitor";
  71238. export * from "babylonjs/Misc/promise";
  71239. export * from "babylonjs/Misc/sceneOptimizer";
  71240. export * from "babylonjs/Misc/sceneSerializer";
  71241. export * from "babylonjs/Misc/smartArray";
  71242. export * from "babylonjs/Misc/stringDictionary";
  71243. export * from "babylonjs/Misc/tags";
  71244. export * from "babylonjs/Misc/textureTools";
  71245. export * from "babylonjs/Misc/tga";
  71246. export * from "babylonjs/Misc/tools";
  71247. export * from "babylonjs/Misc/videoRecorder";
  71248. export * from "babylonjs/Misc/virtualJoystick";
  71249. export * from "babylonjs/Misc/workerPool";
  71250. export * from "babylonjs/Misc/logger";
  71251. export * from "babylonjs/Misc/typeStore";
  71252. export * from "babylonjs/Misc/filesInputStore";
  71253. export * from "babylonjs/Misc/deepCopier";
  71254. export * from "babylonjs/Misc/pivotTools";
  71255. export * from "babylonjs/Misc/precisionDate";
  71256. export * from "babylonjs/Misc/screenshotTools";
  71257. export * from "babylonjs/Misc/typeStore";
  71258. export * from "babylonjs/Misc/webRequest";
  71259. export * from "babylonjs/Misc/iInspectable";
  71260. export * from "babylonjs/Misc/brdfTextureTools";
  71261. export * from "babylonjs/Misc/rgbdTextureTools";
  71262. export * from "babylonjs/Misc/gradients";
  71263. export * from "babylonjs/Misc/perfCounter";
  71264. export * from "babylonjs/Misc/fileRequest";
  71265. export * from "babylonjs/Misc/customAnimationFrameRequester";
  71266. export * from "babylonjs/Misc/retryStrategy";
  71267. export * from "babylonjs/Misc/interfaces/screenshotSize";
  71268. export * from "babylonjs/Misc/canvasGenerator";
  71269. export * from "babylonjs/Misc/fileTools";
  71270. export * from "babylonjs/Misc/stringTools";
  71271. export * from "babylonjs/Misc/dataReader";
  71272. }
  71273. declare module "babylonjs/index" {
  71274. export * from "babylonjs/abstractScene";
  71275. export * from "babylonjs/Actions/index";
  71276. export * from "babylonjs/Animations/index";
  71277. export * from "babylonjs/assetContainer";
  71278. export * from "babylonjs/Audio/index";
  71279. export * from "babylonjs/Behaviors/index";
  71280. export * from "babylonjs/Bones/index";
  71281. export * from "babylonjs/Cameras/index";
  71282. export * from "babylonjs/Collisions/index";
  71283. export * from "babylonjs/Culling/index";
  71284. export * from "babylonjs/Debug/index";
  71285. export * from "babylonjs/Engines/index";
  71286. export * from "babylonjs/Events/index";
  71287. export * from "babylonjs/Gamepads/index";
  71288. export * from "babylonjs/Gizmos/index";
  71289. export * from "babylonjs/Helpers/index";
  71290. export * from "babylonjs/Instrumentation/index";
  71291. export * from "babylonjs/Layers/index";
  71292. export * from "babylonjs/LensFlares/index";
  71293. export * from "babylonjs/Lights/index";
  71294. export * from "babylonjs/Loading/index";
  71295. export * from "babylonjs/Materials/index";
  71296. export * from "babylonjs/Maths/index";
  71297. export * from "babylonjs/Meshes/index";
  71298. export * from "babylonjs/Morph/index";
  71299. export * from "babylonjs/Navigation/index";
  71300. export * from "babylonjs/node";
  71301. export * from "babylonjs/Offline/index";
  71302. export * from "babylonjs/Particles/index";
  71303. export * from "babylonjs/Physics/index";
  71304. export * from "babylonjs/PostProcesses/index";
  71305. export * from "babylonjs/Probes/index";
  71306. export * from "babylonjs/Rendering/index";
  71307. export * from "babylonjs/scene";
  71308. export * from "babylonjs/sceneComponent";
  71309. export * from "babylonjs/Sprites/index";
  71310. export * from "babylonjs/States/index";
  71311. export * from "babylonjs/Misc/index";
  71312. export * from "babylonjs/types";
  71313. }
  71314. declare module "babylonjs/Animations/pathCursor" {
  71315. import { Vector3 } from "babylonjs/Maths/math.vector";
  71316. import { Path2 } from "babylonjs/Maths/math.path";
  71317. /**
  71318. * A cursor which tracks a point on a path
  71319. */
  71320. export class PathCursor {
  71321. private path;
  71322. /**
  71323. * Stores path cursor callbacks for when an onchange event is triggered
  71324. */
  71325. private _onchange;
  71326. /**
  71327. * The value of the path cursor
  71328. */
  71329. value: number;
  71330. /**
  71331. * The animation array of the path cursor
  71332. */
  71333. animations: Animation[];
  71334. /**
  71335. * Initializes the path cursor
  71336. * @param path The path to track
  71337. */
  71338. constructor(path: Path2);
  71339. /**
  71340. * Gets the cursor point on the path
  71341. * @returns A point on the path cursor at the cursor location
  71342. */
  71343. getPoint(): Vector3;
  71344. /**
  71345. * Moves the cursor ahead by the step amount
  71346. * @param step The amount to move the cursor forward
  71347. * @returns This path cursor
  71348. */
  71349. moveAhead(step?: number): PathCursor;
  71350. /**
  71351. * Moves the cursor behind by the step amount
  71352. * @param step The amount to move the cursor back
  71353. * @returns This path cursor
  71354. */
  71355. moveBack(step?: number): PathCursor;
  71356. /**
  71357. * Moves the cursor by the step amount
  71358. * If the step amount is greater than one, an exception is thrown
  71359. * @param step The amount to move the cursor
  71360. * @returns This path cursor
  71361. */
  71362. move(step: number): PathCursor;
  71363. /**
  71364. * Ensures that the value is limited between zero and one
  71365. * @returns This path cursor
  71366. */
  71367. private ensureLimits;
  71368. /**
  71369. * Runs onchange callbacks on change (used by the animation engine)
  71370. * @returns This path cursor
  71371. */
  71372. private raiseOnChange;
  71373. /**
  71374. * Executes a function on change
  71375. * @param f A path cursor onchange callback
  71376. * @returns This path cursor
  71377. */
  71378. onchange(f: (cursor: PathCursor) => void): PathCursor;
  71379. }
  71380. }
  71381. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  71382. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  71383. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  71384. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  71385. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  71386. }
  71387. declare module "babylonjs/Engines/Processors/Expressions/index" {
  71388. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  71389. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  71390. }
  71391. declare module "babylonjs/Engines/Processors/index" {
  71392. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  71393. export * from "babylonjs/Engines/Processors/Expressions/index";
  71394. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  71395. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  71396. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  71397. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  71398. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  71399. export * from "babylonjs/Engines/Processors/shaderProcessor";
  71400. }
  71401. declare module "babylonjs/Legacy/legacy" {
  71402. import * as Babylon from "babylonjs/index";
  71403. export * from "babylonjs/index";
  71404. }
  71405. declare module "babylonjs/Shaders/blur.fragment" {
  71406. /** @hidden */
  71407. export var blurPixelShader: {
  71408. name: string;
  71409. shader: string;
  71410. };
  71411. }
  71412. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  71413. /** @hidden */
  71414. export var pointCloudVertexDeclaration: {
  71415. name: string;
  71416. shader: string;
  71417. };
  71418. }
  71419. declare module "babylonjs" {
  71420. export * from "babylonjs/Legacy/legacy";
  71421. }
  71422. declare module BABYLON {
  71423. /** Alias type for value that can be null */
  71424. export type Nullable<T> = T | null;
  71425. /**
  71426. * Alias type for number that are floats
  71427. * @ignorenaming
  71428. */
  71429. export type float = number;
  71430. /**
  71431. * Alias type for number that are doubles.
  71432. * @ignorenaming
  71433. */
  71434. export type double = number;
  71435. /**
  71436. * Alias type for number that are integer
  71437. * @ignorenaming
  71438. */
  71439. export type int = number;
  71440. /** Alias type for number array or Float32Array */
  71441. export type FloatArray = number[] | Float32Array;
  71442. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  71443. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  71444. /**
  71445. * Alias for types that can be used by a Buffer or VertexBuffer.
  71446. */
  71447. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  71448. /**
  71449. * Alias type for primitive types
  71450. * @ignorenaming
  71451. */
  71452. type Primitive = undefined | null | boolean | string | number | Function;
  71453. /**
  71454. * Type modifier to make all the properties of an object Readonly
  71455. */
  71456. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  71457. /**
  71458. * Type modifier to make all the properties of an object Readonly recursively
  71459. */
  71460. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  71461. /**
  71462. * Type modifier to make object properties readonly.
  71463. */
  71464. export type DeepImmutableObject<T> = {
  71465. readonly [K in keyof T]: DeepImmutable<T[K]>;
  71466. };
  71467. /** @hidden */
  71468. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  71469. }
  71470. }
  71471. declare module BABYLON {
  71472. /**
  71473. * A class serves as a medium between the observable and its observers
  71474. */
  71475. export class EventState {
  71476. /**
  71477. * Create a new EventState
  71478. * @param mask defines the mask associated with this state
  71479. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  71480. * @param target defines the original target of the state
  71481. * @param currentTarget defines the current target of the state
  71482. */
  71483. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  71484. /**
  71485. * Initialize the current event state
  71486. * @param mask defines the mask associated with this state
  71487. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  71488. * @param target defines the original target of the state
  71489. * @param currentTarget defines the current target of the state
  71490. * @returns the current event state
  71491. */
  71492. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71493. /**
  71494. * An Observer can set this property to true to prevent subsequent observers of being notified
  71495. */
  71496. skipNextObservers: boolean;
  71497. /**
  71498. * Get the mask value that were used to trigger the event corresponding to this EventState object
  71499. */
  71500. mask: number;
  71501. /**
  71502. * The object that originally notified the event
  71503. */
  71504. target?: any;
  71505. /**
  71506. * The current object in the bubbling phase
  71507. */
  71508. currentTarget?: any;
  71509. /**
  71510. * This will be populated with the return value of the last function that was executed.
  71511. * If it is the first function in the callback chain it will be the event data.
  71512. */
  71513. lastReturnValue?: any;
  71514. }
  71515. /**
  71516. * Represent an Observer registered to a given Observable object.
  71517. */
  71518. export class Observer<T> {
  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. /** @hidden */
  71532. _willBeUnregistered: boolean;
  71533. /**
  71534. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  71535. */
  71536. unregisterOnNextCall: boolean;
  71537. /**
  71538. * Creates a new observer
  71539. * @param callback defines the callback to call when the observer is notified
  71540. * @param mask defines the mask of the observer (used to filter notifications)
  71541. * @param scope defines the current scope used to restore the JS context
  71542. */
  71543. constructor(
  71544. /**
  71545. * Defines the callback to call when the observer is notified
  71546. */
  71547. callback: (eventData: T, eventState: EventState) => void,
  71548. /**
  71549. * Defines the mask of the observer (used to filter notifications)
  71550. */
  71551. mask: number,
  71552. /**
  71553. * Defines the current scope used to restore the JS context
  71554. */
  71555. scope?: any);
  71556. }
  71557. /**
  71558. * Represent a list of observers registered to multiple Observables object.
  71559. */
  71560. export class MultiObserver<T> {
  71561. private _observers;
  71562. private _observables;
  71563. /**
  71564. * Release associated resources
  71565. */
  71566. dispose(): void;
  71567. /**
  71568. * Raise a callback when one of the observable will notify
  71569. * @param observables defines a list of observables to watch
  71570. * @param callback defines the callback to call on notification
  71571. * @param mask defines the mask used to filter notifications
  71572. * @param scope defines the current scope used to restore the JS context
  71573. * @returns the new MultiObserver
  71574. */
  71575. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  71576. }
  71577. /**
  71578. * The Observable class is a simple implementation of the Observable pattern.
  71579. *
  71580. * 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.
  71581. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  71582. * 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).
  71583. * 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.
  71584. */
  71585. export class Observable<T> {
  71586. private _observers;
  71587. private _eventState;
  71588. private _onObserverAdded;
  71589. /**
  71590. * Gets the list of observers
  71591. */
  71592. get observers(): Array<Observer<T>>;
  71593. /**
  71594. * Creates a new observable
  71595. * @param onObserverAdded defines a callback to call when a new observer is added
  71596. */
  71597. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  71598. /**
  71599. * Create a new Observer with the specified callback
  71600. * @param callback the callback that will be executed for that Observer
  71601. * @param mask the mask used to filter observers
  71602. * @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.
  71603. * @param scope optional scope for the callback to be called from
  71604. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  71605. * @returns the new observer created for the callback
  71606. */
  71607. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  71608. /**
  71609. * Create a new Observer with the specified callback and unregisters after the next notification
  71610. * @param callback the callback that will be executed for that Observer
  71611. * @returns the new observer created for the callback
  71612. */
  71613. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  71614. /**
  71615. * Remove an Observer from the Observable object
  71616. * @param observer the instance of the Observer to remove
  71617. * @returns false if it doesn't belong to this Observable
  71618. */
  71619. remove(observer: Nullable<Observer<T>>): boolean;
  71620. /**
  71621. * Remove a callback from the Observable object
  71622. * @param callback the callback to remove
  71623. * @param scope optional scope. If used only the callbacks with this scope will be removed
  71624. * @returns false if it doesn't belong to this Observable
  71625. */
  71626. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  71627. private _deferUnregister;
  71628. private _remove;
  71629. /**
  71630. * Moves the observable to the top of the observer list making it get called first when notified
  71631. * @param observer the observer to move
  71632. */
  71633. makeObserverTopPriority(observer: Observer<T>): void;
  71634. /**
  71635. * Moves the observable to the bottom of the observer list making it get called last when notified
  71636. * @param observer the observer to move
  71637. */
  71638. makeObserverBottomPriority(observer: Observer<T>): void;
  71639. /**
  71640. * Notify all Observers by calling their respective callback with the given data
  71641. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  71642. * @param eventData defines the data to send to all observers
  71643. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  71644. * @param target defines the original target of the state
  71645. * @param currentTarget defines the current target of the state
  71646. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  71647. */
  71648. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  71649. /**
  71650. * Calling this will execute each callback, expecting it to be a promise or return a value.
  71651. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  71652. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  71653. * and it is crucial that all callbacks will be executed.
  71654. * The order of the callbacks is kept, callbacks are not executed parallel.
  71655. *
  71656. * @param eventData The data to be sent to each callback
  71657. * @param mask is used to filter observers defaults to -1
  71658. * @param target defines the callback target (see EventState)
  71659. * @param currentTarget defines he current object in the bubbling phase
  71660. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  71661. */
  71662. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  71663. /**
  71664. * Notify a specific observer
  71665. * @param observer defines the observer to notify
  71666. * @param eventData defines the data to be sent to each callback
  71667. * @param mask is used to filter observers defaults to -1
  71668. */
  71669. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  71670. /**
  71671. * Gets a boolean indicating if the observable has at least one observer
  71672. * @returns true is the Observable has at least one Observer registered
  71673. */
  71674. hasObservers(): boolean;
  71675. /**
  71676. * Clear the list of observers
  71677. */
  71678. clear(): void;
  71679. /**
  71680. * Clone the current observable
  71681. * @returns a new observable
  71682. */
  71683. clone(): Observable<T>;
  71684. /**
  71685. * Does this observable handles observer registered with a given mask
  71686. * @param mask defines the mask to be tested
  71687. * @return whether or not one observer registered with the given mask is handeled
  71688. **/
  71689. hasSpecificMask(mask?: number): boolean;
  71690. }
  71691. }
  71692. declare module BABYLON {
  71693. /**
  71694. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  71695. * Babylon.js
  71696. */
  71697. export class DomManagement {
  71698. /**
  71699. * Checks if the window object exists
  71700. * @returns true if the window object exists
  71701. */
  71702. static IsWindowObjectExist(): boolean;
  71703. /**
  71704. * Checks if the navigator object exists
  71705. * @returns true if the navigator object exists
  71706. */
  71707. static IsNavigatorAvailable(): boolean;
  71708. /**
  71709. * Extracts text content from a DOM element hierarchy
  71710. * @param element defines the root element
  71711. * @returns a string
  71712. */
  71713. static GetDOMTextContent(element: HTMLElement): string;
  71714. }
  71715. }
  71716. declare module BABYLON {
  71717. /**
  71718. * Logger used througouht the application to allow configuration of
  71719. * the log level required for the messages.
  71720. */
  71721. export class Logger {
  71722. /**
  71723. * No log
  71724. */
  71725. static readonly NoneLogLevel: number;
  71726. /**
  71727. * Only message logs
  71728. */
  71729. static readonly MessageLogLevel: number;
  71730. /**
  71731. * Only warning logs
  71732. */
  71733. static readonly WarningLogLevel: number;
  71734. /**
  71735. * Only error logs
  71736. */
  71737. static readonly ErrorLogLevel: number;
  71738. /**
  71739. * All logs
  71740. */
  71741. static readonly AllLogLevel: number;
  71742. private static _LogCache;
  71743. /**
  71744. * Gets a value indicating the number of loading errors
  71745. * @ignorenaming
  71746. */
  71747. static errorsCount: number;
  71748. /**
  71749. * Callback called when a new log is added
  71750. */
  71751. static OnNewCacheEntry: (entry: string) => void;
  71752. private static _AddLogEntry;
  71753. private static _FormatMessage;
  71754. private static _LogDisabled;
  71755. private static _LogEnabled;
  71756. private static _WarnDisabled;
  71757. private static _WarnEnabled;
  71758. private static _ErrorDisabled;
  71759. private static _ErrorEnabled;
  71760. /**
  71761. * Log a message to the console
  71762. */
  71763. static Log: (message: string) => void;
  71764. /**
  71765. * Write a warning message to the console
  71766. */
  71767. static Warn: (message: string) => void;
  71768. /**
  71769. * Write an error message to the console
  71770. */
  71771. static Error: (message: string) => void;
  71772. /**
  71773. * Gets current log cache (list of logs)
  71774. */
  71775. static get LogCache(): string;
  71776. /**
  71777. * Clears the log cache
  71778. */
  71779. static ClearLogCache(): void;
  71780. /**
  71781. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  71782. */
  71783. static set LogLevels(level: number);
  71784. }
  71785. }
  71786. declare module BABYLON {
  71787. /** @hidden */
  71788. export class _TypeStore {
  71789. /** @hidden */
  71790. static RegisteredTypes: {
  71791. [key: string]: Object;
  71792. };
  71793. /** @hidden */
  71794. static GetClass(fqdn: string): any;
  71795. }
  71796. }
  71797. declare module BABYLON {
  71798. /**
  71799. * Helper to manipulate strings
  71800. */
  71801. export class StringTools {
  71802. /**
  71803. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71804. * @param str Source string
  71805. * @param suffix Suffix to search for in the source string
  71806. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71807. */
  71808. static EndsWith(str: string, suffix: string): boolean;
  71809. /**
  71810. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71811. * @param str Source string
  71812. * @param suffix Suffix to search for in the source string
  71813. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71814. */
  71815. static StartsWith(str: string, suffix: string): boolean;
  71816. /**
  71817. * Decodes a buffer into a string
  71818. * @param buffer The buffer to decode
  71819. * @returns The decoded string
  71820. */
  71821. static Decode(buffer: Uint8Array | Uint16Array): string;
  71822. /**
  71823. * Encode a buffer to a base64 string
  71824. * @param buffer defines the buffer to encode
  71825. * @returns the encoded string
  71826. */
  71827. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  71828. }
  71829. }
  71830. declare module BABYLON {
  71831. /**
  71832. * Class containing a set of static utilities functions for deep copy.
  71833. */
  71834. export class DeepCopier {
  71835. /**
  71836. * Tries to copy an object by duplicating every property
  71837. * @param source defines the source object
  71838. * @param destination defines the target object
  71839. * @param doNotCopyList defines a list of properties to avoid
  71840. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  71841. */
  71842. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  71843. }
  71844. }
  71845. declare module BABYLON {
  71846. /**
  71847. * Class containing a set of static utilities functions for precision date
  71848. */
  71849. export class PrecisionDate {
  71850. /**
  71851. * Gets either window.performance.now() if supported or Date.now() else
  71852. */
  71853. static get Now(): number;
  71854. }
  71855. }
  71856. declare module BABYLON {
  71857. /** @hidden */
  71858. export class _DevTools {
  71859. static WarnImport(name: string): string;
  71860. }
  71861. }
  71862. declare module BABYLON {
  71863. /**
  71864. * Interface used to define the mechanism to get data from the network
  71865. */
  71866. export interface IWebRequest {
  71867. /**
  71868. * Returns client's response url
  71869. */
  71870. responseURL: string;
  71871. /**
  71872. * Returns client's status
  71873. */
  71874. status: number;
  71875. /**
  71876. * Returns client's status as a text
  71877. */
  71878. statusText: string;
  71879. }
  71880. }
  71881. declare module BABYLON {
  71882. /**
  71883. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  71884. */
  71885. export class WebRequest implements IWebRequest {
  71886. private _xhr;
  71887. /**
  71888. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  71889. * i.e. when loading files, where the server/service expects an Authorization header
  71890. */
  71891. static CustomRequestHeaders: {
  71892. [key: string]: string;
  71893. };
  71894. /**
  71895. * Add callback functions in this array to update all the requests before they get sent to the network
  71896. */
  71897. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  71898. private _injectCustomRequestHeaders;
  71899. /**
  71900. * Gets or sets a function to be called when loading progress changes
  71901. */
  71902. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  71903. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  71904. /**
  71905. * Returns client's state
  71906. */
  71907. get readyState(): number;
  71908. /**
  71909. * Returns client's status
  71910. */
  71911. get status(): number;
  71912. /**
  71913. * Returns client's status as a text
  71914. */
  71915. get statusText(): string;
  71916. /**
  71917. * Returns client's response
  71918. */
  71919. get response(): any;
  71920. /**
  71921. * Returns client's response url
  71922. */
  71923. get responseURL(): string;
  71924. /**
  71925. * Returns client's response as text
  71926. */
  71927. get responseText(): string;
  71928. /**
  71929. * Gets or sets the expected response type
  71930. */
  71931. get responseType(): XMLHttpRequestResponseType;
  71932. set responseType(value: XMLHttpRequestResponseType);
  71933. /** @hidden */
  71934. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  71935. /** @hidden */
  71936. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  71937. /**
  71938. * Cancels any network activity
  71939. */
  71940. abort(): void;
  71941. /**
  71942. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  71943. * @param body defines an optional request body
  71944. */
  71945. send(body?: Document | BodyInit | null): void;
  71946. /**
  71947. * Sets the request method, request URL
  71948. * @param method defines the method to use (GET, POST, etc..)
  71949. * @param url defines the url to connect with
  71950. */
  71951. open(method: string, url: string): void;
  71952. /**
  71953. * Sets the value of a request header.
  71954. * @param name The name of the header whose value is to be set
  71955. * @param value The value to set as the body of the header
  71956. */
  71957. setRequestHeader(name: string, value: string): void;
  71958. /**
  71959. * Get the string containing the text of a particular header's value.
  71960. * @param name The name of the header
  71961. * @returns The string containing the text of the given header name
  71962. */
  71963. getResponseHeader(name: string): Nullable<string>;
  71964. }
  71965. }
  71966. declare module BABYLON {
  71967. /**
  71968. * File request interface
  71969. */
  71970. export interface IFileRequest {
  71971. /**
  71972. * Raised when the request is complete (success or error).
  71973. */
  71974. onCompleteObservable: Observable<IFileRequest>;
  71975. /**
  71976. * Aborts the request for a file.
  71977. */
  71978. abort: () => void;
  71979. }
  71980. }
  71981. declare module BABYLON {
  71982. /**
  71983. * Define options used to create a render target texture
  71984. */
  71985. export class RenderTargetCreationOptions {
  71986. /**
  71987. * Specifies is mipmaps must be generated
  71988. */
  71989. generateMipMaps?: boolean;
  71990. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71991. generateDepthBuffer?: boolean;
  71992. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71993. generateStencilBuffer?: boolean;
  71994. /** Defines texture type (int by default) */
  71995. type?: number;
  71996. /** Defines sampling mode (trilinear by default) */
  71997. samplingMode?: number;
  71998. /** Defines format (RGBA by default) */
  71999. format?: number;
  72000. }
  72001. }
  72002. declare module BABYLON {
  72003. /**
  72004. * @hidden
  72005. **/
  72006. export class _TimeToken {
  72007. _startTimeQuery: Nullable<WebGLQuery>;
  72008. _endTimeQuery: Nullable<WebGLQuery>;
  72009. _timeElapsedQuery: Nullable<WebGLQuery>;
  72010. _timeElapsedQueryEnded: boolean;
  72011. }
  72012. }
  72013. declare module BABYLON {
  72014. /** Defines the cross module used constants to avoid circular dependncies */
  72015. export class Constants {
  72016. /** Defines that alpha blending is disabled */
  72017. static readonly ALPHA_DISABLE: number;
  72018. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  72019. static readonly ALPHA_ADD: number;
  72020. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  72021. static readonly ALPHA_COMBINE: number;
  72022. /** Defines that alpha blending is DEST - SRC * DEST */
  72023. static readonly ALPHA_SUBTRACT: number;
  72024. /** Defines that alpha blending is SRC * DEST */
  72025. static readonly ALPHA_MULTIPLY: number;
  72026. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  72027. static readonly ALPHA_MAXIMIZED: number;
  72028. /** Defines that alpha blending is SRC + DEST */
  72029. static readonly ALPHA_ONEONE: number;
  72030. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  72031. static readonly ALPHA_PREMULTIPLIED: number;
  72032. /**
  72033. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  72034. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  72035. */
  72036. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  72037. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  72038. static readonly ALPHA_INTERPOLATE: number;
  72039. /**
  72040. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  72041. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  72042. */
  72043. static readonly ALPHA_SCREENMODE: number;
  72044. /**
  72045. * Defines that alpha blending is SRC + DST
  72046. * Alpha will be set to SRC ALPHA + DST ALPHA
  72047. */
  72048. static readonly ALPHA_ONEONE_ONEONE: number;
  72049. /**
  72050. * Defines that alpha blending is SRC * DST ALPHA + DST
  72051. * Alpha will be set to 0
  72052. */
  72053. static readonly ALPHA_ALPHATOCOLOR: number;
  72054. /**
  72055. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  72056. */
  72057. static readonly ALPHA_REVERSEONEMINUS: number;
  72058. /**
  72059. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  72060. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  72061. */
  72062. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  72063. /**
  72064. * Defines that alpha blending is SRC + DST
  72065. * Alpha will be set to SRC ALPHA
  72066. */
  72067. static readonly ALPHA_ONEONE_ONEZERO: number;
  72068. /**
  72069. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  72070. * Alpha will be set to DST ALPHA
  72071. */
  72072. static readonly ALPHA_EXCLUSION: number;
  72073. /** Defines that alpha blending equation a SUM */
  72074. static readonly ALPHA_EQUATION_ADD: number;
  72075. /** Defines that alpha blending equation a SUBSTRACTION */
  72076. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  72077. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  72078. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  72079. /** Defines that alpha blending equation a MAX operation */
  72080. static readonly ALPHA_EQUATION_MAX: number;
  72081. /** Defines that alpha blending equation a MIN operation */
  72082. static readonly ALPHA_EQUATION_MIN: number;
  72083. /**
  72084. * Defines that alpha blending equation a DARKEN operation:
  72085. * It takes the min of the src and sums the alpha channels.
  72086. */
  72087. static readonly ALPHA_EQUATION_DARKEN: number;
  72088. /** Defines that the ressource is not delayed*/
  72089. static readonly DELAYLOADSTATE_NONE: number;
  72090. /** Defines that the ressource was successfully delay loaded */
  72091. static readonly DELAYLOADSTATE_LOADED: number;
  72092. /** Defines that the ressource is currently delay loading */
  72093. static readonly DELAYLOADSTATE_LOADING: number;
  72094. /** Defines that the ressource is delayed and has not started loading */
  72095. static readonly DELAYLOADSTATE_NOTLOADED: number;
  72096. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  72097. static readonly NEVER: number;
  72098. /** 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 */
  72099. static readonly ALWAYS: number;
  72100. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  72101. static readonly LESS: number;
  72102. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  72103. static readonly EQUAL: number;
  72104. /** 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 */
  72105. static readonly LEQUAL: number;
  72106. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  72107. static readonly GREATER: number;
  72108. /** 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 */
  72109. static readonly GEQUAL: number;
  72110. /** 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 */
  72111. static readonly NOTEQUAL: number;
  72112. /** Passed to stencilOperation to specify that stencil value must be kept */
  72113. static readonly KEEP: number;
  72114. /** Passed to stencilOperation to specify that stencil value must be replaced */
  72115. static readonly REPLACE: number;
  72116. /** Passed to stencilOperation to specify that stencil value must be incremented */
  72117. static readonly INCR: number;
  72118. /** Passed to stencilOperation to specify that stencil value must be decremented */
  72119. static readonly DECR: number;
  72120. /** Passed to stencilOperation to specify that stencil value must be inverted */
  72121. static readonly INVERT: number;
  72122. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  72123. static readonly INCR_WRAP: number;
  72124. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  72125. static readonly DECR_WRAP: number;
  72126. /** Texture is not repeating outside of 0..1 UVs */
  72127. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  72128. /** Texture is repeating outside of 0..1 UVs */
  72129. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  72130. /** Texture is repeating and mirrored */
  72131. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  72132. /** ALPHA */
  72133. static readonly TEXTUREFORMAT_ALPHA: number;
  72134. /** LUMINANCE */
  72135. static readonly TEXTUREFORMAT_LUMINANCE: number;
  72136. /** LUMINANCE_ALPHA */
  72137. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  72138. /** RGB */
  72139. static readonly TEXTUREFORMAT_RGB: number;
  72140. /** RGBA */
  72141. static readonly TEXTUREFORMAT_RGBA: number;
  72142. /** RED */
  72143. static readonly TEXTUREFORMAT_RED: number;
  72144. /** RED (2nd reference) */
  72145. static readonly TEXTUREFORMAT_R: number;
  72146. /** RG */
  72147. static readonly TEXTUREFORMAT_RG: number;
  72148. /** RED_INTEGER */
  72149. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  72150. /** RED_INTEGER (2nd reference) */
  72151. static readonly TEXTUREFORMAT_R_INTEGER: number;
  72152. /** RG_INTEGER */
  72153. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  72154. /** RGB_INTEGER */
  72155. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  72156. /** RGBA_INTEGER */
  72157. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  72158. /** UNSIGNED_BYTE */
  72159. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  72160. /** UNSIGNED_BYTE (2nd reference) */
  72161. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  72162. /** FLOAT */
  72163. static readonly TEXTURETYPE_FLOAT: number;
  72164. /** HALF_FLOAT */
  72165. static readonly TEXTURETYPE_HALF_FLOAT: number;
  72166. /** BYTE */
  72167. static readonly TEXTURETYPE_BYTE: number;
  72168. /** SHORT */
  72169. static readonly TEXTURETYPE_SHORT: number;
  72170. /** UNSIGNED_SHORT */
  72171. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  72172. /** INT */
  72173. static readonly TEXTURETYPE_INT: number;
  72174. /** UNSIGNED_INT */
  72175. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  72176. /** UNSIGNED_SHORT_4_4_4_4 */
  72177. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  72178. /** UNSIGNED_SHORT_5_5_5_1 */
  72179. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  72180. /** UNSIGNED_SHORT_5_6_5 */
  72181. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  72182. /** UNSIGNED_INT_2_10_10_10_REV */
  72183. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  72184. /** UNSIGNED_INT_24_8 */
  72185. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  72186. /** UNSIGNED_INT_10F_11F_11F_REV */
  72187. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  72188. /** UNSIGNED_INT_5_9_9_9_REV */
  72189. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  72190. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  72191. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  72192. /** nearest is mag = nearest and min = nearest and no mip */
  72193. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  72194. /** mag = nearest and min = nearest and mip = none */
  72195. static readonly TEXTURE_NEAREST_NEAREST: number;
  72196. /** Bilinear is mag = linear and min = linear and no mip */
  72197. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  72198. /** mag = linear and min = linear and mip = none */
  72199. static readonly TEXTURE_LINEAR_LINEAR: number;
  72200. /** Trilinear is mag = linear and min = linear and mip = linear */
  72201. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  72202. /** Trilinear is mag = linear and min = linear and mip = linear */
  72203. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  72204. /** mag = nearest and min = nearest and mip = nearest */
  72205. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  72206. /** mag = nearest and min = linear and mip = nearest */
  72207. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  72208. /** mag = nearest and min = linear and mip = linear */
  72209. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  72210. /** mag = nearest and min = linear and mip = none */
  72211. static readonly TEXTURE_NEAREST_LINEAR: number;
  72212. /** nearest is mag = nearest and min = nearest and mip = linear */
  72213. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  72214. /** mag = linear and min = nearest and mip = nearest */
  72215. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  72216. /** mag = linear and min = nearest and mip = linear */
  72217. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  72218. /** Bilinear is mag = linear and min = linear and mip = nearest */
  72219. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  72220. /** mag = linear and min = nearest and mip = none */
  72221. static readonly TEXTURE_LINEAR_NEAREST: number;
  72222. /** Explicit coordinates mode */
  72223. static readonly TEXTURE_EXPLICIT_MODE: number;
  72224. /** Spherical coordinates mode */
  72225. static readonly TEXTURE_SPHERICAL_MODE: number;
  72226. /** Planar coordinates mode */
  72227. static readonly TEXTURE_PLANAR_MODE: number;
  72228. /** Cubic coordinates mode */
  72229. static readonly TEXTURE_CUBIC_MODE: number;
  72230. /** Projection coordinates mode */
  72231. static readonly TEXTURE_PROJECTION_MODE: number;
  72232. /** Skybox coordinates mode */
  72233. static readonly TEXTURE_SKYBOX_MODE: number;
  72234. /** Inverse Cubic coordinates mode */
  72235. static readonly TEXTURE_INVCUBIC_MODE: number;
  72236. /** Equirectangular coordinates mode */
  72237. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  72238. /** Equirectangular Fixed coordinates mode */
  72239. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  72240. /** Equirectangular Fixed Mirrored coordinates mode */
  72241. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  72242. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  72243. static readonly SCALEMODE_FLOOR: number;
  72244. /** Defines that texture rescaling will look for the nearest power of 2 size */
  72245. static readonly SCALEMODE_NEAREST: number;
  72246. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  72247. static readonly SCALEMODE_CEILING: number;
  72248. /**
  72249. * The dirty texture flag value
  72250. */
  72251. static readonly MATERIAL_TextureDirtyFlag: number;
  72252. /**
  72253. * The dirty light flag value
  72254. */
  72255. static readonly MATERIAL_LightDirtyFlag: number;
  72256. /**
  72257. * The dirty fresnel flag value
  72258. */
  72259. static readonly MATERIAL_FresnelDirtyFlag: number;
  72260. /**
  72261. * The dirty attribute flag value
  72262. */
  72263. static readonly MATERIAL_AttributesDirtyFlag: number;
  72264. /**
  72265. * The dirty misc flag value
  72266. */
  72267. static readonly MATERIAL_MiscDirtyFlag: number;
  72268. /**
  72269. * The all dirty flag value
  72270. */
  72271. static readonly MATERIAL_AllDirtyFlag: number;
  72272. /**
  72273. * Returns the triangle fill mode
  72274. */
  72275. static readonly MATERIAL_TriangleFillMode: number;
  72276. /**
  72277. * Returns the wireframe mode
  72278. */
  72279. static readonly MATERIAL_WireFrameFillMode: number;
  72280. /**
  72281. * Returns the point fill mode
  72282. */
  72283. static readonly MATERIAL_PointFillMode: number;
  72284. /**
  72285. * Returns the point list draw mode
  72286. */
  72287. static readonly MATERIAL_PointListDrawMode: number;
  72288. /**
  72289. * Returns the line list draw mode
  72290. */
  72291. static readonly MATERIAL_LineListDrawMode: number;
  72292. /**
  72293. * Returns the line loop draw mode
  72294. */
  72295. static readonly MATERIAL_LineLoopDrawMode: number;
  72296. /**
  72297. * Returns the line strip draw mode
  72298. */
  72299. static readonly MATERIAL_LineStripDrawMode: number;
  72300. /**
  72301. * Returns the triangle strip draw mode
  72302. */
  72303. static readonly MATERIAL_TriangleStripDrawMode: number;
  72304. /**
  72305. * Returns the triangle fan draw mode
  72306. */
  72307. static readonly MATERIAL_TriangleFanDrawMode: number;
  72308. /**
  72309. * Stores the clock-wise side orientation
  72310. */
  72311. static readonly MATERIAL_ClockWiseSideOrientation: number;
  72312. /**
  72313. * Stores the counter clock-wise side orientation
  72314. */
  72315. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  72316. /**
  72317. * Nothing
  72318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72319. */
  72320. static readonly ACTION_NothingTrigger: number;
  72321. /**
  72322. * On pick
  72323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72324. */
  72325. static readonly ACTION_OnPickTrigger: number;
  72326. /**
  72327. * On left pick
  72328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72329. */
  72330. static readonly ACTION_OnLeftPickTrigger: number;
  72331. /**
  72332. * On right pick
  72333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72334. */
  72335. static readonly ACTION_OnRightPickTrigger: number;
  72336. /**
  72337. * On center pick
  72338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72339. */
  72340. static readonly ACTION_OnCenterPickTrigger: number;
  72341. /**
  72342. * On pick down
  72343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72344. */
  72345. static readonly ACTION_OnPickDownTrigger: number;
  72346. /**
  72347. * On double pick
  72348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72349. */
  72350. static readonly ACTION_OnDoublePickTrigger: number;
  72351. /**
  72352. * On pick up
  72353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72354. */
  72355. static readonly ACTION_OnPickUpTrigger: number;
  72356. /**
  72357. * On pick out.
  72358. * This trigger will only be raised if you also declared a OnPickDown
  72359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72360. */
  72361. static readonly ACTION_OnPickOutTrigger: number;
  72362. /**
  72363. * On long press
  72364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72365. */
  72366. static readonly ACTION_OnLongPressTrigger: number;
  72367. /**
  72368. * On pointer over
  72369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72370. */
  72371. static readonly ACTION_OnPointerOverTrigger: number;
  72372. /**
  72373. * On pointer out
  72374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72375. */
  72376. static readonly ACTION_OnPointerOutTrigger: number;
  72377. /**
  72378. * On every frame
  72379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72380. */
  72381. static readonly ACTION_OnEveryFrameTrigger: number;
  72382. /**
  72383. * On intersection enter
  72384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72385. */
  72386. static readonly ACTION_OnIntersectionEnterTrigger: number;
  72387. /**
  72388. * On intersection exit
  72389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72390. */
  72391. static readonly ACTION_OnIntersectionExitTrigger: number;
  72392. /**
  72393. * On key down
  72394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72395. */
  72396. static readonly ACTION_OnKeyDownTrigger: number;
  72397. /**
  72398. * On key up
  72399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72400. */
  72401. static readonly ACTION_OnKeyUpTrigger: number;
  72402. /**
  72403. * Billboard mode will only apply to Y axis
  72404. */
  72405. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  72406. /**
  72407. * Billboard mode will apply to all axes
  72408. */
  72409. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  72410. /**
  72411. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72412. */
  72413. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  72414. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  72415. * Test order :
  72416. * Is the bounding sphere outside the frustum ?
  72417. * If not, are the bounding box vertices outside the frustum ?
  72418. * It not, then the cullable object is in the frustum.
  72419. */
  72420. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  72421. /** Culling strategy : Bounding Sphere Only.
  72422. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  72423. * It's also less accurate than the standard because some not visible objects can still be selected.
  72424. * Test : is the bounding sphere outside the frustum ?
  72425. * If not, then the cullable object is in the frustum.
  72426. */
  72427. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  72428. /** Culling strategy : Optimistic Inclusion.
  72429. * This in an inclusion test first, then the standard exclusion test.
  72430. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  72431. * 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.
  72432. * Anyway, it's as accurate as the standard strategy.
  72433. * Test :
  72434. * Is the cullable object bounding sphere center in the frustum ?
  72435. * If not, apply the default culling strategy.
  72436. */
  72437. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  72438. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  72439. * This in an inclusion test first, then the bounding sphere only exclusion test.
  72440. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  72441. * 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.
  72442. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  72443. * Test :
  72444. * Is the cullable object bounding sphere center in the frustum ?
  72445. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  72446. */
  72447. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  72448. /**
  72449. * No logging while loading
  72450. */
  72451. static readonly SCENELOADER_NO_LOGGING: number;
  72452. /**
  72453. * Minimal logging while loading
  72454. */
  72455. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  72456. /**
  72457. * Summary logging while loading
  72458. */
  72459. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  72460. /**
  72461. * Detailled logging while loading
  72462. */
  72463. static readonly SCENELOADER_DETAILED_LOGGING: number;
  72464. }
  72465. }
  72466. declare module BABYLON {
  72467. /**
  72468. * This represents the required contract to create a new type of texture loader.
  72469. */
  72470. export interface IInternalTextureLoader {
  72471. /**
  72472. * Defines wether the loader supports cascade loading the different faces.
  72473. */
  72474. supportCascades: boolean;
  72475. /**
  72476. * This returns if the loader support the current file information.
  72477. * @param extension defines the file extension of the file being loaded
  72478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72479. * @param fallback defines the fallback internal texture if any
  72480. * @param isBase64 defines whether the texture is encoded as a base64
  72481. * @param isBuffer defines whether the texture data are stored as a buffer
  72482. * @returns true if the loader can load the specified file
  72483. */
  72484. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  72485. /**
  72486. * Transform the url before loading if required.
  72487. * @param rootUrl the url of the texture
  72488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72489. * @returns the transformed texture
  72490. */
  72491. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  72492. /**
  72493. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  72494. * @param rootUrl the url of the texture
  72495. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72496. * @returns the fallback texture
  72497. */
  72498. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  72499. /**
  72500. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  72501. * @param data contains the texture data
  72502. * @param texture defines the BabylonJS internal texture
  72503. * @param createPolynomials will be true if polynomials have been requested
  72504. * @param onLoad defines the callback to trigger once the texture is ready
  72505. * @param onError defines the callback to trigger in case of error
  72506. */
  72507. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  72508. /**
  72509. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  72510. * @param data contains the texture data
  72511. * @param texture defines the BabylonJS internal texture
  72512. * @param callback defines the method to call once ready to upload
  72513. */
  72514. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  72515. }
  72516. }
  72517. declare module BABYLON {
  72518. /**
  72519. * Class used to store and describe the pipeline context associated with an effect
  72520. */
  72521. export interface IPipelineContext {
  72522. /**
  72523. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  72524. */
  72525. isAsync: boolean;
  72526. /**
  72527. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  72528. */
  72529. isReady: boolean;
  72530. /** @hidden */
  72531. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  72532. }
  72533. }
  72534. declare module BABYLON {
  72535. /**
  72536. * Class used to store gfx data (like WebGLBuffer)
  72537. */
  72538. export class DataBuffer {
  72539. /**
  72540. * Gets or sets the number of objects referencing this buffer
  72541. */
  72542. references: number;
  72543. /** Gets or sets the size of the underlying buffer */
  72544. capacity: number;
  72545. /**
  72546. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  72547. */
  72548. is32Bits: boolean;
  72549. /**
  72550. * Gets the underlying buffer
  72551. */
  72552. get underlyingResource(): any;
  72553. }
  72554. }
  72555. declare module BABYLON {
  72556. /** @hidden */
  72557. export interface IShaderProcessor {
  72558. attributeProcessor?: (attribute: string) => string;
  72559. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  72560. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  72561. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  72562. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  72563. lineProcessor?: (line: string, isFragment: boolean) => string;
  72564. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  72565. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  72566. }
  72567. }
  72568. declare module BABYLON {
  72569. /** @hidden */
  72570. export interface ProcessingOptions {
  72571. defines: string[];
  72572. indexParameters: any;
  72573. isFragment: boolean;
  72574. shouldUseHighPrecisionShader: boolean;
  72575. supportsUniformBuffers: boolean;
  72576. shadersRepository: string;
  72577. includesShadersStore: {
  72578. [key: string]: string;
  72579. };
  72580. processor?: IShaderProcessor;
  72581. version: string;
  72582. platformName: string;
  72583. lookForClosingBracketForUniformBuffer?: boolean;
  72584. }
  72585. }
  72586. declare module BABYLON {
  72587. /** @hidden */
  72588. export class ShaderCodeNode {
  72589. line: string;
  72590. children: ShaderCodeNode[];
  72591. additionalDefineKey?: string;
  72592. additionalDefineValue?: string;
  72593. isValid(preprocessors: {
  72594. [key: string]: string;
  72595. }): boolean;
  72596. process(preprocessors: {
  72597. [key: string]: string;
  72598. }, options: ProcessingOptions): string;
  72599. }
  72600. }
  72601. declare module BABYLON {
  72602. /** @hidden */
  72603. export class ShaderCodeCursor {
  72604. private _lines;
  72605. lineIndex: number;
  72606. get currentLine(): string;
  72607. get canRead(): boolean;
  72608. set lines(value: string[]);
  72609. }
  72610. }
  72611. declare module BABYLON {
  72612. /** @hidden */
  72613. export class ShaderCodeConditionNode extends ShaderCodeNode {
  72614. process(preprocessors: {
  72615. [key: string]: string;
  72616. }, options: ProcessingOptions): string;
  72617. }
  72618. }
  72619. declare module BABYLON {
  72620. /** @hidden */
  72621. export class ShaderDefineExpression {
  72622. isTrue(preprocessors: {
  72623. [key: string]: string;
  72624. }): boolean;
  72625. }
  72626. }
  72627. declare module BABYLON {
  72628. /** @hidden */
  72629. export class ShaderCodeTestNode extends ShaderCodeNode {
  72630. testExpression: ShaderDefineExpression;
  72631. isValid(preprocessors: {
  72632. [key: string]: string;
  72633. }): boolean;
  72634. }
  72635. }
  72636. declare module BABYLON {
  72637. /** @hidden */
  72638. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  72639. define: string;
  72640. not: boolean;
  72641. constructor(define: string, not?: boolean);
  72642. isTrue(preprocessors: {
  72643. [key: string]: string;
  72644. }): boolean;
  72645. }
  72646. }
  72647. declare module BABYLON {
  72648. /** @hidden */
  72649. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  72650. leftOperand: ShaderDefineExpression;
  72651. rightOperand: ShaderDefineExpression;
  72652. isTrue(preprocessors: {
  72653. [key: string]: string;
  72654. }): boolean;
  72655. }
  72656. }
  72657. declare module BABYLON {
  72658. /** @hidden */
  72659. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  72660. leftOperand: ShaderDefineExpression;
  72661. rightOperand: ShaderDefineExpression;
  72662. isTrue(preprocessors: {
  72663. [key: string]: string;
  72664. }): boolean;
  72665. }
  72666. }
  72667. declare module BABYLON {
  72668. /** @hidden */
  72669. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  72670. define: string;
  72671. operand: string;
  72672. testValue: string;
  72673. constructor(define: string, operand: string, testValue: string);
  72674. isTrue(preprocessors: {
  72675. [key: string]: string;
  72676. }): boolean;
  72677. }
  72678. }
  72679. declare module BABYLON {
  72680. /**
  72681. * Class used to enable access to offline support
  72682. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72683. */
  72684. export interface IOfflineProvider {
  72685. /**
  72686. * Gets a boolean indicating if scene must be saved in the database
  72687. */
  72688. enableSceneOffline: boolean;
  72689. /**
  72690. * Gets a boolean indicating if textures must be saved in the database
  72691. */
  72692. enableTexturesOffline: boolean;
  72693. /**
  72694. * Open the offline support and make it available
  72695. * @param successCallback defines the callback to call on success
  72696. * @param errorCallback defines the callback to call on error
  72697. */
  72698. open(successCallback: () => void, errorCallback: () => void): void;
  72699. /**
  72700. * Loads an image from the offline support
  72701. * @param url defines the url to load from
  72702. * @param image defines the target DOM image
  72703. */
  72704. loadImage(url: string, image: HTMLImageElement): void;
  72705. /**
  72706. * Loads a file from offline support
  72707. * @param url defines the URL to load from
  72708. * @param sceneLoaded defines a callback to call on success
  72709. * @param progressCallBack defines a callback to call when progress changed
  72710. * @param errorCallback defines a callback to call on error
  72711. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72712. */
  72713. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72714. }
  72715. }
  72716. declare module BABYLON {
  72717. /**
  72718. * Class used to help managing file picking and drag'n'drop
  72719. * File Storage
  72720. */
  72721. export class FilesInputStore {
  72722. /**
  72723. * List of files ready to be loaded
  72724. */
  72725. static FilesToLoad: {
  72726. [key: string]: File;
  72727. };
  72728. }
  72729. }
  72730. declare module BABYLON {
  72731. /**
  72732. * Class used to define a retry strategy when error happens while loading assets
  72733. */
  72734. export class RetryStrategy {
  72735. /**
  72736. * Function used to defines an exponential back off strategy
  72737. * @param maxRetries defines the maximum number of retries (3 by default)
  72738. * @param baseInterval defines the interval between retries
  72739. * @returns the strategy function to use
  72740. */
  72741. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  72742. }
  72743. }
  72744. declare module BABYLON {
  72745. /**
  72746. * @ignore
  72747. * Application error to support additional information when loading a file
  72748. */
  72749. export abstract class BaseError extends Error {
  72750. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  72751. }
  72752. }
  72753. declare module BABYLON {
  72754. /** @ignore */
  72755. export class LoadFileError extends BaseError {
  72756. request?: WebRequest;
  72757. file?: File;
  72758. /**
  72759. * Creates a new LoadFileError
  72760. * @param message defines the message of the error
  72761. * @param request defines the optional web request
  72762. * @param file defines the optional file
  72763. */
  72764. constructor(message: string, object?: WebRequest | File);
  72765. }
  72766. /** @ignore */
  72767. export class RequestFileError extends BaseError {
  72768. request: WebRequest;
  72769. /**
  72770. * Creates a new LoadFileError
  72771. * @param message defines the message of the error
  72772. * @param request defines the optional web request
  72773. */
  72774. constructor(message: string, request: WebRequest);
  72775. }
  72776. /** @ignore */
  72777. export class ReadFileError extends BaseError {
  72778. file: File;
  72779. /**
  72780. * Creates a new ReadFileError
  72781. * @param message defines the message of the error
  72782. * @param file defines the optional file
  72783. */
  72784. constructor(message: string, file: File);
  72785. }
  72786. /**
  72787. * @hidden
  72788. */
  72789. export class FileTools {
  72790. /**
  72791. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  72792. */
  72793. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  72794. /**
  72795. * Gets or sets the base URL to use to load assets
  72796. */
  72797. static BaseUrl: string;
  72798. /**
  72799. * Default behaviour for cors in the application.
  72800. * It can be a string if the expected behavior is identical in the entire app.
  72801. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  72802. */
  72803. static CorsBehavior: string | ((url: string | string[]) => string);
  72804. /**
  72805. * Gets or sets a function used to pre-process url before using them to load assets
  72806. */
  72807. static PreprocessUrl: (url: string) => string;
  72808. /**
  72809. * Removes unwanted characters from an url
  72810. * @param url defines the url to clean
  72811. * @returns the cleaned url
  72812. */
  72813. private static _CleanUrl;
  72814. /**
  72815. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  72816. * @param url define the url we are trying
  72817. * @param element define the dom element where to configure the cors policy
  72818. */
  72819. static SetCorsBehavior(url: string | string[], element: {
  72820. crossOrigin: string | null;
  72821. }): void;
  72822. /**
  72823. * Loads an image as an HTMLImageElement.
  72824. * @param input url string, ArrayBuffer, or Blob to load
  72825. * @param onLoad callback called when the image successfully loads
  72826. * @param onError callback called when the image fails to load
  72827. * @param offlineProvider offline provider for caching
  72828. * @param mimeType optional mime type
  72829. * @returns the HTMLImageElement of the loaded image
  72830. */
  72831. 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>;
  72832. /**
  72833. * Reads a file from a File object
  72834. * @param file defines the file to load
  72835. * @param onSuccess defines the callback to call when data is loaded
  72836. * @param onProgress defines the callback to call during loading process
  72837. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  72838. * @param onError defines the callback to call when an error occurs
  72839. * @returns a file request object
  72840. */
  72841. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  72842. /**
  72843. * Loads a file from a url
  72844. * @param url url to load
  72845. * @param onSuccess callback called when the file successfully loads
  72846. * @param onProgress callback called while file is loading (if the server supports this mode)
  72847. * @param offlineProvider defines the offline provider for caching
  72848. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72849. * @param onError callback called when the file fails to load
  72850. * @returns a file request object
  72851. */
  72852. 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;
  72853. /**
  72854. * Loads a file
  72855. * @param url url to load
  72856. * @param onSuccess callback called when the file successfully loads
  72857. * @param onProgress callback called while file is loading (if the server supports this mode)
  72858. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72859. * @param onError callback called when the file fails to load
  72860. * @param onOpened callback called when the web request is opened
  72861. * @returns a file request object
  72862. */
  72863. 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;
  72864. /**
  72865. * Checks if the loaded document was accessed via `file:`-Protocol.
  72866. * @returns boolean
  72867. */
  72868. static IsFileURL(): boolean;
  72869. }
  72870. }
  72871. declare module BABYLON {
  72872. /** @hidden */
  72873. export class ShaderProcessor {
  72874. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  72875. private static _ProcessPrecision;
  72876. private static _ExtractOperation;
  72877. private static _BuildSubExpression;
  72878. private static _BuildExpression;
  72879. private static _MoveCursorWithinIf;
  72880. private static _MoveCursor;
  72881. private static _EvaluatePreProcessors;
  72882. private static _PreparePreProcessors;
  72883. private static _ProcessShaderConversion;
  72884. private static _ProcessIncludes;
  72885. /**
  72886. * Loads a file from a url
  72887. * @param url url to load
  72888. * @param onSuccess callback called when the file successfully loads
  72889. * @param onProgress callback called while file is loading (if the server supports this mode)
  72890. * @param offlineProvider defines the offline provider for caching
  72891. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72892. * @param onError callback called when the file fails to load
  72893. * @returns a file request object
  72894. * @hidden
  72895. */
  72896. 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;
  72897. }
  72898. }
  72899. declare module BABYLON {
  72900. /**
  72901. * @hidden
  72902. */
  72903. export interface IColor4Like {
  72904. r: float;
  72905. g: float;
  72906. b: float;
  72907. a: float;
  72908. }
  72909. /**
  72910. * @hidden
  72911. */
  72912. export interface IColor3Like {
  72913. r: float;
  72914. g: float;
  72915. b: float;
  72916. }
  72917. /**
  72918. * @hidden
  72919. */
  72920. export interface IVector4Like {
  72921. x: float;
  72922. y: float;
  72923. z: float;
  72924. w: float;
  72925. }
  72926. /**
  72927. * @hidden
  72928. */
  72929. export interface IVector3Like {
  72930. x: float;
  72931. y: float;
  72932. z: float;
  72933. }
  72934. /**
  72935. * @hidden
  72936. */
  72937. export interface IVector2Like {
  72938. x: float;
  72939. y: float;
  72940. }
  72941. /**
  72942. * @hidden
  72943. */
  72944. export interface IMatrixLike {
  72945. toArray(): DeepImmutable<Float32Array>;
  72946. updateFlag: int;
  72947. }
  72948. /**
  72949. * @hidden
  72950. */
  72951. export interface IViewportLike {
  72952. x: float;
  72953. y: float;
  72954. width: float;
  72955. height: float;
  72956. }
  72957. /**
  72958. * @hidden
  72959. */
  72960. export interface IPlaneLike {
  72961. normal: IVector3Like;
  72962. d: float;
  72963. normalize(): void;
  72964. }
  72965. }
  72966. declare module BABYLON {
  72967. /**
  72968. * Interface used to define common properties for effect fallbacks
  72969. */
  72970. export interface IEffectFallbacks {
  72971. /**
  72972. * Removes the defines that should be removed when falling back.
  72973. * @param currentDefines defines the current define statements for the shader.
  72974. * @param effect defines the current effect we try to compile
  72975. * @returns The resulting defines with defines of the current rank removed.
  72976. */
  72977. reduce(currentDefines: string, effect: Effect): string;
  72978. /**
  72979. * Removes the fallback from the bound mesh.
  72980. */
  72981. unBindMesh(): void;
  72982. /**
  72983. * Checks to see if more fallbacks are still availible.
  72984. */
  72985. hasMoreFallbacks: boolean;
  72986. }
  72987. }
  72988. declare module BABYLON {
  72989. /**
  72990. * Class used to evalaute queries containing `and` and `or` operators
  72991. */
  72992. export class AndOrNotEvaluator {
  72993. /**
  72994. * Evaluate a query
  72995. * @param query defines the query to evaluate
  72996. * @param evaluateCallback defines the callback used to filter result
  72997. * @returns true if the query matches
  72998. */
  72999. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  73000. private static _HandleParenthesisContent;
  73001. private static _SimplifyNegation;
  73002. }
  73003. }
  73004. declare module BABYLON {
  73005. /**
  73006. * Class used to store custom tags
  73007. */
  73008. export class Tags {
  73009. /**
  73010. * Adds support for tags on the given object
  73011. * @param obj defines the object to use
  73012. */
  73013. static EnableFor(obj: any): void;
  73014. /**
  73015. * Removes tags support
  73016. * @param obj defines the object to use
  73017. */
  73018. static DisableFor(obj: any): void;
  73019. /**
  73020. * Gets a boolean indicating if the given object has tags
  73021. * @param obj defines the object to use
  73022. * @returns a boolean
  73023. */
  73024. static HasTags(obj: any): boolean;
  73025. /**
  73026. * Gets the tags available on a given object
  73027. * @param obj defines the object to use
  73028. * @param asString defines if the tags must be returned as a string instead of an array of strings
  73029. * @returns the tags
  73030. */
  73031. static GetTags(obj: any, asString?: boolean): any;
  73032. /**
  73033. * Adds tags to an object
  73034. * @param obj defines the object to use
  73035. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  73036. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  73037. */
  73038. static AddTagsTo(obj: any, tagsString: string): void;
  73039. /**
  73040. * @hidden
  73041. */
  73042. static _AddTagTo(obj: any, tag: string): void;
  73043. /**
  73044. * Removes specific tags from a specific object
  73045. * @param obj defines the object to use
  73046. * @param tagsString defines the tags to remove
  73047. */
  73048. static RemoveTagsFrom(obj: any, tagsString: string): void;
  73049. /**
  73050. * @hidden
  73051. */
  73052. static _RemoveTagFrom(obj: any, tag: string): void;
  73053. /**
  73054. * Defines if tags hosted on an object match a given query
  73055. * @param obj defines the object to use
  73056. * @param tagsQuery defines the tag query
  73057. * @returns a boolean
  73058. */
  73059. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  73060. }
  73061. }
  73062. declare module BABYLON {
  73063. /**
  73064. * Scalar computation library
  73065. */
  73066. export class Scalar {
  73067. /**
  73068. * Two pi constants convenient for computation.
  73069. */
  73070. static TwoPi: number;
  73071. /**
  73072. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  73073. * @param a number
  73074. * @param b number
  73075. * @param epsilon (default = 1.401298E-45)
  73076. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  73077. */
  73078. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  73079. /**
  73080. * Returns a string : the upper case translation of the number i to hexadecimal.
  73081. * @param i number
  73082. * @returns the upper case translation of the number i to hexadecimal.
  73083. */
  73084. static ToHex(i: number): string;
  73085. /**
  73086. * Returns -1 if value is negative and +1 is value is positive.
  73087. * @param value the value
  73088. * @returns the value itself if it's equal to zero.
  73089. */
  73090. static Sign(value: number): number;
  73091. /**
  73092. * Returns the value itself if it's between min and max.
  73093. * Returns min if the value is lower than min.
  73094. * Returns max if the value is greater than max.
  73095. * @param value the value to clmap
  73096. * @param min the min value to clamp to (default: 0)
  73097. * @param max the max value to clamp to (default: 1)
  73098. * @returns the clamped value
  73099. */
  73100. static Clamp(value: number, min?: number, max?: number): number;
  73101. /**
  73102. * the log2 of value.
  73103. * @param value the value to compute log2 of
  73104. * @returns the log2 of value.
  73105. */
  73106. static Log2(value: number): number;
  73107. /**
  73108. * Loops the value, so that it is never larger than length and never smaller than 0.
  73109. *
  73110. * This is similar to the modulo operator but it works with floating point numbers.
  73111. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  73112. * With t = 5 and length = 2.5, the result would be 0.0.
  73113. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  73114. * @param value the value
  73115. * @param length the length
  73116. * @returns the looped value
  73117. */
  73118. static Repeat(value: number, length: number): number;
  73119. /**
  73120. * Normalize the value between 0.0 and 1.0 using min and max values
  73121. * @param value value to normalize
  73122. * @param min max to normalize between
  73123. * @param max min to normalize between
  73124. * @returns the normalized value
  73125. */
  73126. static Normalize(value: number, min: number, max: number): number;
  73127. /**
  73128. * Denormalize the value from 0.0 and 1.0 using min and max values
  73129. * @param normalized value to denormalize
  73130. * @param min max to denormalize between
  73131. * @param max min to denormalize between
  73132. * @returns the denormalized value
  73133. */
  73134. static Denormalize(normalized: number, min: number, max: number): number;
  73135. /**
  73136. * Calculates the shortest difference between two given angles given in degrees.
  73137. * @param current current angle in degrees
  73138. * @param target target angle in degrees
  73139. * @returns the delta
  73140. */
  73141. static DeltaAngle(current: number, target: number): number;
  73142. /**
  73143. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  73144. * @param tx value
  73145. * @param length length
  73146. * @returns The returned value will move back and forth between 0 and length
  73147. */
  73148. static PingPong(tx: number, length: number): number;
  73149. /**
  73150. * Interpolates between min and max with smoothing at the limits.
  73151. *
  73152. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  73153. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  73154. * @param from from
  73155. * @param to to
  73156. * @param tx value
  73157. * @returns the smooth stepped value
  73158. */
  73159. static SmoothStep(from: number, to: number, tx: number): number;
  73160. /**
  73161. * Moves a value current towards target.
  73162. *
  73163. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  73164. * Negative values of maxDelta pushes the value away from target.
  73165. * @param current current value
  73166. * @param target target value
  73167. * @param maxDelta max distance to move
  73168. * @returns resulting value
  73169. */
  73170. static MoveTowards(current: number, target: number, maxDelta: number): number;
  73171. /**
  73172. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  73173. *
  73174. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  73175. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  73176. * @param current current value
  73177. * @param target target value
  73178. * @param maxDelta max distance to move
  73179. * @returns resulting angle
  73180. */
  73181. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  73182. /**
  73183. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  73184. * @param start start value
  73185. * @param end target value
  73186. * @param amount amount to lerp between
  73187. * @returns the lerped value
  73188. */
  73189. static Lerp(start: number, end: number, amount: number): number;
  73190. /**
  73191. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  73192. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  73193. * @param start start value
  73194. * @param end target value
  73195. * @param amount amount to lerp between
  73196. * @returns the lerped value
  73197. */
  73198. static LerpAngle(start: number, end: number, amount: number): number;
  73199. /**
  73200. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  73201. * @param a start value
  73202. * @param b target value
  73203. * @param value value between a and b
  73204. * @returns the inverseLerp value
  73205. */
  73206. static InverseLerp(a: number, b: number, value: number): number;
  73207. /**
  73208. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  73209. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  73210. * @param value1 spline value
  73211. * @param tangent1 spline value
  73212. * @param value2 spline value
  73213. * @param tangent2 spline value
  73214. * @param amount input value
  73215. * @returns hermite result
  73216. */
  73217. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  73218. /**
  73219. * Returns a random float number between and min and max values
  73220. * @param min min value of random
  73221. * @param max max value of random
  73222. * @returns random value
  73223. */
  73224. static RandomRange(min: number, max: number): number;
  73225. /**
  73226. * This function returns percentage of a number in a given range.
  73227. *
  73228. * RangeToPercent(40,20,60) will return 0.5 (50%)
  73229. * RangeToPercent(34,0,100) will return 0.34 (34%)
  73230. * @param number to convert to percentage
  73231. * @param min min range
  73232. * @param max max range
  73233. * @returns the percentage
  73234. */
  73235. static RangeToPercent(number: number, min: number, max: number): number;
  73236. /**
  73237. * This function returns number that corresponds to the percentage in a given range.
  73238. *
  73239. * PercentToRange(0.34,0,100) will return 34.
  73240. * @param percent to convert to number
  73241. * @param min min range
  73242. * @param max max range
  73243. * @returns the number
  73244. */
  73245. static PercentToRange(percent: number, min: number, max: number): number;
  73246. /**
  73247. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  73248. * @param angle The angle to normalize in radian.
  73249. * @return The converted angle.
  73250. */
  73251. static NormalizeRadians(angle: number): number;
  73252. }
  73253. }
  73254. declare module BABYLON {
  73255. /**
  73256. * Constant used to convert a value to gamma space
  73257. * @ignorenaming
  73258. */
  73259. export const ToGammaSpace: number;
  73260. /**
  73261. * Constant used to convert a value to linear space
  73262. * @ignorenaming
  73263. */
  73264. export const ToLinearSpace = 2.2;
  73265. /**
  73266. * Constant used to define the minimal number value in Babylon.js
  73267. * @ignorenaming
  73268. */
  73269. let Epsilon: number;
  73270. }
  73271. declare module BABYLON {
  73272. /**
  73273. * Class used to represent a viewport on screen
  73274. */
  73275. export class Viewport {
  73276. /** viewport left coordinate */
  73277. x: number;
  73278. /** viewport top coordinate */
  73279. y: number;
  73280. /**viewport width */
  73281. width: number;
  73282. /** viewport height */
  73283. height: number;
  73284. /**
  73285. * Creates a Viewport object located at (x, y) and sized (width, height)
  73286. * @param x defines viewport left coordinate
  73287. * @param y defines viewport top coordinate
  73288. * @param width defines the viewport width
  73289. * @param height defines the viewport height
  73290. */
  73291. constructor(
  73292. /** viewport left coordinate */
  73293. x: number,
  73294. /** viewport top coordinate */
  73295. y: number,
  73296. /**viewport width */
  73297. width: number,
  73298. /** viewport height */
  73299. height: number);
  73300. /**
  73301. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  73302. * @param renderWidth defines the rendering width
  73303. * @param renderHeight defines the rendering height
  73304. * @returns a new Viewport
  73305. */
  73306. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  73307. /**
  73308. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  73309. * @param renderWidth defines the rendering width
  73310. * @param renderHeight defines the rendering height
  73311. * @param ref defines the target viewport
  73312. * @returns the current viewport
  73313. */
  73314. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  73315. /**
  73316. * Returns a new Viewport copied from the current one
  73317. * @returns a new Viewport
  73318. */
  73319. clone(): Viewport;
  73320. }
  73321. }
  73322. declare module BABYLON {
  73323. /**
  73324. * Class containing a set of static utilities functions for arrays.
  73325. */
  73326. export class ArrayTools {
  73327. /**
  73328. * Returns an array of the given size filled with element built from the given constructor and the paramters
  73329. * @param size the number of element to construct and put in the array
  73330. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  73331. * @returns a new array filled with new objects
  73332. */
  73333. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  73334. }
  73335. }
  73336. declare module BABYLON {
  73337. /**
  73338. * Class representing a vector containing 2 coordinates
  73339. */
  73340. export class Vector2 {
  73341. /** defines the first coordinate */
  73342. x: number;
  73343. /** defines the second coordinate */
  73344. y: number;
  73345. /**
  73346. * Creates a new Vector2 from the given x and y coordinates
  73347. * @param x defines the first coordinate
  73348. * @param y defines the second coordinate
  73349. */
  73350. constructor(
  73351. /** defines the first coordinate */
  73352. x?: number,
  73353. /** defines the second coordinate */
  73354. y?: number);
  73355. /**
  73356. * Gets a string with the Vector2 coordinates
  73357. * @returns a string with the Vector2 coordinates
  73358. */
  73359. toString(): string;
  73360. /**
  73361. * Gets class name
  73362. * @returns the string "Vector2"
  73363. */
  73364. getClassName(): string;
  73365. /**
  73366. * Gets current vector hash code
  73367. * @returns the Vector2 hash code as a number
  73368. */
  73369. getHashCode(): number;
  73370. /**
  73371. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  73372. * @param array defines the source array
  73373. * @param index defines the offset in source array
  73374. * @returns the current Vector2
  73375. */
  73376. toArray(array: FloatArray, index?: number): Vector2;
  73377. /**
  73378. * Copy the current vector to an array
  73379. * @returns a new array with 2 elements: the Vector2 coordinates.
  73380. */
  73381. asArray(): number[];
  73382. /**
  73383. * Sets the Vector2 coordinates with the given Vector2 coordinates
  73384. * @param source defines the source Vector2
  73385. * @returns the current updated Vector2
  73386. */
  73387. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  73388. /**
  73389. * Sets the Vector2 coordinates with the given floats
  73390. * @param x defines the first coordinate
  73391. * @param y defines the second coordinate
  73392. * @returns the current updated Vector2
  73393. */
  73394. copyFromFloats(x: number, y: number): Vector2;
  73395. /**
  73396. * Sets the Vector2 coordinates with the given floats
  73397. * @param x defines the first coordinate
  73398. * @param y defines the second coordinate
  73399. * @returns the current updated Vector2
  73400. */
  73401. set(x: number, y: number): Vector2;
  73402. /**
  73403. * Add another vector with the current one
  73404. * @param otherVector defines the other vector
  73405. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  73406. */
  73407. add(otherVector: DeepImmutable<Vector2>): Vector2;
  73408. /**
  73409. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  73410. * @param otherVector defines the other vector
  73411. * @param result defines the target vector
  73412. * @returns the unmodified current Vector2
  73413. */
  73414. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  73415. /**
  73416. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  73417. * @param otherVector defines the other vector
  73418. * @returns the current updated Vector2
  73419. */
  73420. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  73421. /**
  73422. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  73423. * @param otherVector defines the other vector
  73424. * @returns a new Vector2
  73425. */
  73426. addVector3(otherVector: Vector3): Vector2;
  73427. /**
  73428. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  73429. * @param otherVector defines the other vector
  73430. * @returns a new Vector2
  73431. */
  73432. subtract(otherVector: Vector2): Vector2;
  73433. /**
  73434. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  73435. * @param otherVector defines the other vector
  73436. * @param result defines the target vector
  73437. * @returns the unmodified current Vector2
  73438. */
  73439. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  73440. /**
  73441. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  73442. * @param otherVector defines the other vector
  73443. * @returns the current updated Vector2
  73444. */
  73445. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  73446. /**
  73447. * Multiplies in place the current Vector2 coordinates by the given ones
  73448. * @param otherVector defines the other vector
  73449. * @returns the current updated Vector2
  73450. */
  73451. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  73452. /**
  73453. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  73454. * @param otherVector defines the other vector
  73455. * @returns a new Vector2
  73456. */
  73457. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  73458. /**
  73459. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  73460. * @param otherVector defines the other vector
  73461. * @param result defines the target vector
  73462. * @returns the unmodified current Vector2
  73463. */
  73464. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  73465. /**
  73466. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  73467. * @param x defines the first coordinate
  73468. * @param y defines the second coordinate
  73469. * @returns a new Vector2
  73470. */
  73471. multiplyByFloats(x: number, y: number): Vector2;
  73472. /**
  73473. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  73474. * @param otherVector defines the other vector
  73475. * @returns a new Vector2
  73476. */
  73477. divide(otherVector: Vector2): Vector2;
  73478. /**
  73479. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  73480. * @param otherVector defines the other vector
  73481. * @param result defines the target vector
  73482. * @returns the unmodified current Vector2
  73483. */
  73484. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  73485. /**
  73486. * Divides the current Vector2 coordinates by the given ones
  73487. * @param otherVector defines the other vector
  73488. * @returns the current updated Vector2
  73489. */
  73490. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  73491. /**
  73492. * Gets a new Vector2 with current Vector2 negated coordinates
  73493. * @returns a new Vector2
  73494. */
  73495. negate(): Vector2;
  73496. /**
  73497. * Multiply the Vector2 coordinates by scale
  73498. * @param scale defines the scaling factor
  73499. * @returns the current updated Vector2
  73500. */
  73501. scaleInPlace(scale: number): Vector2;
  73502. /**
  73503. * Returns a new Vector2 scaled by "scale" from the current Vector2
  73504. * @param scale defines the scaling factor
  73505. * @returns a new Vector2
  73506. */
  73507. scale(scale: number): Vector2;
  73508. /**
  73509. * Scale the current Vector2 values by a factor to a given Vector2
  73510. * @param scale defines the scale factor
  73511. * @param result defines the Vector2 object where to store the result
  73512. * @returns the unmodified current Vector2
  73513. */
  73514. scaleToRef(scale: number, result: Vector2): Vector2;
  73515. /**
  73516. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  73517. * @param scale defines the scale factor
  73518. * @param result defines the Vector2 object where to store the result
  73519. * @returns the unmodified current Vector2
  73520. */
  73521. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  73522. /**
  73523. * Gets a boolean if two vectors are equals
  73524. * @param otherVector defines the other vector
  73525. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  73526. */
  73527. equals(otherVector: DeepImmutable<Vector2>): boolean;
  73528. /**
  73529. * Gets a boolean if two vectors are equals (using an epsilon value)
  73530. * @param otherVector defines the other vector
  73531. * @param epsilon defines the minimal distance to consider equality
  73532. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  73533. */
  73534. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  73535. /**
  73536. * Gets a new Vector2 from current Vector2 floored values
  73537. * @returns a new Vector2
  73538. */
  73539. floor(): Vector2;
  73540. /**
  73541. * Gets a new Vector2 from current Vector2 floored values
  73542. * @returns a new Vector2
  73543. */
  73544. fract(): Vector2;
  73545. /**
  73546. * Gets the length of the vector
  73547. * @returns the vector length (float)
  73548. */
  73549. length(): number;
  73550. /**
  73551. * Gets the vector squared length
  73552. * @returns the vector squared length (float)
  73553. */
  73554. lengthSquared(): number;
  73555. /**
  73556. * Normalize the vector
  73557. * @returns the current updated Vector2
  73558. */
  73559. normalize(): Vector2;
  73560. /**
  73561. * Gets a new Vector2 copied from the Vector2
  73562. * @returns a new Vector2
  73563. */
  73564. clone(): Vector2;
  73565. /**
  73566. * Gets a new Vector2(0, 0)
  73567. * @returns a new Vector2
  73568. */
  73569. static Zero(): Vector2;
  73570. /**
  73571. * Gets a new Vector2(1, 1)
  73572. * @returns a new Vector2
  73573. */
  73574. static One(): Vector2;
  73575. /**
  73576. * Gets a new Vector2 set from the given index element of the given array
  73577. * @param array defines the data source
  73578. * @param offset defines the offset in the data source
  73579. * @returns a new Vector2
  73580. */
  73581. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  73582. /**
  73583. * Sets "result" from the given index element of the given array
  73584. * @param array defines the data source
  73585. * @param offset defines the offset in the data source
  73586. * @param result defines the target vector
  73587. */
  73588. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  73589. /**
  73590. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  73591. * @param value1 defines 1st point of control
  73592. * @param value2 defines 2nd point of control
  73593. * @param value3 defines 3rd point of control
  73594. * @param value4 defines 4th point of control
  73595. * @param amount defines the interpolation factor
  73596. * @returns a new Vector2
  73597. */
  73598. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  73599. /**
  73600. * 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".
  73601. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  73602. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  73603. * @param value defines the value to clamp
  73604. * @param min defines the lower limit
  73605. * @param max defines the upper limit
  73606. * @returns a new Vector2
  73607. */
  73608. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  73609. /**
  73610. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  73611. * @param value1 defines the 1st control point
  73612. * @param tangent1 defines the outgoing tangent
  73613. * @param value2 defines the 2nd control point
  73614. * @param tangent2 defines the incoming tangent
  73615. * @param amount defines the interpolation factor
  73616. * @returns a new Vector2
  73617. */
  73618. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  73619. /**
  73620. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  73621. * @param start defines the start vector
  73622. * @param end defines the end vector
  73623. * @param amount defines the interpolation factor
  73624. * @returns a new Vector2
  73625. */
  73626. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  73627. /**
  73628. * Gets the dot product of the vector "left" and the vector "right"
  73629. * @param left defines first vector
  73630. * @param right defines second vector
  73631. * @returns the dot product (float)
  73632. */
  73633. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  73634. /**
  73635. * Returns a new Vector2 equal to the normalized given vector
  73636. * @param vector defines the vector to normalize
  73637. * @returns a new Vector2
  73638. */
  73639. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  73640. /**
  73641. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  73642. * @param left defines 1st vector
  73643. * @param right defines 2nd vector
  73644. * @returns a new Vector2
  73645. */
  73646. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  73647. /**
  73648. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  73649. * @param left defines 1st vector
  73650. * @param right defines 2nd vector
  73651. * @returns a new Vector2
  73652. */
  73653. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  73654. /**
  73655. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  73656. * @param vector defines the vector to transform
  73657. * @param transformation defines the matrix to apply
  73658. * @returns a new Vector2
  73659. */
  73660. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  73661. /**
  73662. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  73663. * @param vector defines the vector to transform
  73664. * @param transformation defines the matrix to apply
  73665. * @param result defines the target vector
  73666. */
  73667. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  73668. /**
  73669. * Determines if a given vector is included in a triangle
  73670. * @param p defines the vector to test
  73671. * @param p0 defines 1st triangle point
  73672. * @param p1 defines 2nd triangle point
  73673. * @param p2 defines 3rd triangle point
  73674. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  73675. */
  73676. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  73677. /**
  73678. * Gets the distance between the vectors "value1" and "value2"
  73679. * @param value1 defines first vector
  73680. * @param value2 defines second vector
  73681. * @returns the distance between vectors
  73682. */
  73683. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  73684. /**
  73685. * Returns the squared distance between the vectors "value1" and "value2"
  73686. * @param value1 defines first vector
  73687. * @param value2 defines second vector
  73688. * @returns the squared distance between vectors
  73689. */
  73690. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  73691. /**
  73692. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  73693. * @param value1 defines first vector
  73694. * @param value2 defines second vector
  73695. * @returns a new Vector2
  73696. */
  73697. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  73698. /**
  73699. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  73700. * @param p defines the middle point
  73701. * @param segA defines one point of the segment
  73702. * @param segB defines the other point of the segment
  73703. * @returns the shortest distance
  73704. */
  73705. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  73706. }
  73707. /**
  73708. * Class used to store (x,y,z) vector representation
  73709. * A Vector3 is the main object used in 3D geometry
  73710. * It can represent etiher the coordinates of a point the space, either a direction
  73711. * Reminder: js uses a left handed forward facing system
  73712. */
  73713. export class Vector3 {
  73714. /**
  73715. * Defines the first coordinates (on X axis)
  73716. */
  73717. x: number;
  73718. /**
  73719. * Defines the second coordinates (on Y axis)
  73720. */
  73721. y: number;
  73722. /**
  73723. * Defines the third coordinates (on Z axis)
  73724. */
  73725. z: number;
  73726. private static _UpReadOnly;
  73727. private static _ZeroReadOnly;
  73728. /**
  73729. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  73730. * @param x defines the first coordinates (on X axis)
  73731. * @param y defines the second coordinates (on Y axis)
  73732. * @param z defines the third coordinates (on Z axis)
  73733. */
  73734. constructor(
  73735. /**
  73736. * Defines the first coordinates (on X axis)
  73737. */
  73738. x?: number,
  73739. /**
  73740. * Defines the second coordinates (on Y axis)
  73741. */
  73742. y?: number,
  73743. /**
  73744. * Defines the third coordinates (on Z axis)
  73745. */
  73746. z?: number);
  73747. /**
  73748. * Creates a string representation of the Vector3
  73749. * @returns a string with the Vector3 coordinates.
  73750. */
  73751. toString(): string;
  73752. /**
  73753. * Gets the class name
  73754. * @returns the string "Vector3"
  73755. */
  73756. getClassName(): string;
  73757. /**
  73758. * Creates the Vector3 hash code
  73759. * @returns a number which tends to be unique between Vector3 instances
  73760. */
  73761. getHashCode(): number;
  73762. /**
  73763. * Creates an array containing three elements : the coordinates of the Vector3
  73764. * @returns a new array of numbers
  73765. */
  73766. asArray(): number[];
  73767. /**
  73768. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  73769. * @param array defines the destination array
  73770. * @param index defines the offset in the destination array
  73771. * @returns the current Vector3
  73772. */
  73773. toArray(array: FloatArray, index?: number): Vector3;
  73774. /**
  73775. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  73776. * @returns a new Quaternion object, computed from the Vector3 coordinates
  73777. */
  73778. toQuaternion(): Quaternion;
  73779. /**
  73780. * Adds the given vector to the current Vector3
  73781. * @param otherVector defines the second operand
  73782. * @returns the current updated Vector3
  73783. */
  73784. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73785. /**
  73786. * Adds the given coordinates to the current Vector3
  73787. * @param x defines the x coordinate of the operand
  73788. * @param y defines the y coordinate of the operand
  73789. * @param z defines the z coordinate of the operand
  73790. * @returns the current updated Vector3
  73791. */
  73792. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73793. /**
  73794. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  73795. * @param otherVector defines the second operand
  73796. * @returns the resulting Vector3
  73797. */
  73798. add(otherVector: DeepImmutable<Vector3>): Vector3;
  73799. /**
  73800. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  73801. * @param otherVector defines the second operand
  73802. * @param result defines the Vector3 object where to store the result
  73803. * @returns the current Vector3
  73804. */
  73805. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73806. /**
  73807. * Subtract the given vector from the current Vector3
  73808. * @param otherVector defines the second operand
  73809. * @returns the current updated Vector3
  73810. */
  73811. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73812. /**
  73813. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  73814. * @param otherVector defines the second operand
  73815. * @returns the resulting Vector3
  73816. */
  73817. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  73818. /**
  73819. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  73820. * @param otherVector defines the second operand
  73821. * @param result defines the Vector3 object where to store the result
  73822. * @returns the current Vector3
  73823. */
  73824. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73825. /**
  73826. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  73827. * @param x defines the x coordinate of the operand
  73828. * @param y defines the y coordinate of the operand
  73829. * @param z defines the z coordinate of the operand
  73830. * @returns the resulting Vector3
  73831. */
  73832. subtractFromFloats(x: number, y: number, z: number): Vector3;
  73833. /**
  73834. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  73835. * @param x defines the x coordinate of the operand
  73836. * @param y defines the y coordinate of the operand
  73837. * @param z defines the z coordinate of the operand
  73838. * @param result defines the Vector3 object where to store the result
  73839. * @returns the current Vector3
  73840. */
  73841. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  73842. /**
  73843. * Gets a new Vector3 set with the current Vector3 negated coordinates
  73844. * @returns a new Vector3
  73845. */
  73846. negate(): Vector3;
  73847. /**
  73848. * Negate this vector in place
  73849. * @returns this
  73850. */
  73851. negateInPlace(): Vector3;
  73852. /**
  73853. * Multiplies the Vector3 coordinates by the float "scale"
  73854. * @param scale defines the multiplier factor
  73855. * @returns the current updated Vector3
  73856. */
  73857. scaleInPlace(scale: number): Vector3;
  73858. /**
  73859. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  73860. * @param scale defines the multiplier factor
  73861. * @returns a new Vector3
  73862. */
  73863. scale(scale: number): Vector3;
  73864. /**
  73865. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  73866. * @param scale defines the multiplier factor
  73867. * @param result defines the Vector3 object where to store the result
  73868. * @returns the current Vector3
  73869. */
  73870. scaleToRef(scale: number, result: Vector3): Vector3;
  73871. /**
  73872. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  73873. * @param scale defines the scale factor
  73874. * @param result defines the Vector3 object where to store the result
  73875. * @returns the unmodified current Vector3
  73876. */
  73877. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  73878. /**
  73879. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  73880. * @param otherVector defines the second operand
  73881. * @returns true if both vectors are equals
  73882. */
  73883. equals(otherVector: DeepImmutable<Vector3>): boolean;
  73884. /**
  73885. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  73886. * @param otherVector defines the second operand
  73887. * @param epsilon defines the minimal distance to define values as equals
  73888. * @returns true if both vectors are distant less than epsilon
  73889. */
  73890. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  73891. /**
  73892. * Returns true if the current Vector3 coordinates equals the given floats
  73893. * @param x defines the x coordinate of the operand
  73894. * @param y defines the y coordinate of the operand
  73895. * @param z defines the z coordinate of the operand
  73896. * @returns true if both vectors are equals
  73897. */
  73898. equalsToFloats(x: number, y: number, z: number): boolean;
  73899. /**
  73900. * Multiplies the current Vector3 coordinates by the given ones
  73901. * @param otherVector defines the second operand
  73902. * @returns the current updated Vector3
  73903. */
  73904. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73905. /**
  73906. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  73907. * @param otherVector defines the second operand
  73908. * @returns the new Vector3
  73909. */
  73910. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  73911. /**
  73912. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  73913. * @param otherVector defines the second operand
  73914. * @param result defines the Vector3 object where to store the result
  73915. * @returns the current Vector3
  73916. */
  73917. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73918. /**
  73919. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  73920. * @param x defines the x coordinate of the operand
  73921. * @param y defines the y coordinate of the operand
  73922. * @param z defines the z coordinate of the operand
  73923. * @returns the new Vector3
  73924. */
  73925. multiplyByFloats(x: number, y: number, z: number): Vector3;
  73926. /**
  73927. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  73928. * @param otherVector defines the second operand
  73929. * @returns the new Vector3
  73930. */
  73931. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  73932. /**
  73933. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  73934. * @param otherVector defines the second operand
  73935. * @param result defines the Vector3 object where to store the result
  73936. * @returns the current Vector3
  73937. */
  73938. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73939. /**
  73940. * Divides the current Vector3 coordinates by the given ones.
  73941. * @param otherVector defines the second operand
  73942. * @returns the current updated Vector3
  73943. */
  73944. divideInPlace(otherVector: Vector3): Vector3;
  73945. /**
  73946. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  73947. * @param other defines the second operand
  73948. * @returns the current updated Vector3
  73949. */
  73950. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73951. /**
  73952. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  73953. * @param other defines the second operand
  73954. * @returns the current updated Vector3
  73955. */
  73956. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73957. /**
  73958. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  73959. * @param x defines the x coordinate of the operand
  73960. * @param y defines the y coordinate of the operand
  73961. * @param z defines the z coordinate of the operand
  73962. * @returns the current updated Vector3
  73963. */
  73964. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73965. /**
  73966. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  73967. * @param x defines the x coordinate of the operand
  73968. * @param y defines the y coordinate of the operand
  73969. * @param z defines the z coordinate of the operand
  73970. * @returns the current updated Vector3
  73971. */
  73972. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73973. /**
  73974. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  73975. * Check if is non uniform within a certain amount of decimal places to account for this
  73976. * @param epsilon the amount the values can differ
  73977. * @returns if the the vector is non uniform to a certain number of decimal places
  73978. */
  73979. isNonUniformWithinEpsilon(epsilon: number): boolean;
  73980. /**
  73981. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  73982. */
  73983. get isNonUniform(): boolean;
  73984. /**
  73985. * Gets a new Vector3 from current Vector3 floored values
  73986. * @returns a new Vector3
  73987. */
  73988. floor(): Vector3;
  73989. /**
  73990. * Gets a new Vector3 from current Vector3 floored values
  73991. * @returns a new Vector3
  73992. */
  73993. fract(): Vector3;
  73994. /**
  73995. * Gets the length of the Vector3
  73996. * @returns the length of the Vector3
  73997. */
  73998. length(): number;
  73999. /**
  74000. * Gets the squared length of the Vector3
  74001. * @returns squared length of the Vector3
  74002. */
  74003. lengthSquared(): number;
  74004. /**
  74005. * Normalize the current Vector3.
  74006. * Please note that this is an in place operation.
  74007. * @returns the current updated Vector3
  74008. */
  74009. normalize(): Vector3;
  74010. /**
  74011. * Reorders the x y z properties of the vector in place
  74012. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  74013. * @returns the current updated vector
  74014. */
  74015. reorderInPlace(order: string): this;
  74016. /**
  74017. * Rotates the vector around 0,0,0 by a quaternion
  74018. * @param quaternion the rotation quaternion
  74019. * @param result vector to store the result
  74020. * @returns the resulting vector
  74021. */
  74022. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  74023. /**
  74024. * Rotates a vector around a given point
  74025. * @param quaternion the rotation quaternion
  74026. * @param point the point to rotate around
  74027. * @param result vector to store the result
  74028. * @returns the resulting vector
  74029. */
  74030. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  74031. /**
  74032. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  74033. * The cross product is then orthogonal to both current and "other"
  74034. * @param other defines the right operand
  74035. * @returns the cross product
  74036. */
  74037. cross(other: Vector3): Vector3;
  74038. /**
  74039. * Normalize the current Vector3 with the given input length.
  74040. * Please note that this is an in place operation.
  74041. * @param len the length of the vector
  74042. * @returns the current updated Vector3
  74043. */
  74044. normalizeFromLength(len: number): Vector3;
  74045. /**
  74046. * Normalize the current Vector3 to a new vector
  74047. * @returns the new Vector3
  74048. */
  74049. normalizeToNew(): Vector3;
  74050. /**
  74051. * Normalize the current Vector3 to the reference
  74052. * @param reference define the Vector3 to update
  74053. * @returns the updated Vector3
  74054. */
  74055. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  74056. /**
  74057. * Creates a new Vector3 copied from the current Vector3
  74058. * @returns the new Vector3
  74059. */
  74060. clone(): Vector3;
  74061. /**
  74062. * Copies the given vector coordinates to the current Vector3 ones
  74063. * @param source defines the source Vector3
  74064. * @returns the current updated Vector3
  74065. */
  74066. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  74067. /**
  74068. * Copies the given floats to the current Vector3 coordinates
  74069. * @param x defines the x coordinate of the operand
  74070. * @param y defines the y coordinate of the operand
  74071. * @param z defines the z coordinate of the operand
  74072. * @returns the current updated Vector3
  74073. */
  74074. copyFromFloats(x: number, y: number, z: number): Vector3;
  74075. /**
  74076. * Copies the given floats to the current Vector3 coordinates
  74077. * @param x defines the x coordinate of the operand
  74078. * @param y defines the y coordinate of the operand
  74079. * @param z defines the z coordinate of the operand
  74080. * @returns the current updated Vector3
  74081. */
  74082. set(x: number, y: number, z: number): Vector3;
  74083. /**
  74084. * Copies the given float to the current Vector3 coordinates
  74085. * @param v defines the x, y and z coordinates of the operand
  74086. * @returns the current updated Vector3
  74087. */
  74088. setAll(v: number): Vector3;
  74089. /**
  74090. * Get the clip factor between two vectors
  74091. * @param vector0 defines the first operand
  74092. * @param vector1 defines the second operand
  74093. * @param axis defines the axis to use
  74094. * @param size defines the size along the axis
  74095. * @returns the clip factor
  74096. */
  74097. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  74098. /**
  74099. * Get angle between two vectors
  74100. * @param vector0 angle between vector0 and vector1
  74101. * @param vector1 angle between vector0 and vector1
  74102. * @param normal direction of the normal
  74103. * @return the angle between vector0 and vector1
  74104. */
  74105. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  74106. /**
  74107. * Returns a new Vector3 set from the index "offset" of the given array
  74108. * @param array defines the source array
  74109. * @param offset defines the offset in the source array
  74110. * @returns the new Vector3
  74111. */
  74112. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  74113. /**
  74114. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  74115. * @param array defines the source array
  74116. * @param offset defines the offset in the source array
  74117. * @returns the new Vector3
  74118. * @deprecated Please use FromArray instead.
  74119. */
  74120. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  74121. /**
  74122. * Sets the given vector "result" with the element values from the index "offset" of the given array
  74123. * @param array defines the source array
  74124. * @param offset defines the offset in the source array
  74125. * @param result defines the Vector3 where to store the result
  74126. */
  74127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  74128. /**
  74129. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  74130. * @param array defines the source array
  74131. * @param offset defines the offset in the source array
  74132. * @param result defines the Vector3 where to store the result
  74133. * @deprecated Please use FromArrayToRef instead.
  74134. */
  74135. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  74136. /**
  74137. * Sets the given vector "result" with the given floats.
  74138. * @param x defines the x coordinate of the source
  74139. * @param y defines the y coordinate of the source
  74140. * @param z defines the z coordinate of the source
  74141. * @param result defines the Vector3 where to store the result
  74142. */
  74143. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  74144. /**
  74145. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  74146. * @returns a new empty Vector3
  74147. */
  74148. static Zero(): Vector3;
  74149. /**
  74150. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  74151. * @returns a new unit Vector3
  74152. */
  74153. static One(): Vector3;
  74154. /**
  74155. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  74156. * @returns a new up Vector3
  74157. */
  74158. static Up(): Vector3;
  74159. /**
  74160. * Gets a up Vector3 that must not be updated
  74161. */
  74162. static get UpReadOnly(): DeepImmutable<Vector3>;
  74163. /**
  74164. * Gets a zero Vector3 that must not be updated
  74165. */
  74166. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  74167. /**
  74168. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  74169. * @returns a new down Vector3
  74170. */
  74171. static Down(): Vector3;
  74172. /**
  74173. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  74174. * @returns a new forward Vector3
  74175. */
  74176. static Forward(): Vector3;
  74177. /**
  74178. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  74179. * @returns a new forward Vector3
  74180. */
  74181. static Backward(): Vector3;
  74182. /**
  74183. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  74184. * @returns a new right Vector3
  74185. */
  74186. static Right(): Vector3;
  74187. /**
  74188. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  74189. * @returns a new left Vector3
  74190. */
  74191. static Left(): Vector3;
  74192. /**
  74193. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  74194. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  74195. * @param vector defines the Vector3 to transform
  74196. * @param transformation defines the transformation matrix
  74197. * @returns the transformed Vector3
  74198. */
  74199. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  74200. /**
  74201. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  74202. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  74203. * @param vector defines the Vector3 to transform
  74204. * @param transformation defines the transformation matrix
  74205. * @param result defines the Vector3 where to store the result
  74206. */
  74207. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  74208. /**
  74209. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  74210. * This method computes tranformed coordinates only, not transformed direction vectors
  74211. * @param x define the x coordinate of the source vector
  74212. * @param y define the y coordinate of the source vector
  74213. * @param z define the z coordinate of the source vector
  74214. * @param transformation defines the transformation matrix
  74215. * @param result defines the Vector3 where to store the result
  74216. */
  74217. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  74218. /**
  74219. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  74220. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  74221. * @param vector defines the Vector3 to transform
  74222. * @param transformation defines the transformation matrix
  74223. * @returns the new Vector3
  74224. */
  74225. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  74226. /**
  74227. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  74228. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  74229. * @param vector defines the Vector3 to transform
  74230. * @param transformation defines the transformation matrix
  74231. * @param result defines the Vector3 where to store the result
  74232. */
  74233. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  74234. /**
  74235. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  74236. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  74237. * @param x define the x coordinate of the source vector
  74238. * @param y define the y coordinate of the source vector
  74239. * @param z define the z coordinate of the source vector
  74240. * @param transformation defines the transformation matrix
  74241. * @param result defines the Vector3 where to store the result
  74242. */
  74243. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  74244. /**
  74245. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  74246. * @param value1 defines the first control point
  74247. * @param value2 defines the second control point
  74248. * @param value3 defines the third control point
  74249. * @param value4 defines the fourth control point
  74250. * @param amount defines the amount on the spline to use
  74251. * @returns the new Vector3
  74252. */
  74253. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  74254. /**
  74255. * 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"
  74256. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  74257. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  74258. * @param value defines the current value
  74259. * @param min defines the lower range value
  74260. * @param max defines the upper range value
  74261. * @returns the new Vector3
  74262. */
  74263. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  74264. /**
  74265. * 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"
  74266. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  74267. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  74268. * @param value defines the current value
  74269. * @param min defines the lower range value
  74270. * @param max defines the upper range value
  74271. * @param result defines the Vector3 where to store the result
  74272. */
  74273. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  74274. /**
  74275. * Checks if a given vector is inside a specific range
  74276. * @param v defines the vector to test
  74277. * @param min defines the minimum range
  74278. * @param max defines the maximum range
  74279. */
  74280. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  74281. /**
  74282. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  74283. * @param value1 defines the first control point
  74284. * @param tangent1 defines the first tangent vector
  74285. * @param value2 defines the second control point
  74286. * @param tangent2 defines the second tangent vector
  74287. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  74288. * @returns the new Vector3
  74289. */
  74290. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  74291. /**
  74292. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  74293. * @param start defines the start value
  74294. * @param end defines the end value
  74295. * @param amount max defines amount between both (between 0 and 1)
  74296. * @returns the new Vector3
  74297. */
  74298. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  74299. /**
  74300. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  74301. * @param start defines the start value
  74302. * @param end defines the end value
  74303. * @param amount max defines amount between both (between 0 and 1)
  74304. * @param result defines the Vector3 where to store the result
  74305. */
  74306. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  74307. /**
  74308. * Returns the dot product (float) between the vectors "left" and "right"
  74309. * @param left defines the left operand
  74310. * @param right defines the right operand
  74311. * @returns the dot product
  74312. */
  74313. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  74314. /**
  74315. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  74316. * The cross product is then orthogonal to both "left" and "right"
  74317. * @param left defines the left operand
  74318. * @param right defines the right operand
  74319. * @returns the cross product
  74320. */
  74321. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  74322. /**
  74323. * Sets the given vector "result" with the cross product of "left" and "right"
  74324. * The cross product is then orthogonal to both "left" and "right"
  74325. * @param left defines the left operand
  74326. * @param right defines the right operand
  74327. * @param result defines the Vector3 where to store the result
  74328. */
  74329. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  74330. /**
  74331. * Returns a new Vector3 as the normalization of the given vector
  74332. * @param vector defines the Vector3 to normalize
  74333. * @returns the new Vector3
  74334. */
  74335. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  74336. /**
  74337. * Sets the given vector "result" with the normalization of the given first vector
  74338. * @param vector defines the Vector3 to normalize
  74339. * @param result defines the Vector3 where to store the result
  74340. */
  74341. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  74342. /**
  74343. * Project a Vector3 onto screen space
  74344. * @param vector defines the Vector3 to project
  74345. * @param world defines the world matrix to use
  74346. * @param transform defines the transform (view x projection) matrix to use
  74347. * @param viewport defines the screen viewport to use
  74348. * @returns the new Vector3
  74349. */
  74350. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  74351. /** @hidden */
  74352. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  74353. /**
  74354. * Unproject from screen space to object space
  74355. * @param source defines the screen space Vector3 to use
  74356. * @param viewportWidth defines the current width of the viewport
  74357. * @param viewportHeight defines the current height of the viewport
  74358. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74359. * @param transform defines the transform (view x projection) matrix to use
  74360. * @returns the new Vector3
  74361. */
  74362. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  74363. /**
  74364. * Unproject from screen space to object space
  74365. * @param source defines the screen space Vector3 to use
  74366. * @param viewportWidth defines the current width of the viewport
  74367. * @param viewportHeight defines the current height of the viewport
  74368. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74369. * @param view defines the view matrix to use
  74370. * @param projection defines the projection matrix to use
  74371. * @returns the new Vector3
  74372. */
  74373. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  74374. /**
  74375. * Unproject from screen space to object space
  74376. * @param source defines the screen space Vector3 to use
  74377. * @param viewportWidth defines the current width of the viewport
  74378. * @param viewportHeight defines the current height of the viewport
  74379. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74380. * @param view defines the view matrix to use
  74381. * @param projection defines the projection matrix to use
  74382. * @param result defines the Vector3 where to store the result
  74383. */
  74384. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  74385. /**
  74386. * Unproject from screen space to object space
  74387. * @param sourceX defines the screen space x coordinate to use
  74388. * @param sourceY defines the screen space y coordinate to use
  74389. * @param sourceZ defines the screen space z coordinate to use
  74390. * @param viewportWidth defines the current width of the viewport
  74391. * @param viewportHeight defines the current height of the viewport
  74392. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74393. * @param view defines the view matrix to use
  74394. * @param projection defines the projection matrix to use
  74395. * @param result defines the Vector3 where to store the result
  74396. */
  74397. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  74398. /**
  74399. * Gets the minimal coordinate values between two Vector3
  74400. * @param left defines the first operand
  74401. * @param right defines the second operand
  74402. * @returns the new Vector3
  74403. */
  74404. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  74405. /**
  74406. * Gets the maximal coordinate values between two Vector3
  74407. * @param left defines the first operand
  74408. * @param right defines the second operand
  74409. * @returns the new Vector3
  74410. */
  74411. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  74412. /**
  74413. * Returns the distance between the vectors "value1" and "value2"
  74414. * @param value1 defines the first operand
  74415. * @param value2 defines the second operand
  74416. * @returns the distance
  74417. */
  74418. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  74419. /**
  74420. * Returns the squared distance between the vectors "value1" and "value2"
  74421. * @param value1 defines the first operand
  74422. * @param value2 defines the second operand
  74423. * @returns the squared distance
  74424. */
  74425. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  74426. /**
  74427. * Returns a new Vector3 located at the center between "value1" and "value2"
  74428. * @param value1 defines the first operand
  74429. * @param value2 defines the second operand
  74430. * @returns the new Vector3
  74431. */
  74432. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  74433. /**
  74434. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  74435. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  74436. * to something in order to rotate it from its local system to the given target system
  74437. * Note: axis1, axis2 and axis3 are normalized during this operation
  74438. * @param axis1 defines the first axis
  74439. * @param axis2 defines the second axis
  74440. * @param axis3 defines the third axis
  74441. * @returns a new Vector3
  74442. */
  74443. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  74444. /**
  74445. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  74446. * @param axis1 defines the first axis
  74447. * @param axis2 defines the second axis
  74448. * @param axis3 defines the third axis
  74449. * @param ref defines the Vector3 where to store the result
  74450. */
  74451. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  74452. }
  74453. /**
  74454. * Vector4 class created for EulerAngle class conversion to Quaternion
  74455. */
  74456. export class Vector4 {
  74457. /** x value of the vector */
  74458. x: number;
  74459. /** y value of the vector */
  74460. y: number;
  74461. /** z value of the vector */
  74462. z: number;
  74463. /** w value of the vector */
  74464. w: number;
  74465. /**
  74466. * Creates a Vector4 object from the given floats.
  74467. * @param x x value of the vector
  74468. * @param y y value of the vector
  74469. * @param z z value of the vector
  74470. * @param w w value of the vector
  74471. */
  74472. constructor(
  74473. /** x value of the vector */
  74474. x: number,
  74475. /** y value of the vector */
  74476. y: number,
  74477. /** z value of the vector */
  74478. z: number,
  74479. /** w value of the vector */
  74480. w: number);
  74481. /**
  74482. * Returns the string with the Vector4 coordinates.
  74483. * @returns a string containing all the vector values
  74484. */
  74485. toString(): string;
  74486. /**
  74487. * Returns the string "Vector4".
  74488. * @returns "Vector4"
  74489. */
  74490. getClassName(): string;
  74491. /**
  74492. * Returns the Vector4 hash code.
  74493. * @returns a unique hash code
  74494. */
  74495. getHashCode(): number;
  74496. /**
  74497. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  74498. * @returns the resulting array
  74499. */
  74500. asArray(): number[];
  74501. /**
  74502. * Populates the given array from the given index with the Vector4 coordinates.
  74503. * @param array array to populate
  74504. * @param index index of the array to start at (default: 0)
  74505. * @returns the Vector4.
  74506. */
  74507. toArray(array: FloatArray, index?: number): Vector4;
  74508. /**
  74509. * Adds the given vector to the current Vector4.
  74510. * @param otherVector the vector to add
  74511. * @returns the updated Vector4.
  74512. */
  74513. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  74514. /**
  74515. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  74516. * @param otherVector the vector to add
  74517. * @returns the resulting vector
  74518. */
  74519. add(otherVector: DeepImmutable<Vector4>): Vector4;
  74520. /**
  74521. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  74522. * @param otherVector the vector to add
  74523. * @param result the vector to store the result
  74524. * @returns the current Vector4.
  74525. */
  74526. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  74527. /**
  74528. * Subtract in place the given vector from the current Vector4.
  74529. * @param otherVector the vector to subtract
  74530. * @returns the updated Vector4.
  74531. */
  74532. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  74533. /**
  74534. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  74535. * @param otherVector the vector to add
  74536. * @returns the new vector with the result
  74537. */
  74538. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  74539. /**
  74540. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  74541. * @param otherVector the vector to subtract
  74542. * @param result the vector to store the result
  74543. * @returns the current Vector4.
  74544. */
  74545. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  74546. /**
  74547. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  74548. */
  74549. /**
  74550. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  74551. * @param x value to subtract
  74552. * @param y value to subtract
  74553. * @param z value to subtract
  74554. * @param w value to subtract
  74555. * @returns new vector containing the result
  74556. */
  74557. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  74558. /**
  74559. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  74560. * @param x value to subtract
  74561. * @param y value to subtract
  74562. * @param z value to subtract
  74563. * @param w value to subtract
  74564. * @param result the vector to store the result in
  74565. * @returns the current Vector4.
  74566. */
  74567. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  74568. /**
  74569. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  74570. * @returns a new vector with the negated values
  74571. */
  74572. negate(): Vector4;
  74573. /**
  74574. * Multiplies the current Vector4 coordinates by scale (float).
  74575. * @param scale the number to scale with
  74576. * @returns the updated Vector4.
  74577. */
  74578. scaleInPlace(scale: number): Vector4;
  74579. /**
  74580. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  74581. * @param scale the number to scale with
  74582. * @returns a new vector with the result
  74583. */
  74584. scale(scale: number): Vector4;
  74585. /**
  74586. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  74587. * @param scale the number to scale with
  74588. * @param result a vector to store the result in
  74589. * @returns the current Vector4.
  74590. */
  74591. scaleToRef(scale: number, result: Vector4): Vector4;
  74592. /**
  74593. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  74594. * @param scale defines the scale factor
  74595. * @param result defines the Vector4 object where to store the result
  74596. * @returns the unmodified current Vector4
  74597. */
  74598. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  74599. /**
  74600. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  74601. * @param otherVector the vector to compare against
  74602. * @returns true if they are equal
  74603. */
  74604. equals(otherVector: DeepImmutable<Vector4>): boolean;
  74605. /**
  74606. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  74607. * @param otherVector vector to compare against
  74608. * @param epsilon (Default: very small number)
  74609. * @returns true if they are equal
  74610. */
  74611. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  74612. /**
  74613. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  74614. * @param x x value to compare against
  74615. * @param y y value to compare against
  74616. * @param z z value to compare against
  74617. * @param w w value to compare against
  74618. * @returns true if equal
  74619. */
  74620. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  74621. /**
  74622. * Multiplies in place the current Vector4 by the given one.
  74623. * @param otherVector vector to multiple with
  74624. * @returns the updated Vector4.
  74625. */
  74626. multiplyInPlace(otherVector: Vector4): Vector4;
  74627. /**
  74628. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  74629. * @param otherVector vector to multiple with
  74630. * @returns resulting new vector
  74631. */
  74632. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  74633. /**
  74634. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  74635. * @param otherVector vector to multiple with
  74636. * @param result vector to store the result
  74637. * @returns the current Vector4.
  74638. */
  74639. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  74640. /**
  74641. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  74642. * @param x x value multiply with
  74643. * @param y y value multiply with
  74644. * @param z z value multiply with
  74645. * @param w w value multiply with
  74646. * @returns resulting new vector
  74647. */
  74648. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  74649. /**
  74650. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  74651. * @param otherVector vector to devide with
  74652. * @returns resulting new vector
  74653. */
  74654. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  74655. /**
  74656. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  74657. * @param otherVector vector to devide with
  74658. * @param result vector to store the result
  74659. * @returns the current Vector4.
  74660. */
  74661. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  74662. /**
  74663. * Divides the current Vector3 coordinates by the given ones.
  74664. * @param otherVector vector to devide with
  74665. * @returns the updated Vector3.
  74666. */
  74667. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  74668. /**
  74669. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  74670. * @param other defines the second operand
  74671. * @returns the current updated Vector4
  74672. */
  74673. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  74674. /**
  74675. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  74676. * @param other defines the second operand
  74677. * @returns the current updated Vector4
  74678. */
  74679. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  74680. /**
  74681. * Gets a new Vector4 from current Vector4 floored values
  74682. * @returns a new Vector4
  74683. */
  74684. floor(): Vector4;
  74685. /**
  74686. * Gets a new Vector4 from current Vector3 floored values
  74687. * @returns a new Vector4
  74688. */
  74689. fract(): Vector4;
  74690. /**
  74691. * Returns the Vector4 length (float).
  74692. * @returns the length
  74693. */
  74694. length(): number;
  74695. /**
  74696. * Returns the Vector4 squared length (float).
  74697. * @returns the length squared
  74698. */
  74699. lengthSquared(): number;
  74700. /**
  74701. * Normalizes in place the Vector4.
  74702. * @returns the updated Vector4.
  74703. */
  74704. normalize(): Vector4;
  74705. /**
  74706. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  74707. * @returns this converted to a new vector3
  74708. */
  74709. toVector3(): Vector3;
  74710. /**
  74711. * Returns a new Vector4 copied from the current one.
  74712. * @returns the new cloned vector
  74713. */
  74714. clone(): Vector4;
  74715. /**
  74716. * Updates the current Vector4 with the given one coordinates.
  74717. * @param source the source vector to copy from
  74718. * @returns the updated Vector4.
  74719. */
  74720. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  74721. /**
  74722. * Updates the current Vector4 coordinates with the given floats.
  74723. * @param x float to copy from
  74724. * @param y float to copy from
  74725. * @param z float to copy from
  74726. * @param w float to copy from
  74727. * @returns the updated Vector4.
  74728. */
  74729. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  74730. /**
  74731. * Updates the current Vector4 coordinates with the given floats.
  74732. * @param x float to set from
  74733. * @param y float to set from
  74734. * @param z float to set from
  74735. * @param w float to set from
  74736. * @returns the updated Vector4.
  74737. */
  74738. set(x: number, y: number, z: number, w: number): Vector4;
  74739. /**
  74740. * Copies the given float to the current Vector3 coordinates
  74741. * @param v defines the x, y, z and w coordinates of the operand
  74742. * @returns the current updated Vector3
  74743. */
  74744. setAll(v: number): Vector4;
  74745. /**
  74746. * Returns a new Vector4 set from the starting index of the given array.
  74747. * @param array the array to pull values from
  74748. * @param offset the offset into the array to start at
  74749. * @returns the new vector
  74750. */
  74751. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  74752. /**
  74753. * Updates the given vector "result" from the starting index of the given array.
  74754. * @param array the array to pull values from
  74755. * @param offset the offset into the array to start at
  74756. * @param result the vector to store the result in
  74757. */
  74758. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  74759. /**
  74760. * Updates the given vector "result" from the starting index of the given Float32Array.
  74761. * @param array the array to pull values from
  74762. * @param offset the offset into the array to start at
  74763. * @param result the vector to store the result in
  74764. */
  74765. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  74766. /**
  74767. * Updates the given vector "result" coordinates from the given floats.
  74768. * @param x float to set from
  74769. * @param y float to set from
  74770. * @param z float to set from
  74771. * @param w float to set from
  74772. * @param result the vector to the floats in
  74773. */
  74774. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  74775. /**
  74776. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  74777. * @returns the new vector
  74778. */
  74779. static Zero(): Vector4;
  74780. /**
  74781. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  74782. * @returns the new vector
  74783. */
  74784. static One(): Vector4;
  74785. /**
  74786. * Returns a new normalized Vector4 from the given one.
  74787. * @param vector the vector to normalize
  74788. * @returns the vector
  74789. */
  74790. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  74791. /**
  74792. * Updates the given vector "result" from the normalization of the given one.
  74793. * @param vector the vector to normalize
  74794. * @param result the vector to store the result in
  74795. */
  74796. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  74797. /**
  74798. * Returns a vector with the minimum values from the left and right vectors
  74799. * @param left left vector to minimize
  74800. * @param right right vector to minimize
  74801. * @returns a new vector with the minimum of the left and right vector values
  74802. */
  74803. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74804. /**
  74805. * Returns a vector with the maximum values from the left and right vectors
  74806. * @param left left vector to maximize
  74807. * @param right right vector to maximize
  74808. * @returns a new vector with the maximum of the left and right vector values
  74809. */
  74810. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74811. /**
  74812. * Returns the distance (float) between the vectors "value1" and "value2".
  74813. * @param value1 value to calulate the distance between
  74814. * @param value2 value to calulate the distance between
  74815. * @return the distance between the two vectors
  74816. */
  74817. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74818. /**
  74819. * Returns the squared distance (float) between the vectors "value1" and "value2".
  74820. * @param value1 value to calulate the distance between
  74821. * @param value2 value to calulate the distance between
  74822. * @return the distance between the two vectors squared
  74823. */
  74824. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74825. /**
  74826. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  74827. * @param value1 value to calulate the center between
  74828. * @param value2 value to calulate the center between
  74829. * @return the center between the two vectors
  74830. */
  74831. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  74832. /**
  74833. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  74834. * This methods computes transformed normalized direction vectors only.
  74835. * @param vector the vector to transform
  74836. * @param transformation the transformation matrix to apply
  74837. * @returns the new vector
  74838. */
  74839. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  74840. /**
  74841. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  74842. * This methods computes transformed normalized direction vectors only.
  74843. * @param vector the vector to transform
  74844. * @param transformation the transformation matrix to apply
  74845. * @param result the vector to store the result in
  74846. */
  74847. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74848. /**
  74849. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  74850. * This methods computes transformed normalized direction vectors only.
  74851. * @param x value to transform
  74852. * @param y value to transform
  74853. * @param z value to transform
  74854. * @param w value to transform
  74855. * @param transformation the transformation matrix to apply
  74856. * @param result the vector to store the results in
  74857. */
  74858. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74859. /**
  74860. * Creates a new Vector4 from a Vector3
  74861. * @param source defines the source data
  74862. * @param w defines the 4th component (default is 0)
  74863. * @returns a new Vector4
  74864. */
  74865. static FromVector3(source: Vector3, w?: number): Vector4;
  74866. }
  74867. /**
  74868. * Class used to store quaternion data
  74869. * @see https://en.wikipedia.org/wiki/Quaternion
  74870. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74871. */
  74872. export class Quaternion {
  74873. /** defines the first component (0 by default) */
  74874. x: number;
  74875. /** defines the second component (0 by default) */
  74876. y: number;
  74877. /** defines the third component (0 by default) */
  74878. z: number;
  74879. /** defines the fourth component (1.0 by default) */
  74880. w: number;
  74881. /**
  74882. * Creates a new Quaternion from the given floats
  74883. * @param x defines the first component (0 by default)
  74884. * @param y defines the second component (0 by default)
  74885. * @param z defines the third component (0 by default)
  74886. * @param w defines the fourth component (1.0 by default)
  74887. */
  74888. constructor(
  74889. /** defines the first component (0 by default) */
  74890. x?: number,
  74891. /** defines the second component (0 by default) */
  74892. y?: number,
  74893. /** defines the third component (0 by default) */
  74894. z?: number,
  74895. /** defines the fourth component (1.0 by default) */
  74896. w?: number);
  74897. /**
  74898. * Gets a string representation for the current quaternion
  74899. * @returns a string with the Quaternion coordinates
  74900. */
  74901. toString(): string;
  74902. /**
  74903. * Gets the class name of the quaternion
  74904. * @returns the string "Quaternion"
  74905. */
  74906. getClassName(): string;
  74907. /**
  74908. * Gets a hash code for this quaternion
  74909. * @returns the quaternion hash code
  74910. */
  74911. getHashCode(): number;
  74912. /**
  74913. * Copy the quaternion to an array
  74914. * @returns a new array populated with 4 elements from the quaternion coordinates
  74915. */
  74916. asArray(): number[];
  74917. /**
  74918. * Check if two quaternions are equals
  74919. * @param otherQuaternion defines the second operand
  74920. * @return true if the current quaternion and the given one coordinates are strictly equals
  74921. */
  74922. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  74923. /**
  74924. * Gets a boolean if two quaternions are equals (using an epsilon value)
  74925. * @param otherQuaternion defines the other quaternion
  74926. * @param epsilon defines the minimal distance to consider equality
  74927. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  74928. */
  74929. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  74930. /**
  74931. * Clone the current quaternion
  74932. * @returns a new quaternion copied from the current one
  74933. */
  74934. clone(): Quaternion;
  74935. /**
  74936. * Copy a quaternion to the current one
  74937. * @param other defines the other quaternion
  74938. * @returns the updated current quaternion
  74939. */
  74940. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  74941. /**
  74942. * Updates the current quaternion with the given float coordinates
  74943. * @param x defines the x coordinate
  74944. * @param y defines the y coordinate
  74945. * @param z defines the z coordinate
  74946. * @param w defines the w coordinate
  74947. * @returns the updated current quaternion
  74948. */
  74949. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  74950. /**
  74951. * Updates the current quaternion from the given float coordinates
  74952. * @param x defines the x coordinate
  74953. * @param y defines the y coordinate
  74954. * @param z defines the z coordinate
  74955. * @param w defines the w coordinate
  74956. * @returns the updated current quaternion
  74957. */
  74958. set(x: number, y: number, z: number, w: number): Quaternion;
  74959. /**
  74960. * Adds two quaternions
  74961. * @param other defines the second operand
  74962. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74963. */
  74964. add(other: DeepImmutable<Quaternion>): Quaternion;
  74965. /**
  74966. * Add a quaternion to the current one
  74967. * @param other defines the quaternion to add
  74968. * @returns the current quaternion
  74969. */
  74970. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  74971. /**
  74972. * Subtract two quaternions
  74973. * @param other defines the second operand
  74974. * @returns a new quaternion as the subtraction result of the given one from the current one
  74975. */
  74976. subtract(other: Quaternion): Quaternion;
  74977. /**
  74978. * Multiplies the current quaternion by a scale factor
  74979. * @param value defines the scale factor
  74980. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74981. */
  74982. scale(value: number): Quaternion;
  74983. /**
  74984. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74985. * @param scale defines the scale factor
  74986. * @param result defines the Quaternion object where to store the result
  74987. * @returns the unmodified current quaternion
  74988. */
  74989. scaleToRef(scale: number, result: Quaternion): Quaternion;
  74990. /**
  74991. * Multiplies in place the current quaternion by a scale factor
  74992. * @param value defines the scale factor
  74993. * @returns the current modified quaternion
  74994. */
  74995. scaleInPlace(value: number): Quaternion;
  74996. /**
  74997. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74998. * @param scale defines the scale factor
  74999. * @param result defines the Quaternion object where to store the result
  75000. * @returns the unmodified current quaternion
  75001. */
  75002. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  75003. /**
  75004. * Multiplies two quaternions
  75005. * @param q1 defines the second operand
  75006. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  75007. */
  75008. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  75009. /**
  75010. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  75011. * @param q1 defines the second operand
  75012. * @param result defines the target quaternion
  75013. * @returns the current quaternion
  75014. */
  75015. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  75016. /**
  75017. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  75018. * @param q1 defines the second operand
  75019. * @returns the currentupdated quaternion
  75020. */
  75021. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  75022. /**
  75023. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  75024. * @param ref defines the target quaternion
  75025. * @returns the current quaternion
  75026. */
  75027. conjugateToRef(ref: Quaternion): Quaternion;
  75028. /**
  75029. * Conjugates in place (1-q) the current quaternion
  75030. * @returns the current updated quaternion
  75031. */
  75032. conjugateInPlace(): Quaternion;
  75033. /**
  75034. * Conjugates in place (1-q) the current quaternion
  75035. * @returns a new quaternion
  75036. */
  75037. conjugate(): Quaternion;
  75038. /**
  75039. * Gets length of current quaternion
  75040. * @returns the quaternion length (float)
  75041. */
  75042. length(): number;
  75043. /**
  75044. * Normalize in place the current quaternion
  75045. * @returns the current updated quaternion
  75046. */
  75047. normalize(): Quaternion;
  75048. /**
  75049. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  75050. * @param order is a reserved parameter and is ignore for now
  75051. * @returns a new Vector3 containing the Euler angles
  75052. */
  75053. toEulerAngles(order?: string): Vector3;
  75054. /**
  75055. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  75056. * @param result defines the vector which will be filled with the Euler angles
  75057. * @param order is a reserved parameter and is ignore for now
  75058. * @returns the current unchanged quaternion
  75059. */
  75060. toEulerAnglesToRef(result: Vector3): Quaternion;
  75061. /**
  75062. * Updates the given rotation matrix with the current quaternion values
  75063. * @param result defines the target matrix
  75064. * @returns the current unchanged quaternion
  75065. */
  75066. toRotationMatrix(result: Matrix): Quaternion;
  75067. /**
  75068. * Updates the current quaternion from the given rotation matrix values
  75069. * @param matrix defines the source matrix
  75070. * @returns the current updated quaternion
  75071. */
  75072. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  75073. /**
  75074. * Creates a new quaternion from a rotation matrix
  75075. * @param matrix defines the source matrix
  75076. * @returns a new quaternion created from the given rotation matrix values
  75077. */
  75078. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  75079. /**
  75080. * Updates the given quaternion with the given rotation matrix values
  75081. * @param matrix defines the source matrix
  75082. * @param result defines the target quaternion
  75083. */
  75084. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  75085. /**
  75086. * Returns the dot product (float) between the quaternions "left" and "right"
  75087. * @param left defines the left operand
  75088. * @param right defines the right operand
  75089. * @returns the dot product
  75090. */
  75091. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  75092. /**
  75093. * Checks if the two quaternions are close to each other
  75094. * @param quat0 defines the first quaternion to check
  75095. * @param quat1 defines the second quaternion to check
  75096. * @returns true if the two quaternions are close to each other
  75097. */
  75098. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  75099. /**
  75100. * Creates an empty quaternion
  75101. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  75102. */
  75103. static Zero(): Quaternion;
  75104. /**
  75105. * Inverse a given quaternion
  75106. * @param q defines the source quaternion
  75107. * @returns a new quaternion as the inverted current quaternion
  75108. */
  75109. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  75110. /**
  75111. * Inverse a given quaternion
  75112. * @param q defines the source quaternion
  75113. * @param result the quaternion the result will be stored in
  75114. * @returns the result quaternion
  75115. */
  75116. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  75117. /**
  75118. * Creates an identity quaternion
  75119. * @returns the identity quaternion
  75120. */
  75121. static Identity(): Quaternion;
  75122. /**
  75123. * Gets a boolean indicating if the given quaternion is identity
  75124. * @param quaternion defines the quaternion to check
  75125. * @returns true if the quaternion is identity
  75126. */
  75127. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  75128. /**
  75129. * Creates a quaternion from a rotation around an axis
  75130. * @param axis defines the axis to use
  75131. * @param angle defines the angle to use
  75132. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  75133. */
  75134. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  75135. /**
  75136. * Creates a rotation around an axis and stores it into the given quaternion
  75137. * @param axis defines the axis to use
  75138. * @param angle defines the angle to use
  75139. * @param result defines the target quaternion
  75140. * @returns the target quaternion
  75141. */
  75142. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  75143. /**
  75144. * Creates a new quaternion from data stored into an array
  75145. * @param array defines the data source
  75146. * @param offset defines the offset in the source array where the data starts
  75147. * @returns a new quaternion
  75148. */
  75149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  75150. /**
  75151. * Create a quaternion from Euler rotation angles
  75152. * @param x Pitch
  75153. * @param y Yaw
  75154. * @param z Roll
  75155. * @returns the new Quaternion
  75156. */
  75157. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  75158. /**
  75159. * Updates a quaternion from Euler rotation angles
  75160. * @param x Pitch
  75161. * @param y Yaw
  75162. * @param z Roll
  75163. * @param result the quaternion to store the result
  75164. * @returns the updated quaternion
  75165. */
  75166. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  75167. /**
  75168. * Create a quaternion from Euler rotation vector
  75169. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  75170. * @returns the new Quaternion
  75171. */
  75172. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  75173. /**
  75174. * Updates a quaternion from Euler rotation vector
  75175. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  75176. * @param result the quaternion to store the result
  75177. * @returns the updated quaternion
  75178. */
  75179. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  75180. /**
  75181. * Creates a new quaternion from the given Euler float angles (y, x, z)
  75182. * @param yaw defines the rotation around Y axis
  75183. * @param pitch defines the rotation around X axis
  75184. * @param roll defines the rotation around Z axis
  75185. * @returns the new quaternion
  75186. */
  75187. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  75188. /**
  75189. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  75190. * @param yaw defines the rotation around Y axis
  75191. * @param pitch defines the rotation around X axis
  75192. * @param roll defines the rotation around Z axis
  75193. * @param result defines the target quaternion
  75194. */
  75195. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  75196. /**
  75197. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  75198. * @param alpha defines the rotation around first axis
  75199. * @param beta defines the rotation around second axis
  75200. * @param gamma defines the rotation around third axis
  75201. * @returns the new quaternion
  75202. */
  75203. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  75204. /**
  75205. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  75206. * @param alpha defines the rotation around first axis
  75207. * @param beta defines the rotation around second axis
  75208. * @param gamma defines the rotation around third axis
  75209. * @param result defines the target quaternion
  75210. */
  75211. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  75212. /**
  75213. * 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)
  75214. * @param axis1 defines the first axis
  75215. * @param axis2 defines the second axis
  75216. * @param axis3 defines the third axis
  75217. * @returns the new quaternion
  75218. */
  75219. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  75220. /**
  75221. * 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
  75222. * @param axis1 defines the first axis
  75223. * @param axis2 defines the second axis
  75224. * @param axis3 defines the third axis
  75225. * @param ref defines the target quaternion
  75226. */
  75227. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  75228. /**
  75229. * Interpolates between two quaternions
  75230. * @param left defines first quaternion
  75231. * @param right defines second quaternion
  75232. * @param amount defines the gradient to use
  75233. * @returns the new interpolated quaternion
  75234. */
  75235. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  75236. /**
  75237. * Interpolates between two quaternions and stores it into a target quaternion
  75238. * @param left defines first quaternion
  75239. * @param right defines second quaternion
  75240. * @param amount defines the gradient to use
  75241. * @param result defines the target quaternion
  75242. */
  75243. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  75244. /**
  75245. * Interpolate between two quaternions using Hermite interpolation
  75246. * @param value1 defines first quaternion
  75247. * @param tangent1 defines the incoming tangent
  75248. * @param value2 defines second quaternion
  75249. * @param tangent2 defines the outgoing tangent
  75250. * @param amount defines the target quaternion
  75251. * @returns the new interpolated quaternion
  75252. */
  75253. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  75254. }
  75255. /**
  75256. * Class used to store matrix data (4x4)
  75257. */
  75258. export class Matrix {
  75259. private static _updateFlagSeed;
  75260. private static _identityReadOnly;
  75261. private _isIdentity;
  75262. private _isIdentityDirty;
  75263. private _isIdentity3x2;
  75264. private _isIdentity3x2Dirty;
  75265. /**
  75266. * Gets the update flag of the matrix which is an unique number for the matrix.
  75267. * It will be incremented every time the matrix data change.
  75268. * You can use it to speed the comparison between two versions of the same matrix.
  75269. */
  75270. updateFlag: number;
  75271. private readonly _m;
  75272. /**
  75273. * Gets the internal data of the matrix
  75274. */
  75275. get m(): DeepImmutable<Float32Array>;
  75276. /** @hidden */
  75277. _markAsUpdated(): void;
  75278. /** @hidden */
  75279. private _updateIdentityStatus;
  75280. /**
  75281. * Creates an empty matrix (filled with zeros)
  75282. */
  75283. constructor();
  75284. /**
  75285. * Check if the current matrix is identity
  75286. * @returns true is the matrix is the identity matrix
  75287. */
  75288. isIdentity(): boolean;
  75289. /**
  75290. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  75291. * @returns true is the matrix is the identity matrix
  75292. */
  75293. isIdentityAs3x2(): boolean;
  75294. /**
  75295. * Gets the determinant of the matrix
  75296. * @returns the matrix determinant
  75297. */
  75298. determinant(): number;
  75299. /**
  75300. * Returns the matrix as a Float32Array
  75301. * @returns the matrix underlying array
  75302. */
  75303. toArray(): DeepImmutable<Float32Array>;
  75304. /**
  75305. * Returns the matrix as a Float32Array
  75306. * @returns the matrix underlying array.
  75307. */
  75308. asArray(): DeepImmutable<Float32Array>;
  75309. /**
  75310. * Inverts the current matrix in place
  75311. * @returns the current inverted matrix
  75312. */
  75313. invert(): Matrix;
  75314. /**
  75315. * Sets all the matrix elements to zero
  75316. * @returns the current matrix
  75317. */
  75318. reset(): Matrix;
  75319. /**
  75320. * Adds the current matrix with a second one
  75321. * @param other defines the matrix to add
  75322. * @returns a new matrix as the addition of the current matrix and the given one
  75323. */
  75324. add(other: DeepImmutable<Matrix>): Matrix;
  75325. /**
  75326. * Sets the given matrix "result" to the addition of the current matrix and the given one
  75327. * @param other defines the matrix to add
  75328. * @param result defines the target matrix
  75329. * @returns the current matrix
  75330. */
  75331. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  75332. /**
  75333. * Adds in place the given matrix to the current matrix
  75334. * @param other defines the second operand
  75335. * @returns the current updated matrix
  75336. */
  75337. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  75338. /**
  75339. * Sets the given matrix to the current inverted Matrix
  75340. * @param other defines the target matrix
  75341. * @returns the unmodified current matrix
  75342. */
  75343. invertToRef(other: Matrix): Matrix;
  75344. /**
  75345. * add a value at the specified position in the current Matrix
  75346. * @param index the index of the value within the matrix. between 0 and 15.
  75347. * @param value the value to be added
  75348. * @returns the current updated matrix
  75349. */
  75350. addAtIndex(index: number, value: number): Matrix;
  75351. /**
  75352. * mutiply the specified position in the current Matrix by a value
  75353. * @param index the index of the value within the matrix. between 0 and 15.
  75354. * @param value the value to be added
  75355. * @returns the current updated matrix
  75356. */
  75357. multiplyAtIndex(index: number, value: number): Matrix;
  75358. /**
  75359. * Inserts the translation vector (using 3 floats) in the current matrix
  75360. * @param x defines the 1st component of the translation
  75361. * @param y defines the 2nd component of the translation
  75362. * @param z defines the 3rd component of the translation
  75363. * @returns the current updated matrix
  75364. */
  75365. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  75366. /**
  75367. * Adds the translation vector (using 3 floats) in the current matrix
  75368. * @param x defines the 1st component of the translation
  75369. * @param y defines the 2nd component of the translation
  75370. * @param z defines the 3rd component of the translation
  75371. * @returns the current updated matrix
  75372. */
  75373. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  75374. /**
  75375. * Inserts the translation vector in the current matrix
  75376. * @param vector3 defines the translation to insert
  75377. * @returns the current updated matrix
  75378. */
  75379. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  75380. /**
  75381. * Gets the translation value of the current matrix
  75382. * @returns a new Vector3 as the extracted translation from the matrix
  75383. */
  75384. getTranslation(): Vector3;
  75385. /**
  75386. * Fill a Vector3 with the extracted translation from the matrix
  75387. * @param result defines the Vector3 where to store the translation
  75388. * @returns the current matrix
  75389. */
  75390. getTranslationToRef(result: Vector3): Matrix;
  75391. /**
  75392. * Remove rotation and scaling part from the matrix
  75393. * @returns the updated matrix
  75394. */
  75395. removeRotationAndScaling(): Matrix;
  75396. /**
  75397. * Multiply two matrices
  75398. * @param other defines the second operand
  75399. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  75400. */
  75401. multiply(other: DeepImmutable<Matrix>): Matrix;
  75402. /**
  75403. * Copy the current matrix from the given one
  75404. * @param other defines the source matrix
  75405. * @returns the current updated matrix
  75406. */
  75407. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  75408. /**
  75409. * Populates the given array from the starting index with the current matrix values
  75410. * @param array defines the target array
  75411. * @param offset defines the offset in the target array where to start storing values
  75412. * @returns the current matrix
  75413. */
  75414. copyToArray(array: Float32Array, offset?: number): Matrix;
  75415. /**
  75416. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  75417. * @param other defines the second operand
  75418. * @param result defines the matrix where to store the multiplication
  75419. * @returns the current matrix
  75420. */
  75421. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  75422. /**
  75423. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  75424. * @param other defines the second operand
  75425. * @param result defines the array where to store the multiplication
  75426. * @param offset defines the offset in the target array where to start storing values
  75427. * @returns the current matrix
  75428. */
  75429. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  75430. /**
  75431. * Check equality between this matrix and a second one
  75432. * @param value defines the second matrix to compare
  75433. * @returns true is the current matrix and the given one values are strictly equal
  75434. */
  75435. equals(value: DeepImmutable<Matrix>): boolean;
  75436. /**
  75437. * Clone the current matrix
  75438. * @returns a new matrix from the current matrix
  75439. */
  75440. clone(): Matrix;
  75441. /**
  75442. * Returns the name of the current matrix class
  75443. * @returns the string "Matrix"
  75444. */
  75445. getClassName(): string;
  75446. /**
  75447. * Gets the hash code of the current matrix
  75448. * @returns the hash code
  75449. */
  75450. getHashCode(): number;
  75451. /**
  75452. * Decomposes the current Matrix into a translation, rotation and scaling components
  75453. * @param scale defines the scale vector3 given as a reference to update
  75454. * @param rotation defines the rotation quaternion given as a reference to update
  75455. * @param translation defines the translation vector3 given as a reference to update
  75456. * @returns true if operation was successful
  75457. */
  75458. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  75459. /**
  75460. * Gets specific row of the matrix
  75461. * @param index defines the number of the row to get
  75462. * @returns the index-th row of the current matrix as a new Vector4
  75463. */
  75464. getRow(index: number): Nullable<Vector4>;
  75465. /**
  75466. * Sets the index-th row of the current matrix to the vector4 values
  75467. * @param index defines the number of the row to set
  75468. * @param row defines the target vector4
  75469. * @returns the updated current matrix
  75470. */
  75471. setRow(index: number, row: Vector4): Matrix;
  75472. /**
  75473. * Compute the transpose of the matrix
  75474. * @returns the new transposed matrix
  75475. */
  75476. transpose(): Matrix;
  75477. /**
  75478. * Compute the transpose of the matrix and store it in a given matrix
  75479. * @param result defines the target matrix
  75480. * @returns the current matrix
  75481. */
  75482. transposeToRef(result: Matrix): Matrix;
  75483. /**
  75484. * Sets the index-th row of the current matrix with the given 4 x float values
  75485. * @param index defines the row index
  75486. * @param x defines the x component to set
  75487. * @param y defines the y component to set
  75488. * @param z defines the z component to set
  75489. * @param w defines the w component to set
  75490. * @returns the updated current matrix
  75491. */
  75492. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  75493. /**
  75494. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  75495. * @param scale defines the scale factor
  75496. * @returns a new matrix
  75497. */
  75498. scale(scale: number): Matrix;
  75499. /**
  75500. * Scale the current matrix values by a factor to a given result matrix
  75501. * @param scale defines the scale factor
  75502. * @param result defines the matrix to store the result
  75503. * @returns the current matrix
  75504. */
  75505. scaleToRef(scale: number, result: Matrix): Matrix;
  75506. /**
  75507. * Scale the current matrix values by a factor and add the result to a given matrix
  75508. * @param scale defines the scale factor
  75509. * @param result defines the Matrix to store the result
  75510. * @returns the current matrix
  75511. */
  75512. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  75513. /**
  75514. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  75515. * @param ref matrix to store the result
  75516. */
  75517. toNormalMatrix(ref: Matrix): void;
  75518. /**
  75519. * Gets only rotation part of the current matrix
  75520. * @returns a new matrix sets to the extracted rotation matrix from the current one
  75521. */
  75522. getRotationMatrix(): Matrix;
  75523. /**
  75524. * Extracts the rotation matrix from the current one and sets it as the given "result"
  75525. * @param result defines the target matrix to store data to
  75526. * @returns the current matrix
  75527. */
  75528. getRotationMatrixToRef(result: Matrix): Matrix;
  75529. /**
  75530. * Toggles model matrix from being right handed to left handed in place and vice versa
  75531. */
  75532. toggleModelMatrixHandInPlace(): void;
  75533. /**
  75534. * Toggles projection matrix from being right handed to left handed in place and vice versa
  75535. */
  75536. toggleProjectionMatrixHandInPlace(): void;
  75537. /**
  75538. * Creates a matrix from an array
  75539. * @param array defines the source array
  75540. * @param offset defines an offset in the source array
  75541. * @returns a new Matrix set from the starting index of the given array
  75542. */
  75543. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  75544. /**
  75545. * Copy the content of an array into a given matrix
  75546. * @param array defines the source array
  75547. * @param offset defines an offset in the source array
  75548. * @param result defines the target matrix
  75549. */
  75550. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  75551. /**
  75552. * Stores an array into a matrix after having multiplied each component by a given factor
  75553. * @param array defines the source array
  75554. * @param offset defines the offset in the source array
  75555. * @param scale defines the scaling factor
  75556. * @param result defines the target matrix
  75557. */
  75558. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  75559. /**
  75560. * Gets an identity matrix that must not be updated
  75561. */
  75562. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  75563. /**
  75564. * Stores a list of values (16) inside a given matrix
  75565. * @param initialM11 defines 1st value of 1st row
  75566. * @param initialM12 defines 2nd value of 1st row
  75567. * @param initialM13 defines 3rd value of 1st row
  75568. * @param initialM14 defines 4th value of 1st row
  75569. * @param initialM21 defines 1st value of 2nd row
  75570. * @param initialM22 defines 2nd value of 2nd row
  75571. * @param initialM23 defines 3rd value of 2nd row
  75572. * @param initialM24 defines 4th value of 2nd row
  75573. * @param initialM31 defines 1st value of 3rd row
  75574. * @param initialM32 defines 2nd value of 3rd row
  75575. * @param initialM33 defines 3rd value of 3rd row
  75576. * @param initialM34 defines 4th value of 3rd row
  75577. * @param initialM41 defines 1st value of 4th row
  75578. * @param initialM42 defines 2nd value of 4th row
  75579. * @param initialM43 defines 3rd value of 4th row
  75580. * @param initialM44 defines 4th value of 4th row
  75581. * @param result defines the target matrix
  75582. */
  75583. 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;
  75584. /**
  75585. * Creates new matrix from a list of values (16)
  75586. * @param initialM11 defines 1st value of 1st row
  75587. * @param initialM12 defines 2nd value of 1st row
  75588. * @param initialM13 defines 3rd value of 1st row
  75589. * @param initialM14 defines 4th value of 1st row
  75590. * @param initialM21 defines 1st value of 2nd row
  75591. * @param initialM22 defines 2nd value of 2nd row
  75592. * @param initialM23 defines 3rd value of 2nd row
  75593. * @param initialM24 defines 4th value of 2nd row
  75594. * @param initialM31 defines 1st value of 3rd row
  75595. * @param initialM32 defines 2nd value of 3rd row
  75596. * @param initialM33 defines 3rd value of 3rd row
  75597. * @param initialM34 defines 4th value of 3rd row
  75598. * @param initialM41 defines 1st value of 4th row
  75599. * @param initialM42 defines 2nd value of 4th row
  75600. * @param initialM43 defines 3rd value of 4th row
  75601. * @param initialM44 defines 4th value of 4th row
  75602. * @returns the new matrix
  75603. */
  75604. 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;
  75605. /**
  75606. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75607. * @param scale defines the scale vector3
  75608. * @param rotation defines the rotation quaternion
  75609. * @param translation defines the translation vector3
  75610. * @returns a new matrix
  75611. */
  75612. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  75613. /**
  75614. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75615. * @param scale defines the scale vector3
  75616. * @param rotation defines the rotation quaternion
  75617. * @param translation defines the translation vector3
  75618. * @param result defines the target matrix
  75619. */
  75620. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  75621. /**
  75622. * Creates a new identity matrix
  75623. * @returns a new identity matrix
  75624. */
  75625. static Identity(): Matrix;
  75626. /**
  75627. * Creates a new identity matrix and stores the result in a given matrix
  75628. * @param result defines the target matrix
  75629. */
  75630. static IdentityToRef(result: Matrix): void;
  75631. /**
  75632. * Creates a new zero matrix
  75633. * @returns a new zero matrix
  75634. */
  75635. static Zero(): Matrix;
  75636. /**
  75637. * Creates a new rotation matrix for "angle" radians around the X axis
  75638. * @param angle defines the angle (in radians) to use
  75639. * @return the new matrix
  75640. */
  75641. static RotationX(angle: number): Matrix;
  75642. /**
  75643. * Creates a new matrix as the invert of a given matrix
  75644. * @param source defines the source matrix
  75645. * @returns the new matrix
  75646. */
  75647. static Invert(source: DeepImmutable<Matrix>): Matrix;
  75648. /**
  75649. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  75650. * @param angle defines the angle (in radians) to use
  75651. * @param result defines the target matrix
  75652. */
  75653. static RotationXToRef(angle: number, result: Matrix): void;
  75654. /**
  75655. * Creates a new rotation matrix for "angle" radians around the Y axis
  75656. * @param angle defines the angle (in radians) to use
  75657. * @return the new matrix
  75658. */
  75659. static RotationY(angle: number): Matrix;
  75660. /**
  75661. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  75662. * @param angle defines the angle (in radians) to use
  75663. * @param result defines the target matrix
  75664. */
  75665. static RotationYToRef(angle: number, result: Matrix): void;
  75666. /**
  75667. * Creates a new rotation matrix for "angle" radians around the Z axis
  75668. * @param angle defines the angle (in radians) to use
  75669. * @return the new matrix
  75670. */
  75671. static RotationZ(angle: number): Matrix;
  75672. /**
  75673. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  75674. * @param angle defines the angle (in radians) to use
  75675. * @param result defines the target matrix
  75676. */
  75677. static RotationZToRef(angle: number, result: Matrix): void;
  75678. /**
  75679. * Creates a new rotation matrix for "angle" radians around the given axis
  75680. * @param axis defines the axis to use
  75681. * @param angle defines the angle (in radians) to use
  75682. * @return the new matrix
  75683. */
  75684. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  75685. /**
  75686. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  75687. * @param axis defines the axis to use
  75688. * @param angle defines the angle (in radians) to use
  75689. * @param result defines the target matrix
  75690. */
  75691. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  75692. /**
  75693. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  75694. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  75695. * @param from defines the vector to align
  75696. * @param to defines the vector to align to
  75697. * @param result defines the target matrix
  75698. */
  75699. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  75700. /**
  75701. * Creates a rotation matrix
  75702. * @param yaw defines the yaw angle in radians (Y axis)
  75703. * @param pitch defines the pitch angle in radians (X axis)
  75704. * @param roll defines the roll angle in radians (X axis)
  75705. * @returns the new rotation matrix
  75706. */
  75707. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  75708. /**
  75709. * Creates a rotation matrix and stores it in a given matrix
  75710. * @param yaw defines the yaw angle in radians (Y axis)
  75711. * @param pitch defines the pitch angle in radians (X axis)
  75712. * @param roll defines the roll angle in radians (X axis)
  75713. * @param result defines the target matrix
  75714. */
  75715. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  75716. /**
  75717. * Creates a scaling matrix
  75718. * @param x defines the scale factor on X axis
  75719. * @param y defines the scale factor on Y axis
  75720. * @param z defines the scale factor on Z axis
  75721. * @returns the new matrix
  75722. */
  75723. static Scaling(x: number, y: number, z: number): Matrix;
  75724. /**
  75725. * Creates a scaling matrix and stores it in a given matrix
  75726. * @param x defines the scale factor on X axis
  75727. * @param y defines the scale factor on Y axis
  75728. * @param z defines the scale factor on Z axis
  75729. * @param result defines the target matrix
  75730. */
  75731. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  75732. /**
  75733. * Creates a translation matrix
  75734. * @param x defines the translation on X axis
  75735. * @param y defines the translation on Y axis
  75736. * @param z defines the translationon Z axis
  75737. * @returns the new matrix
  75738. */
  75739. static Translation(x: number, y: number, z: number): Matrix;
  75740. /**
  75741. * Creates a translation matrix and stores it in a given matrix
  75742. * @param x defines the translation on X axis
  75743. * @param y defines the translation on Y axis
  75744. * @param z defines the translationon Z axis
  75745. * @param result defines the target matrix
  75746. */
  75747. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  75748. /**
  75749. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75750. * @param startValue defines the start value
  75751. * @param endValue defines the end value
  75752. * @param gradient defines the gradient factor
  75753. * @returns the new matrix
  75754. */
  75755. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  75756. /**
  75757. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75758. * @param startValue defines the start value
  75759. * @param endValue defines the end value
  75760. * @param gradient defines the gradient factor
  75761. * @param result defines the Matrix object where to store data
  75762. */
  75763. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  75764. /**
  75765. * Builds a new matrix whose values are computed by:
  75766. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75767. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75768. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75769. * @param startValue defines the first matrix
  75770. * @param endValue defines the second matrix
  75771. * @param gradient defines the gradient between the two matrices
  75772. * @returns the new matrix
  75773. */
  75774. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  75775. /**
  75776. * Update a matrix to values which are computed by:
  75777. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75778. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75779. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75780. * @param startValue defines the first matrix
  75781. * @param endValue defines the second matrix
  75782. * @param gradient defines the gradient between the two matrices
  75783. * @param result defines the target matrix
  75784. */
  75785. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  75786. /**
  75787. * 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"
  75788. * This function works in left handed mode
  75789. * @param eye defines the final position of the entity
  75790. * @param target defines where the entity should look at
  75791. * @param up defines the up vector for the entity
  75792. * @returns the new matrix
  75793. */
  75794. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75795. /**
  75796. * 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".
  75797. * This function works in left handed mode
  75798. * @param eye defines the final position of the entity
  75799. * @param target defines where the entity should look at
  75800. * @param up defines the up vector for the entity
  75801. * @param result defines the target matrix
  75802. */
  75803. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75804. /**
  75805. * 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"
  75806. * This function works in right handed mode
  75807. * @param eye defines the final position of the entity
  75808. * @param target defines where the entity should look at
  75809. * @param up defines the up vector for the entity
  75810. * @returns the new matrix
  75811. */
  75812. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75813. /**
  75814. * 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".
  75815. * This function works in right handed mode
  75816. * @param eye defines the final position of the entity
  75817. * @param target defines where the entity should look at
  75818. * @param up defines the up vector for the entity
  75819. * @param result defines the target matrix
  75820. */
  75821. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75822. /**
  75823. * Create a left-handed orthographic projection matrix
  75824. * @param width defines the viewport width
  75825. * @param height defines the viewport height
  75826. * @param znear defines the near clip plane
  75827. * @param zfar defines the far clip plane
  75828. * @returns a new matrix as a left-handed orthographic projection matrix
  75829. */
  75830. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75831. /**
  75832. * Store a left-handed orthographic projection to a given matrix
  75833. * @param width defines the viewport width
  75834. * @param height defines the viewport height
  75835. * @param znear defines the near clip plane
  75836. * @param zfar defines the far clip plane
  75837. * @param result defines the target matrix
  75838. */
  75839. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  75840. /**
  75841. * Create a left-handed orthographic projection matrix
  75842. * @param left defines the viewport left coordinate
  75843. * @param right defines the viewport right coordinate
  75844. * @param bottom defines the viewport bottom coordinate
  75845. * @param top defines the viewport top coordinate
  75846. * @param znear defines the near clip plane
  75847. * @param zfar defines the far clip plane
  75848. * @returns a new matrix as a left-handed orthographic projection matrix
  75849. */
  75850. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75851. /**
  75852. * Stores a left-handed orthographic projection into a given matrix
  75853. * @param left defines the viewport left coordinate
  75854. * @param right defines the viewport right coordinate
  75855. * @param bottom defines the viewport bottom coordinate
  75856. * @param top defines the viewport top coordinate
  75857. * @param znear defines the near clip plane
  75858. * @param zfar defines the far clip plane
  75859. * @param result defines the target matrix
  75860. */
  75861. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75862. /**
  75863. * Creates a right-handed orthographic projection matrix
  75864. * @param left defines the viewport left coordinate
  75865. * @param right defines the viewport right coordinate
  75866. * @param bottom defines the viewport bottom coordinate
  75867. * @param top defines the viewport top coordinate
  75868. * @param znear defines the near clip plane
  75869. * @param zfar defines the far clip plane
  75870. * @returns a new matrix as a right-handed orthographic projection matrix
  75871. */
  75872. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75873. /**
  75874. * Stores a right-handed orthographic projection into a given matrix
  75875. * @param left defines the viewport left coordinate
  75876. * @param right defines the viewport right coordinate
  75877. * @param bottom defines the viewport bottom coordinate
  75878. * @param top defines the viewport top coordinate
  75879. * @param znear defines the near clip plane
  75880. * @param zfar defines the far clip plane
  75881. * @param result defines the target matrix
  75882. */
  75883. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75884. /**
  75885. * Creates a left-handed perspective projection matrix
  75886. * @param width defines the viewport width
  75887. * @param height defines the viewport height
  75888. * @param znear defines the near clip plane
  75889. * @param zfar defines the far clip plane
  75890. * @returns a new matrix as a left-handed perspective projection matrix
  75891. */
  75892. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75893. /**
  75894. * Creates a left-handed perspective projection matrix
  75895. * @param fov defines the horizontal field of view
  75896. * @param aspect defines the aspect ratio
  75897. * @param znear defines the near clip plane
  75898. * @param zfar defines the far clip plane
  75899. * @returns a new matrix as a left-handed perspective projection matrix
  75900. */
  75901. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75902. /**
  75903. * Stores a left-handed perspective projection into a given matrix
  75904. * @param fov defines the horizontal field of view
  75905. * @param aspect defines the aspect ratio
  75906. * @param znear defines the near clip plane
  75907. * @param zfar defines the far clip plane
  75908. * @param result defines the target matrix
  75909. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75910. */
  75911. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75912. /**
  75913. * Stores a left-handed perspective projection into a given matrix with depth reversed
  75914. * @param fov defines the horizontal field of view
  75915. * @param aspect defines the aspect ratio
  75916. * @param znear defines the near clip plane
  75917. * @param zfar not used as infinity is used as far clip
  75918. * @param result defines the target matrix
  75919. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75920. */
  75921. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75922. /**
  75923. * Creates a right-handed perspective projection matrix
  75924. * @param fov defines the horizontal field of view
  75925. * @param aspect defines the aspect ratio
  75926. * @param znear defines the near clip plane
  75927. * @param zfar defines the far clip plane
  75928. * @returns a new matrix as a right-handed perspective projection matrix
  75929. */
  75930. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75931. /**
  75932. * Stores a right-handed perspective projection into a given matrix
  75933. * @param fov defines the horizontal field of view
  75934. * @param aspect defines the aspect ratio
  75935. * @param znear defines the near clip plane
  75936. * @param zfar defines the far clip plane
  75937. * @param result defines the target matrix
  75938. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75939. */
  75940. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75941. /**
  75942. * Stores a right-handed perspective projection into a given matrix
  75943. * @param fov defines the horizontal field of view
  75944. * @param aspect defines the aspect ratio
  75945. * @param znear defines the near clip plane
  75946. * @param zfar not used as infinity is used as far clip
  75947. * @param result defines the target matrix
  75948. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75949. */
  75950. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75951. /**
  75952. * Stores a perspective projection for WebVR info a given matrix
  75953. * @param fov defines the field of view
  75954. * @param znear defines the near clip plane
  75955. * @param zfar defines the far clip plane
  75956. * @param result defines the target matrix
  75957. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75958. */
  75959. static PerspectiveFovWebVRToRef(fov: {
  75960. upDegrees: number;
  75961. downDegrees: number;
  75962. leftDegrees: number;
  75963. rightDegrees: number;
  75964. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  75965. /**
  75966. * Computes a complete transformation matrix
  75967. * @param viewport defines the viewport to use
  75968. * @param world defines the world matrix
  75969. * @param view defines the view matrix
  75970. * @param projection defines the projection matrix
  75971. * @param zmin defines the near clip plane
  75972. * @param zmax defines the far clip plane
  75973. * @returns the transformation matrix
  75974. */
  75975. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  75976. /**
  75977. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75978. * @param matrix defines the matrix to use
  75979. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75980. */
  75981. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  75982. /**
  75983. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75984. * @param matrix defines the matrix to use
  75985. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75986. */
  75987. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  75988. /**
  75989. * Compute the transpose of a given matrix
  75990. * @param matrix defines the matrix to transpose
  75991. * @returns the new matrix
  75992. */
  75993. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  75994. /**
  75995. * Compute the transpose of a matrix and store it in a target matrix
  75996. * @param matrix defines the matrix to transpose
  75997. * @param result defines the target matrix
  75998. */
  75999. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  76000. /**
  76001. * Computes a reflection matrix from a plane
  76002. * @param plane defines the reflection plane
  76003. * @returns a new matrix
  76004. */
  76005. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  76006. /**
  76007. * Computes a reflection matrix from a plane
  76008. * @param plane defines the reflection plane
  76009. * @param result defines the target matrix
  76010. */
  76011. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  76012. /**
  76013. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  76014. * @param xaxis defines the value of the 1st axis
  76015. * @param yaxis defines the value of the 2nd axis
  76016. * @param zaxis defines the value of the 3rd axis
  76017. * @param result defines the target matrix
  76018. */
  76019. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  76020. /**
  76021. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  76022. * @param quat defines the quaternion to use
  76023. * @param result defines the target matrix
  76024. */
  76025. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  76026. }
  76027. /**
  76028. * @hidden
  76029. */
  76030. export class TmpVectors {
  76031. static Vector2: Vector2[];
  76032. static Vector3: Vector3[];
  76033. static Vector4: Vector4[];
  76034. static Quaternion: Quaternion[];
  76035. static Matrix: Matrix[];
  76036. }
  76037. }
  76038. declare module BABYLON {
  76039. /**
  76040. * Defines potential orientation for back face culling
  76041. */
  76042. export enum Orientation {
  76043. /**
  76044. * Clockwise
  76045. */
  76046. CW = 0,
  76047. /** Counter clockwise */
  76048. CCW = 1
  76049. }
  76050. /** Class used to represent a Bezier curve */
  76051. export class BezierCurve {
  76052. /**
  76053. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  76054. * @param t defines the time
  76055. * @param x1 defines the left coordinate on X axis
  76056. * @param y1 defines the left coordinate on Y axis
  76057. * @param x2 defines the right coordinate on X axis
  76058. * @param y2 defines the right coordinate on Y axis
  76059. * @returns the interpolated value
  76060. */
  76061. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  76062. }
  76063. /**
  76064. * Defines angle representation
  76065. */
  76066. export class Angle {
  76067. private _radians;
  76068. /**
  76069. * Creates an Angle object of "radians" radians (float).
  76070. * @param radians the angle in radians
  76071. */
  76072. constructor(radians: number);
  76073. /**
  76074. * Get value in degrees
  76075. * @returns the Angle value in degrees (float)
  76076. */
  76077. degrees(): number;
  76078. /**
  76079. * Get value in radians
  76080. * @returns the Angle value in radians (float)
  76081. */
  76082. radians(): number;
  76083. /**
  76084. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  76085. * @param a defines first vector
  76086. * @param b defines second vector
  76087. * @returns a new Angle
  76088. */
  76089. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  76090. /**
  76091. * Gets a new Angle object from the given float in radians
  76092. * @param radians defines the angle value in radians
  76093. * @returns a new Angle
  76094. */
  76095. static FromRadians(radians: number): Angle;
  76096. /**
  76097. * Gets a new Angle object from the given float in degrees
  76098. * @param degrees defines the angle value in degrees
  76099. * @returns a new Angle
  76100. */
  76101. static FromDegrees(degrees: number): Angle;
  76102. }
  76103. /**
  76104. * This represents an arc in a 2d space.
  76105. */
  76106. export class Arc2 {
  76107. /** Defines the start point of the arc */
  76108. startPoint: Vector2;
  76109. /** Defines the mid point of the arc */
  76110. midPoint: Vector2;
  76111. /** Defines the end point of the arc */
  76112. endPoint: Vector2;
  76113. /**
  76114. * Defines the center point of the arc.
  76115. */
  76116. centerPoint: Vector2;
  76117. /**
  76118. * Defines the radius of the arc.
  76119. */
  76120. radius: number;
  76121. /**
  76122. * Defines the angle of the arc (from mid point to end point).
  76123. */
  76124. angle: Angle;
  76125. /**
  76126. * Defines the start angle of the arc (from start point to middle point).
  76127. */
  76128. startAngle: Angle;
  76129. /**
  76130. * Defines the orientation of the arc (clock wise/counter clock wise).
  76131. */
  76132. orientation: Orientation;
  76133. /**
  76134. * Creates an Arc object from the three given points : start, middle and end.
  76135. * @param startPoint Defines the start point of the arc
  76136. * @param midPoint Defines the midlle point of the arc
  76137. * @param endPoint Defines the end point of the arc
  76138. */
  76139. constructor(
  76140. /** Defines the start point of the arc */
  76141. startPoint: Vector2,
  76142. /** Defines the mid point of the arc */
  76143. midPoint: Vector2,
  76144. /** Defines the end point of the arc */
  76145. endPoint: Vector2);
  76146. }
  76147. /**
  76148. * Represents a 2D path made up of multiple 2D points
  76149. */
  76150. export class Path2 {
  76151. private _points;
  76152. private _length;
  76153. /**
  76154. * If the path start and end point are the same
  76155. */
  76156. closed: boolean;
  76157. /**
  76158. * Creates a Path2 object from the starting 2D coordinates x and y.
  76159. * @param x the starting points x value
  76160. * @param y the starting points y value
  76161. */
  76162. constructor(x: number, y: number);
  76163. /**
  76164. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  76165. * @param x the added points x value
  76166. * @param y the added points y value
  76167. * @returns the updated Path2.
  76168. */
  76169. addLineTo(x: number, y: number): Path2;
  76170. /**
  76171. * 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.
  76172. * @param midX middle point x value
  76173. * @param midY middle point y value
  76174. * @param endX end point x value
  76175. * @param endY end point y value
  76176. * @param numberOfSegments (default: 36)
  76177. * @returns the updated Path2.
  76178. */
  76179. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  76180. /**
  76181. * Closes the Path2.
  76182. * @returns the Path2.
  76183. */
  76184. close(): Path2;
  76185. /**
  76186. * Gets the sum of the distance between each sequential point in the path
  76187. * @returns the Path2 total length (float).
  76188. */
  76189. length(): number;
  76190. /**
  76191. * Gets the points which construct the path
  76192. * @returns the Path2 internal array of points.
  76193. */
  76194. getPoints(): Vector2[];
  76195. /**
  76196. * Retreives the point at the distance aways from the starting point
  76197. * @param normalizedLengthPosition the length along the path to retreive the point from
  76198. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  76199. */
  76200. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  76201. /**
  76202. * Creates a new path starting from an x and y position
  76203. * @param x starting x value
  76204. * @param y starting y value
  76205. * @returns a new Path2 starting at the coordinates (x, y).
  76206. */
  76207. static StartingAt(x: number, y: number): Path2;
  76208. }
  76209. /**
  76210. * Represents a 3D path made up of multiple 3D points
  76211. */
  76212. export class Path3D {
  76213. /**
  76214. * an array of Vector3, the curve axis of the Path3D
  76215. */
  76216. path: Vector3[];
  76217. private _curve;
  76218. private _distances;
  76219. private _tangents;
  76220. private _normals;
  76221. private _binormals;
  76222. private _raw;
  76223. private _alignTangentsWithPath;
  76224. private readonly _pointAtData;
  76225. /**
  76226. * new Path3D(path, normal, raw)
  76227. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  76228. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  76229. * @param path an array of Vector3, the curve axis of the Path3D
  76230. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  76231. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  76232. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  76233. */
  76234. constructor(
  76235. /**
  76236. * an array of Vector3, the curve axis of the Path3D
  76237. */
  76238. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  76239. /**
  76240. * Returns the Path3D array of successive Vector3 designing its curve.
  76241. * @returns the Path3D array of successive Vector3 designing its curve.
  76242. */
  76243. getCurve(): Vector3[];
  76244. /**
  76245. * Returns the Path3D array of successive Vector3 designing its curve.
  76246. * @returns the Path3D array of successive Vector3 designing its curve.
  76247. */
  76248. getPoints(): Vector3[];
  76249. /**
  76250. * @returns the computed length (float) of the path.
  76251. */
  76252. length(): number;
  76253. /**
  76254. * Returns an array populated with tangent vectors on each Path3D curve point.
  76255. * @returns an array populated with tangent vectors on each Path3D curve point.
  76256. */
  76257. getTangents(): Vector3[];
  76258. /**
  76259. * Returns an array populated with normal vectors on each Path3D curve point.
  76260. * @returns an array populated with normal vectors on each Path3D curve point.
  76261. */
  76262. getNormals(): Vector3[];
  76263. /**
  76264. * Returns an array populated with binormal vectors on each Path3D curve point.
  76265. * @returns an array populated with binormal vectors on each Path3D curve point.
  76266. */
  76267. getBinormals(): Vector3[];
  76268. /**
  76269. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  76270. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  76271. */
  76272. getDistances(): number[];
  76273. /**
  76274. * Returns an interpolated point along this path
  76275. * @param position the position of the point along this path, from 0.0 to 1.0
  76276. * @returns a new Vector3 as the point
  76277. */
  76278. getPointAt(position: number): Vector3;
  76279. /**
  76280. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  76281. * @param position the position of the point along this path, from 0.0 to 1.0
  76282. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  76283. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  76284. */
  76285. getTangentAt(position: number, interpolated?: boolean): Vector3;
  76286. /**
  76287. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  76288. * @param position the position of the point along this path, from 0.0 to 1.0
  76289. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  76290. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  76291. */
  76292. getNormalAt(position: number, interpolated?: boolean): Vector3;
  76293. /**
  76294. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  76295. * @param position the position of the point along this path, from 0.0 to 1.0
  76296. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  76297. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  76298. */
  76299. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  76300. /**
  76301. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  76302. * @param position the position of the point along this path, from 0.0 to 1.0
  76303. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  76304. */
  76305. getDistanceAt(position: number): number;
  76306. /**
  76307. * Returns the array index of the previous point of an interpolated point along this path
  76308. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  76309. * @returns the array index
  76310. */
  76311. getPreviousPointIndexAt(position: number): number;
  76312. /**
  76313. * 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)
  76314. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  76315. * @returns the sub position
  76316. */
  76317. getSubPositionAt(position: number): number;
  76318. /**
  76319. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  76320. * @param target the vector of which to get the closest position to
  76321. * @returns the position of the closest virtual point on this path to the target vector
  76322. */
  76323. getClosestPositionTo(target: Vector3): number;
  76324. /**
  76325. * Returns a sub path (slice) of this path
  76326. * @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
  76327. * @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
  76328. * @returns a sub path (slice) of this path
  76329. */
  76330. slice(start?: number, end?: number): Path3D;
  76331. /**
  76332. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  76333. * @param path path which all values are copied into the curves points
  76334. * @param firstNormal which should be projected onto the curve
  76335. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  76336. * @returns the same object updated.
  76337. */
  76338. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  76339. private _compute;
  76340. private _getFirstNonNullVector;
  76341. private _getLastNonNullVector;
  76342. private _normalVector;
  76343. /**
  76344. * Updates the point at data for an interpolated point along this curve
  76345. * @param position the position of the point along this curve, from 0.0 to 1.0
  76346. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  76347. * @returns the (updated) point at data
  76348. */
  76349. private _updatePointAtData;
  76350. /**
  76351. * Updates the point at data from the specified parameters
  76352. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  76353. * @param point the interpolated point
  76354. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  76355. */
  76356. private _setPointAtData;
  76357. /**
  76358. * Updates the point at interpolation matrix for the tangents, normals and binormals
  76359. */
  76360. private _updateInterpolationMatrix;
  76361. }
  76362. /**
  76363. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  76364. * A Curve3 is designed from a series of successive Vector3.
  76365. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  76366. */
  76367. export class Curve3 {
  76368. private _points;
  76369. private _length;
  76370. /**
  76371. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  76372. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  76373. * @param v1 (Vector3) the control point
  76374. * @param v2 (Vector3) the end point of the Quadratic Bezier
  76375. * @param nbPoints (integer) the wanted number of points in the curve
  76376. * @returns the created Curve3
  76377. */
  76378. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  76379. /**
  76380. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  76381. * @param v0 (Vector3) the origin point of the Cubic Bezier
  76382. * @param v1 (Vector3) the first control point
  76383. * @param v2 (Vector3) the second control point
  76384. * @param v3 (Vector3) the end point of the Cubic Bezier
  76385. * @param nbPoints (integer) the wanted number of points in the curve
  76386. * @returns the created Curve3
  76387. */
  76388. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  76389. /**
  76390. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  76391. * @param p1 (Vector3) the origin point of the Hermite Spline
  76392. * @param t1 (Vector3) the tangent vector at the origin point
  76393. * @param p2 (Vector3) the end point of the Hermite Spline
  76394. * @param t2 (Vector3) the tangent vector at the end point
  76395. * @param nbPoints (integer) the wanted number of points in the curve
  76396. * @returns the created Curve3
  76397. */
  76398. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  76399. /**
  76400. * Returns a Curve3 object along a CatmullRom Spline curve :
  76401. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  76402. * @param nbPoints (integer) the wanted number of points between each curve control points
  76403. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  76404. * @returns the created Curve3
  76405. */
  76406. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  76407. /**
  76408. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  76409. * A Curve3 is designed from a series of successive Vector3.
  76410. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  76411. * @param points points which make up the curve
  76412. */
  76413. constructor(points: Vector3[]);
  76414. /**
  76415. * @returns the Curve3 stored array of successive Vector3
  76416. */
  76417. getPoints(): Vector3[];
  76418. /**
  76419. * @returns the computed length (float) of the curve.
  76420. */
  76421. length(): number;
  76422. /**
  76423. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  76424. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  76425. * curveA and curveB keep unchanged.
  76426. * @param curve the curve to continue from this curve
  76427. * @returns the newly constructed curve
  76428. */
  76429. continue(curve: DeepImmutable<Curve3>): Curve3;
  76430. private _computeLength;
  76431. }
  76432. }
  76433. declare module BABYLON {
  76434. /**
  76435. * This represents the main contract an easing function should follow.
  76436. * Easing functions are used throughout the animation system.
  76437. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76438. */
  76439. export interface IEasingFunction {
  76440. /**
  76441. * Given an input gradient between 0 and 1, this returns the corrseponding value
  76442. * of the easing function.
  76443. * The link below provides some of the most common examples of easing functions.
  76444. * @see https://easings.net/
  76445. * @param gradient Defines the value between 0 and 1 we want the easing value for
  76446. * @returns the corresponding value on the curve defined by the easing function
  76447. */
  76448. ease(gradient: number): number;
  76449. }
  76450. /**
  76451. * Base class used for every default easing function.
  76452. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76453. */
  76454. export class EasingFunction implements IEasingFunction {
  76455. /**
  76456. * Interpolation follows the mathematical formula associated with the easing function.
  76457. */
  76458. static readonly EASINGMODE_EASEIN: number;
  76459. /**
  76460. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  76461. */
  76462. static readonly EASINGMODE_EASEOUT: number;
  76463. /**
  76464. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  76465. */
  76466. static readonly EASINGMODE_EASEINOUT: number;
  76467. private _easingMode;
  76468. /**
  76469. * Sets the easing mode of the current function.
  76470. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  76471. */
  76472. setEasingMode(easingMode: number): void;
  76473. /**
  76474. * Gets the current easing mode.
  76475. * @returns the easing mode
  76476. */
  76477. getEasingMode(): number;
  76478. /**
  76479. * @hidden
  76480. */
  76481. easeInCore(gradient: number): number;
  76482. /**
  76483. * Given an input gradient between 0 and 1, this returns the corresponding value
  76484. * of the easing function.
  76485. * @param gradient Defines the value between 0 and 1 we want the easing value for
  76486. * @returns the corresponding value on the curve defined by the easing function
  76487. */
  76488. ease(gradient: number): number;
  76489. }
  76490. /**
  76491. * Easing function with a circle shape (see link below).
  76492. * @see https://easings.net/#easeInCirc
  76493. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76494. */
  76495. export class CircleEase extends EasingFunction implements IEasingFunction {
  76496. /** @hidden */
  76497. easeInCore(gradient: number): number;
  76498. }
  76499. /**
  76500. * Easing function with a ease back shape (see link below).
  76501. * @see https://easings.net/#easeInBack
  76502. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76503. */
  76504. export class BackEase extends EasingFunction implements IEasingFunction {
  76505. /** Defines the amplitude of the function */
  76506. amplitude: number;
  76507. /**
  76508. * Instantiates a back ease easing
  76509. * @see https://easings.net/#easeInBack
  76510. * @param amplitude Defines the amplitude of the function
  76511. */
  76512. constructor(
  76513. /** Defines the amplitude of the function */
  76514. amplitude?: number);
  76515. /** @hidden */
  76516. easeInCore(gradient: number): number;
  76517. }
  76518. /**
  76519. * Easing function with a bouncing shape (see link below).
  76520. * @see https://easings.net/#easeInBounce
  76521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76522. */
  76523. export class BounceEase extends EasingFunction implements IEasingFunction {
  76524. /** Defines the number of bounces */
  76525. bounces: number;
  76526. /** Defines the amplitude of the bounce */
  76527. bounciness: number;
  76528. /**
  76529. * Instantiates a bounce easing
  76530. * @see https://easings.net/#easeInBounce
  76531. * @param bounces Defines the number of bounces
  76532. * @param bounciness Defines the amplitude of the bounce
  76533. */
  76534. constructor(
  76535. /** Defines the number of bounces */
  76536. bounces?: number,
  76537. /** Defines the amplitude of the bounce */
  76538. bounciness?: number);
  76539. /** @hidden */
  76540. easeInCore(gradient: number): number;
  76541. }
  76542. /**
  76543. * Easing function with a power of 3 shape (see link below).
  76544. * @see https://easings.net/#easeInCubic
  76545. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76546. */
  76547. export class CubicEase extends EasingFunction implements IEasingFunction {
  76548. /** @hidden */
  76549. easeInCore(gradient: number): number;
  76550. }
  76551. /**
  76552. * Easing function with an elastic shape (see link below).
  76553. * @see https://easings.net/#easeInElastic
  76554. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76555. */
  76556. export class ElasticEase extends EasingFunction implements IEasingFunction {
  76557. /** Defines the number of oscillations*/
  76558. oscillations: number;
  76559. /** Defines the amplitude of the oscillations*/
  76560. springiness: number;
  76561. /**
  76562. * Instantiates an elastic easing function
  76563. * @see https://easings.net/#easeInElastic
  76564. * @param oscillations Defines the number of oscillations
  76565. * @param springiness Defines the amplitude of the oscillations
  76566. */
  76567. constructor(
  76568. /** Defines the number of oscillations*/
  76569. oscillations?: number,
  76570. /** Defines the amplitude of the oscillations*/
  76571. springiness?: number);
  76572. /** @hidden */
  76573. easeInCore(gradient: number): number;
  76574. }
  76575. /**
  76576. * Easing function with an exponential shape (see link below).
  76577. * @see https://easings.net/#easeInExpo
  76578. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76579. */
  76580. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  76581. /** Defines the exponent of the function */
  76582. exponent: number;
  76583. /**
  76584. * Instantiates an exponential easing function
  76585. * @see https://easings.net/#easeInExpo
  76586. * @param exponent Defines the exponent of the function
  76587. */
  76588. constructor(
  76589. /** Defines the exponent of the function */
  76590. exponent?: number);
  76591. /** @hidden */
  76592. easeInCore(gradient: number): number;
  76593. }
  76594. /**
  76595. * Easing function with a power shape (see link below).
  76596. * @see https://easings.net/#easeInQuad
  76597. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76598. */
  76599. export class PowerEase extends EasingFunction implements IEasingFunction {
  76600. /** Defines the power of the function */
  76601. power: number;
  76602. /**
  76603. * Instantiates an power base easing function
  76604. * @see https://easings.net/#easeInQuad
  76605. * @param power Defines the power of the function
  76606. */
  76607. constructor(
  76608. /** Defines the power of the function */
  76609. power?: number);
  76610. /** @hidden */
  76611. easeInCore(gradient: number): number;
  76612. }
  76613. /**
  76614. * Easing function with a power of 2 shape (see link below).
  76615. * @see https://easings.net/#easeInQuad
  76616. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76617. */
  76618. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  76619. /** @hidden */
  76620. easeInCore(gradient: number): number;
  76621. }
  76622. /**
  76623. * Easing function with a power of 4 shape (see link below).
  76624. * @see https://easings.net/#easeInQuart
  76625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76626. */
  76627. export class QuarticEase extends EasingFunction implements IEasingFunction {
  76628. /** @hidden */
  76629. easeInCore(gradient: number): number;
  76630. }
  76631. /**
  76632. * Easing function with a power of 5 shape (see link below).
  76633. * @see https://easings.net/#easeInQuint
  76634. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76635. */
  76636. export class QuinticEase extends EasingFunction implements IEasingFunction {
  76637. /** @hidden */
  76638. easeInCore(gradient: number): number;
  76639. }
  76640. /**
  76641. * Easing function with a sin shape (see link below).
  76642. * @see https://easings.net/#easeInSine
  76643. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76644. */
  76645. export class SineEase extends EasingFunction implements IEasingFunction {
  76646. /** @hidden */
  76647. easeInCore(gradient: number): number;
  76648. }
  76649. /**
  76650. * Easing function with a bezier shape (see link below).
  76651. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  76652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76653. */
  76654. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  76655. /** Defines the x component of the start tangent in the bezier curve */
  76656. x1: number;
  76657. /** Defines the y component of the start tangent in the bezier curve */
  76658. y1: number;
  76659. /** Defines the x component of the end tangent in the bezier curve */
  76660. x2: number;
  76661. /** Defines the y component of the end tangent in the bezier curve */
  76662. y2: number;
  76663. /**
  76664. * Instantiates a bezier function
  76665. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  76666. * @param x1 Defines the x component of the start tangent in the bezier curve
  76667. * @param y1 Defines the y component of the start tangent in the bezier curve
  76668. * @param x2 Defines the x component of the end tangent in the bezier curve
  76669. * @param y2 Defines the y component of the end tangent in the bezier curve
  76670. */
  76671. constructor(
  76672. /** Defines the x component of the start tangent in the bezier curve */
  76673. x1?: number,
  76674. /** Defines the y component of the start tangent in the bezier curve */
  76675. y1?: number,
  76676. /** Defines the x component of the end tangent in the bezier curve */
  76677. x2?: number,
  76678. /** Defines the y component of the end tangent in the bezier curve */
  76679. y2?: number);
  76680. /** @hidden */
  76681. easeInCore(gradient: number): number;
  76682. }
  76683. }
  76684. declare module BABYLON {
  76685. /**
  76686. * Class used to hold a RBG color
  76687. */
  76688. export class Color3 {
  76689. /**
  76690. * Defines the red component (between 0 and 1, default is 0)
  76691. */
  76692. r: number;
  76693. /**
  76694. * Defines the green component (between 0 and 1, default is 0)
  76695. */
  76696. g: number;
  76697. /**
  76698. * Defines the blue component (between 0 and 1, default is 0)
  76699. */
  76700. b: number;
  76701. /**
  76702. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  76703. * @param r defines the red component (between 0 and 1, default is 0)
  76704. * @param g defines the green component (between 0 and 1, default is 0)
  76705. * @param b defines the blue component (between 0 and 1, default is 0)
  76706. */
  76707. constructor(
  76708. /**
  76709. * Defines the red component (between 0 and 1, default is 0)
  76710. */
  76711. r?: number,
  76712. /**
  76713. * Defines the green component (between 0 and 1, default is 0)
  76714. */
  76715. g?: number,
  76716. /**
  76717. * Defines the blue component (between 0 and 1, default is 0)
  76718. */
  76719. b?: number);
  76720. /**
  76721. * Creates a string with the Color3 current values
  76722. * @returns the string representation of the Color3 object
  76723. */
  76724. toString(): string;
  76725. /**
  76726. * Returns the string "Color3"
  76727. * @returns "Color3"
  76728. */
  76729. getClassName(): string;
  76730. /**
  76731. * Compute the Color3 hash code
  76732. * @returns an unique number that can be used to hash Color3 objects
  76733. */
  76734. getHashCode(): number;
  76735. /**
  76736. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  76737. * @param array defines the array where to store the r,g,b components
  76738. * @param index defines an optional index in the target array to define where to start storing values
  76739. * @returns the current Color3 object
  76740. */
  76741. toArray(array: FloatArray, index?: number): Color3;
  76742. /**
  76743. * Returns a new Color4 object from the current Color3 and the given alpha
  76744. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  76745. * @returns a new Color4 object
  76746. */
  76747. toColor4(alpha?: number): Color4;
  76748. /**
  76749. * Returns a new array populated with 3 numeric elements : red, green and blue values
  76750. * @returns the new array
  76751. */
  76752. asArray(): number[];
  76753. /**
  76754. * Returns the luminance value
  76755. * @returns a float value
  76756. */
  76757. toLuminance(): number;
  76758. /**
  76759. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  76760. * @param otherColor defines the second operand
  76761. * @returns the new Color3 object
  76762. */
  76763. multiply(otherColor: DeepImmutable<Color3>): Color3;
  76764. /**
  76765. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  76766. * @param otherColor defines the second operand
  76767. * @param result defines the Color3 object where to store the result
  76768. * @returns the current Color3
  76769. */
  76770. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76771. /**
  76772. * Determines equality between Color3 objects
  76773. * @param otherColor defines the second operand
  76774. * @returns true if the rgb values are equal to the given ones
  76775. */
  76776. equals(otherColor: DeepImmutable<Color3>): boolean;
  76777. /**
  76778. * Determines equality between the current Color3 object and a set of r,b,g values
  76779. * @param r defines the red component to check
  76780. * @param g defines the green component to check
  76781. * @param b defines the blue component to check
  76782. * @returns true if the rgb values are equal to the given ones
  76783. */
  76784. equalsFloats(r: number, g: number, b: number): boolean;
  76785. /**
  76786. * Multiplies in place each rgb value by scale
  76787. * @param scale defines the scaling factor
  76788. * @returns the updated Color3
  76789. */
  76790. scale(scale: number): Color3;
  76791. /**
  76792. * Multiplies the rgb values by scale and stores the result into "result"
  76793. * @param scale defines the scaling factor
  76794. * @param result defines the Color3 object where to store the result
  76795. * @returns the unmodified current Color3
  76796. */
  76797. scaleToRef(scale: number, result: Color3): Color3;
  76798. /**
  76799. * Scale the current Color3 values by a factor and add the result to a given Color3
  76800. * @param scale defines the scale factor
  76801. * @param result defines color to store the result into
  76802. * @returns the unmodified current Color3
  76803. */
  76804. scaleAndAddToRef(scale: number, result: Color3): Color3;
  76805. /**
  76806. * Clamps the rgb values by the min and max values and stores the result into "result"
  76807. * @param min defines minimum clamping value (default is 0)
  76808. * @param max defines maximum clamping value (default is 1)
  76809. * @param result defines color to store the result into
  76810. * @returns the original Color3
  76811. */
  76812. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  76813. /**
  76814. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  76815. * @param otherColor defines the second operand
  76816. * @returns the new Color3
  76817. */
  76818. add(otherColor: DeepImmutable<Color3>): Color3;
  76819. /**
  76820. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  76821. * @param otherColor defines the second operand
  76822. * @param result defines Color3 object to store the result into
  76823. * @returns the unmodified current Color3
  76824. */
  76825. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76826. /**
  76827. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  76828. * @param otherColor defines the second operand
  76829. * @returns the new Color3
  76830. */
  76831. subtract(otherColor: DeepImmutable<Color3>): Color3;
  76832. /**
  76833. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  76834. * @param otherColor defines the second operand
  76835. * @param result defines Color3 object to store the result into
  76836. * @returns the unmodified current Color3
  76837. */
  76838. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76839. /**
  76840. * Copy the current object
  76841. * @returns a new Color3 copied the current one
  76842. */
  76843. clone(): Color3;
  76844. /**
  76845. * Copies the rgb values from the source in the current Color3
  76846. * @param source defines the source Color3 object
  76847. * @returns the updated Color3 object
  76848. */
  76849. copyFrom(source: DeepImmutable<Color3>): Color3;
  76850. /**
  76851. * Updates the Color3 rgb values from the given floats
  76852. * @param r defines the red component to read from
  76853. * @param g defines the green component to read from
  76854. * @param b defines the blue component to read from
  76855. * @returns the current Color3 object
  76856. */
  76857. copyFromFloats(r: number, g: number, b: number): Color3;
  76858. /**
  76859. * Updates the Color3 rgb values from the given floats
  76860. * @param r defines the red component to read from
  76861. * @param g defines the green component to read from
  76862. * @param b defines the blue component to read from
  76863. * @returns the current Color3 object
  76864. */
  76865. set(r: number, g: number, b: number): Color3;
  76866. /**
  76867. * Compute the Color3 hexadecimal code as a string
  76868. * @returns a string containing the hexadecimal representation of the Color3 object
  76869. */
  76870. toHexString(): string;
  76871. /**
  76872. * Computes a new Color3 converted from the current one to linear space
  76873. * @returns a new Color3 object
  76874. */
  76875. toLinearSpace(): Color3;
  76876. /**
  76877. * Converts current color in rgb space to HSV values
  76878. * @returns a new color3 representing the HSV values
  76879. */
  76880. toHSV(): Color3;
  76881. /**
  76882. * Converts current color in rgb space to HSV values
  76883. * @param result defines the Color3 where to store the HSV values
  76884. */
  76885. toHSVToRef(result: Color3): void;
  76886. /**
  76887. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  76888. * @param convertedColor defines the Color3 object where to store the linear space version
  76889. * @returns the unmodified Color3
  76890. */
  76891. toLinearSpaceToRef(convertedColor: Color3): Color3;
  76892. /**
  76893. * Computes a new Color3 converted from the current one to gamma space
  76894. * @returns a new Color3 object
  76895. */
  76896. toGammaSpace(): Color3;
  76897. /**
  76898. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  76899. * @param convertedColor defines the Color3 object where to store the gamma space version
  76900. * @returns the unmodified Color3
  76901. */
  76902. toGammaSpaceToRef(convertedColor: Color3): Color3;
  76903. private static _BlackReadOnly;
  76904. /**
  76905. * Convert Hue, saturation and value to a Color3 (RGB)
  76906. * @param hue defines the hue
  76907. * @param saturation defines the saturation
  76908. * @param value defines the value
  76909. * @param result defines the Color3 where to store the RGB values
  76910. */
  76911. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  76912. /**
  76913. * Creates a new Color3 from the string containing valid hexadecimal values
  76914. * @param hex defines a string containing valid hexadecimal values
  76915. * @returns a new Color3 object
  76916. */
  76917. static FromHexString(hex: string): Color3;
  76918. /**
  76919. * Creates a new Color3 from the starting index of the given array
  76920. * @param array defines the source array
  76921. * @param offset defines an offset in the source array
  76922. * @returns a new Color3 object
  76923. */
  76924. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  76925. /**
  76926. * Creates a new Color3 from integer values (< 256)
  76927. * @param r defines the red component to read from (value between 0 and 255)
  76928. * @param g defines the green component to read from (value between 0 and 255)
  76929. * @param b defines the blue component to read from (value between 0 and 255)
  76930. * @returns a new Color3 object
  76931. */
  76932. static FromInts(r: number, g: number, b: number): Color3;
  76933. /**
  76934. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76935. * @param start defines the start Color3 value
  76936. * @param end defines the end Color3 value
  76937. * @param amount defines the gradient value between start and end
  76938. * @returns a new Color3 object
  76939. */
  76940. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  76941. /**
  76942. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76943. * @param left defines the start value
  76944. * @param right defines the end value
  76945. * @param amount defines the gradient factor
  76946. * @param result defines the Color3 object where to store the result
  76947. */
  76948. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  76949. /**
  76950. * Returns a Color3 value containing a red color
  76951. * @returns a new Color3 object
  76952. */
  76953. static Red(): Color3;
  76954. /**
  76955. * Returns a Color3 value containing a green color
  76956. * @returns a new Color3 object
  76957. */
  76958. static Green(): Color3;
  76959. /**
  76960. * Returns a Color3 value containing a blue color
  76961. * @returns a new Color3 object
  76962. */
  76963. static Blue(): Color3;
  76964. /**
  76965. * Returns a Color3 value containing a black color
  76966. * @returns a new Color3 object
  76967. */
  76968. static Black(): Color3;
  76969. /**
  76970. * Gets a Color3 value containing a black color that must not be updated
  76971. */
  76972. static get BlackReadOnly(): DeepImmutable<Color3>;
  76973. /**
  76974. * Returns a Color3 value containing a white color
  76975. * @returns a new Color3 object
  76976. */
  76977. static White(): Color3;
  76978. /**
  76979. * Returns a Color3 value containing a purple color
  76980. * @returns a new Color3 object
  76981. */
  76982. static Purple(): Color3;
  76983. /**
  76984. * Returns a Color3 value containing a magenta color
  76985. * @returns a new Color3 object
  76986. */
  76987. static Magenta(): Color3;
  76988. /**
  76989. * Returns a Color3 value containing a yellow color
  76990. * @returns a new Color3 object
  76991. */
  76992. static Yellow(): Color3;
  76993. /**
  76994. * Returns a Color3 value containing a gray color
  76995. * @returns a new Color3 object
  76996. */
  76997. static Gray(): Color3;
  76998. /**
  76999. * Returns a Color3 value containing a teal color
  77000. * @returns a new Color3 object
  77001. */
  77002. static Teal(): Color3;
  77003. /**
  77004. * Returns a Color3 value containing a random color
  77005. * @returns a new Color3 object
  77006. */
  77007. static Random(): Color3;
  77008. }
  77009. /**
  77010. * Class used to hold a RBGA color
  77011. */
  77012. export class Color4 {
  77013. /**
  77014. * Defines the red component (between 0 and 1, default is 0)
  77015. */
  77016. r: number;
  77017. /**
  77018. * Defines the green component (between 0 and 1, default is 0)
  77019. */
  77020. g: number;
  77021. /**
  77022. * Defines the blue component (between 0 and 1, default is 0)
  77023. */
  77024. b: number;
  77025. /**
  77026. * Defines the alpha component (between 0 and 1, default is 1)
  77027. */
  77028. a: number;
  77029. /**
  77030. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  77031. * @param r defines the red component (between 0 and 1, default is 0)
  77032. * @param g defines the green component (between 0 and 1, default is 0)
  77033. * @param b defines the blue component (between 0 and 1, default is 0)
  77034. * @param a defines the alpha component (between 0 and 1, default is 1)
  77035. */
  77036. constructor(
  77037. /**
  77038. * Defines the red component (between 0 and 1, default is 0)
  77039. */
  77040. r?: number,
  77041. /**
  77042. * Defines the green component (between 0 and 1, default is 0)
  77043. */
  77044. g?: number,
  77045. /**
  77046. * Defines the blue component (between 0 and 1, default is 0)
  77047. */
  77048. b?: number,
  77049. /**
  77050. * Defines the alpha component (between 0 and 1, default is 1)
  77051. */
  77052. a?: number);
  77053. /**
  77054. * Adds in place the given Color4 values to the current Color4 object
  77055. * @param right defines the second operand
  77056. * @returns the current updated Color4 object
  77057. */
  77058. addInPlace(right: DeepImmutable<Color4>): Color4;
  77059. /**
  77060. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  77061. * @returns the new array
  77062. */
  77063. asArray(): number[];
  77064. /**
  77065. * Stores from the starting index in the given array the Color4 successive values
  77066. * @param array defines the array where to store the r,g,b components
  77067. * @param index defines an optional index in the target array to define where to start storing values
  77068. * @returns the current Color4 object
  77069. */
  77070. toArray(array: number[], index?: number): Color4;
  77071. /**
  77072. * Determines equality between Color4 objects
  77073. * @param otherColor defines the second operand
  77074. * @returns true if the rgba values are equal to the given ones
  77075. */
  77076. equals(otherColor: DeepImmutable<Color4>): boolean;
  77077. /**
  77078. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  77079. * @param right defines the second operand
  77080. * @returns a new Color4 object
  77081. */
  77082. add(right: DeepImmutable<Color4>): Color4;
  77083. /**
  77084. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  77085. * @param right defines the second operand
  77086. * @returns a new Color4 object
  77087. */
  77088. subtract(right: DeepImmutable<Color4>): Color4;
  77089. /**
  77090. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  77091. * @param right defines the second operand
  77092. * @param result defines the Color4 object where to store the result
  77093. * @returns the current Color4 object
  77094. */
  77095. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  77096. /**
  77097. * Creates a new Color4 with the current Color4 values multiplied by scale
  77098. * @param scale defines the scaling factor to apply
  77099. * @returns a new Color4 object
  77100. */
  77101. scale(scale: number): Color4;
  77102. /**
  77103. * Multiplies the current Color4 values by scale and stores the result in "result"
  77104. * @param scale defines the scaling factor to apply
  77105. * @param result defines the Color4 object where to store the result
  77106. * @returns the current unmodified Color4
  77107. */
  77108. scaleToRef(scale: number, result: Color4): Color4;
  77109. /**
  77110. * Scale the current Color4 values by a factor and add the result to a given Color4
  77111. * @param scale defines the scale factor
  77112. * @param result defines the Color4 object where to store the result
  77113. * @returns the unmodified current Color4
  77114. */
  77115. scaleAndAddToRef(scale: number, result: Color4): Color4;
  77116. /**
  77117. * Clamps the rgb values by the min and max values and stores the result into "result"
  77118. * @param min defines minimum clamping value (default is 0)
  77119. * @param max defines maximum clamping value (default is 1)
  77120. * @param result defines color to store the result into.
  77121. * @returns the cuurent Color4
  77122. */
  77123. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  77124. /**
  77125. * Multipy an Color4 value by another and return a new Color4 object
  77126. * @param color defines the Color4 value to multiply by
  77127. * @returns a new Color4 object
  77128. */
  77129. multiply(color: Color4): Color4;
  77130. /**
  77131. * Multipy a Color4 value by another and push the result in a reference value
  77132. * @param color defines the Color4 value to multiply by
  77133. * @param result defines the Color4 to fill the result in
  77134. * @returns the result Color4
  77135. */
  77136. multiplyToRef(color: Color4, result: Color4): Color4;
  77137. /**
  77138. * Creates a string with the Color4 current values
  77139. * @returns the string representation of the Color4 object
  77140. */
  77141. toString(): string;
  77142. /**
  77143. * Returns the string "Color4"
  77144. * @returns "Color4"
  77145. */
  77146. getClassName(): string;
  77147. /**
  77148. * Compute the Color4 hash code
  77149. * @returns an unique number that can be used to hash Color4 objects
  77150. */
  77151. getHashCode(): number;
  77152. /**
  77153. * Creates a new Color4 copied from the current one
  77154. * @returns a new Color4 object
  77155. */
  77156. clone(): Color4;
  77157. /**
  77158. * Copies the given Color4 values into the current one
  77159. * @param source defines the source Color4 object
  77160. * @returns the current updated Color4 object
  77161. */
  77162. copyFrom(source: Color4): Color4;
  77163. /**
  77164. * Copies the given float values into the current one
  77165. * @param r defines the red component to read from
  77166. * @param g defines the green component to read from
  77167. * @param b defines the blue component to read from
  77168. * @param a defines the alpha component to read from
  77169. * @returns the current updated Color4 object
  77170. */
  77171. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  77172. /**
  77173. * Copies the given float values into the current one
  77174. * @param r defines the red component to read from
  77175. * @param g defines the green component to read from
  77176. * @param b defines the blue component to read from
  77177. * @param a defines the alpha component to read from
  77178. * @returns the current updated Color4 object
  77179. */
  77180. set(r: number, g: number, b: number, a: number): Color4;
  77181. /**
  77182. * Compute the Color4 hexadecimal code as a string
  77183. * @returns a string containing the hexadecimal representation of the Color4 object
  77184. */
  77185. toHexString(): string;
  77186. /**
  77187. * Computes a new Color4 converted from the current one to linear space
  77188. * @returns a new Color4 object
  77189. */
  77190. toLinearSpace(): Color4;
  77191. /**
  77192. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  77193. * @param convertedColor defines the Color4 object where to store the linear space version
  77194. * @returns the unmodified Color4
  77195. */
  77196. toLinearSpaceToRef(convertedColor: Color4): Color4;
  77197. /**
  77198. * Computes a new Color4 converted from the current one to gamma space
  77199. * @returns a new Color4 object
  77200. */
  77201. toGammaSpace(): Color4;
  77202. /**
  77203. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  77204. * @param convertedColor defines the Color4 object where to store the gamma space version
  77205. * @returns the unmodified Color4
  77206. */
  77207. toGammaSpaceToRef(convertedColor: Color4): Color4;
  77208. /**
  77209. * Creates a new Color4 from the string containing valid hexadecimal values
  77210. * @param hex defines a string containing valid hexadecimal values
  77211. * @returns a new Color4 object
  77212. */
  77213. static FromHexString(hex: string): Color4;
  77214. /**
  77215. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  77216. * @param left defines the start value
  77217. * @param right defines the end value
  77218. * @param amount defines the gradient factor
  77219. * @returns a new Color4 object
  77220. */
  77221. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  77222. /**
  77223. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  77224. * @param left defines the start value
  77225. * @param right defines the end value
  77226. * @param amount defines the gradient factor
  77227. * @param result defines the Color4 object where to store data
  77228. */
  77229. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  77230. /**
  77231. * Creates a new Color4 from a Color3 and an alpha value
  77232. * @param color3 defines the source Color3 to read from
  77233. * @param alpha defines the alpha component (1.0 by default)
  77234. * @returns a new Color4 object
  77235. */
  77236. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  77237. /**
  77238. * Creates a new Color4 from the starting index element of the given array
  77239. * @param array defines the source array to read from
  77240. * @param offset defines the offset in the source array
  77241. * @returns a new Color4 object
  77242. */
  77243. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  77244. /**
  77245. * Creates a new Color3 from integer values (< 256)
  77246. * @param r defines the red component to read from (value between 0 and 255)
  77247. * @param g defines the green component to read from (value between 0 and 255)
  77248. * @param b defines the blue component to read from (value between 0 and 255)
  77249. * @param a defines the alpha component to read from (value between 0 and 255)
  77250. * @returns a new Color3 object
  77251. */
  77252. static FromInts(r: number, g: number, b: number, a: number): Color4;
  77253. /**
  77254. * Check the content of a given array and convert it to an array containing RGBA data
  77255. * If the original array was already containing count * 4 values then it is returned directly
  77256. * @param colors defines the array to check
  77257. * @param count defines the number of RGBA data to expect
  77258. * @returns an array containing count * 4 values (RGBA)
  77259. */
  77260. static CheckColors4(colors: number[], count: number): number[];
  77261. }
  77262. /**
  77263. * @hidden
  77264. */
  77265. export class TmpColors {
  77266. static Color3: Color3[];
  77267. static Color4: Color4[];
  77268. }
  77269. }
  77270. declare module BABYLON {
  77271. /**
  77272. * Defines an interface which represents an animation key frame
  77273. */
  77274. export interface IAnimationKey {
  77275. /**
  77276. * Frame of the key frame
  77277. */
  77278. frame: number;
  77279. /**
  77280. * Value at the specifies key frame
  77281. */
  77282. value: any;
  77283. /**
  77284. * The input tangent for the cubic hermite spline
  77285. */
  77286. inTangent?: any;
  77287. /**
  77288. * The output tangent for the cubic hermite spline
  77289. */
  77290. outTangent?: any;
  77291. /**
  77292. * The animation interpolation type
  77293. */
  77294. interpolation?: AnimationKeyInterpolation;
  77295. }
  77296. /**
  77297. * Enum for the animation key frame interpolation type
  77298. */
  77299. export enum AnimationKeyInterpolation {
  77300. /**
  77301. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  77302. */
  77303. STEP = 1
  77304. }
  77305. }
  77306. declare module BABYLON {
  77307. /**
  77308. * Represents the range of an animation
  77309. */
  77310. export class AnimationRange {
  77311. /**The name of the animation range**/
  77312. name: string;
  77313. /**The starting frame of the animation */
  77314. from: number;
  77315. /**The ending frame of the animation*/
  77316. to: number;
  77317. /**
  77318. * Initializes the range of an animation
  77319. * @param name The name of the animation range
  77320. * @param from The starting frame of the animation
  77321. * @param to The ending frame of the animation
  77322. */
  77323. constructor(
  77324. /**The name of the animation range**/
  77325. name: string,
  77326. /**The starting frame of the animation */
  77327. from: number,
  77328. /**The ending frame of the animation*/
  77329. to: number);
  77330. /**
  77331. * Makes a copy of the animation range
  77332. * @returns A copy of the animation range
  77333. */
  77334. clone(): AnimationRange;
  77335. }
  77336. }
  77337. declare module BABYLON {
  77338. /**
  77339. * Composed of a frame, and an action function
  77340. */
  77341. export class AnimationEvent {
  77342. /** The frame for which the event is triggered **/
  77343. frame: number;
  77344. /** The event to perform when triggered **/
  77345. action: (currentFrame: number) => void;
  77346. /** Specifies if the event should be triggered only once**/
  77347. onlyOnce?: boolean | undefined;
  77348. /**
  77349. * Specifies if the animation event is done
  77350. */
  77351. isDone: boolean;
  77352. /**
  77353. * Initializes the animation event
  77354. * @param frame The frame for which the event is triggered
  77355. * @param action The event to perform when triggered
  77356. * @param onlyOnce Specifies if the event should be triggered only once
  77357. */
  77358. constructor(
  77359. /** The frame for which the event is triggered **/
  77360. frame: number,
  77361. /** The event to perform when triggered **/
  77362. action: (currentFrame: number) => void,
  77363. /** Specifies if the event should be triggered only once**/
  77364. onlyOnce?: boolean | undefined);
  77365. /** @hidden */
  77366. _clone(): AnimationEvent;
  77367. }
  77368. }
  77369. declare module BABYLON {
  77370. /**
  77371. * Interface used to define a behavior
  77372. */
  77373. export interface Behavior<T> {
  77374. /** gets or sets behavior's name */
  77375. name: string;
  77376. /**
  77377. * Function called when the behavior needs to be initialized (after attaching it to a target)
  77378. */
  77379. init(): void;
  77380. /**
  77381. * Called when the behavior is attached to a target
  77382. * @param target defines the target where the behavior is attached to
  77383. */
  77384. attach(target: T): void;
  77385. /**
  77386. * Called when the behavior is detached from its target
  77387. */
  77388. detach(): void;
  77389. }
  77390. /**
  77391. * Interface implemented by classes supporting behaviors
  77392. */
  77393. export interface IBehaviorAware<T> {
  77394. /**
  77395. * Attach a behavior
  77396. * @param behavior defines the behavior to attach
  77397. * @returns the current host
  77398. */
  77399. addBehavior(behavior: Behavior<T>): T;
  77400. /**
  77401. * Remove a behavior from the current object
  77402. * @param behavior defines the behavior to detach
  77403. * @returns the current host
  77404. */
  77405. removeBehavior(behavior: Behavior<T>): T;
  77406. /**
  77407. * Gets a behavior using its name to search
  77408. * @param name defines the name to search
  77409. * @returns the behavior or null if not found
  77410. */
  77411. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  77412. }
  77413. }
  77414. declare module BABYLON {
  77415. /**
  77416. * Defines an array and its length.
  77417. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  77418. */
  77419. export interface ISmartArrayLike<T> {
  77420. /**
  77421. * The data of the array.
  77422. */
  77423. data: Array<T>;
  77424. /**
  77425. * The active length of the array.
  77426. */
  77427. length: number;
  77428. }
  77429. /**
  77430. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  77431. */
  77432. export class SmartArray<T> implements ISmartArrayLike<T> {
  77433. /**
  77434. * The full set of data from the array.
  77435. */
  77436. data: Array<T>;
  77437. /**
  77438. * The active length of the array.
  77439. */
  77440. length: number;
  77441. protected _id: number;
  77442. /**
  77443. * Instantiates a Smart Array.
  77444. * @param capacity defines the default capacity of the array.
  77445. */
  77446. constructor(capacity: number);
  77447. /**
  77448. * Pushes a value at the end of the active data.
  77449. * @param value defines the object to push in the array.
  77450. */
  77451. push(value: T): void;
  77452. /**
  77453. * Iterates over the active data and apply the lambda to them.
  77454. * @param func defines the action to apply on each value.
  77455. */
  77456. forEach(func: (content: T) => void): void;
  77457. /**
  77458. * Sorts the full sets of data.
  77459. * @param compareFn defines the comparison function to apply.
  77460. */
  77461. sort(compareFn: (a: T, b: T) => number): void;
  77462. /**
  77463. * Resets the active data to an empty array.
  77464. */
  77465. reset(): void;
  77466. /**
  77467. * Releases all the data from the array as well as the array.
  77468. */
  77469. dispose(): void;
  77470. /**
  77471. * Concats the active data with a given array.
  77472. * @param array defines the data to concatenate with.
  77473. */
  77474. concat(array: any): void;
  77475. /**
  77476. * Returns the position of a value in the active data.
  77477. * @param value defines the value to find the index for
  77478. * @returns the index if found in the active data otherwise -1
  77479. */
  77480. indexOf(value: T): number;
  77481. /**
  77482. * Returns whether an element is part of the active data.
  77483. * @param value defines the value to look for
  77484. * @returns true if found in the active data otherwise false
  77485. */
  77486. contains(value: T): boolean;
  77487. private static _GlobalId;
  77488. }
  77489. /**
  77490. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  77491. * The data in this array can only be present once
  77492. */
  77493. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  77494. private _duplicateId;
  77495. /**
  77496. * Pushes a value at the end of the active data.
  77497. * THIS DOES NOT PREVENT DUPPLICATE DATA
  77498. * @param value defines the object to push in the array.
  77499. */
  77500. push(value: T): void;
  77501. /**
  77502. * Pushes a value at the end of the active data.
  77503. * If the data is already present, it won t be added again
  77504. * @param value defines the object to push in the array.
  77505. * @returns true if added false if it was already present
  77506. */
  77507. pushNoDuplicate(value: T): boolean;
  77508. /**
  77509. * Resets the active data to an empty array.
  77510. */
  77511. reset(): void;
  77512. /**
  77513. * Concats the active data with a given array.
  77514. * This ensures no dupplicate will be present in the result.
  77515. * @param array defines the data to concatenate with.
  77516. */
  77517. concatWithNoDuplicate(array: any): void;
  77518. }
  77519. }
  77520. declare module BABYLON {
  77521. /**
  77522. * @ignore
  77523. * This is a list of all the different input types that are available in the application.
  77524. * Fo instance: ArcRotateCameraGamepadInput...
  77525. */
  77526. export var CameraInputTypes: {};
  77527. /**
  77528. * This is the contract to implement in order to create a new input class.
  77529. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  77530. */
  77531. export interface ICameraInput<TCamera extends Camera> {
  77532. /**
  77533. * Defines the camera the input is attached to.
  77534. */
  77535. camera: Nullable<TCamera>;
  77536. /**
  77537. * Gets the class name of the current intput.
  77538. * @returns the class name
  77539. */
  77540. getClassName(): string;
  77541. /**
  77542. * Get the friendly name associated with the input class.
  77543. * @returns the input friendly name
  77544. */
  77545. getSimpleName(): string;
  77546. /**
  77547. * Attach the input controls to a specific dom element to get the input from.
  77548. * @param element Defines the element the controls should be listened from
  77549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77550. */
  77551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77552. /**
  77553. * Detach the current controls from the specified dom element.
  77554. * @param element Defines the element to stop listening the inputs from
  77555. */
  77556. detachControl(element: Nullable<HTMLElement>): void;
  77557. /**
  77558. * Update the current camera state depending on the inputs that have been used this frame.
  77559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77560. */
  77561. checkInputs?: () => void;
  77562. }
  77563. /**
  77564. * Represents a map of input types to input instance or input index to input instance.
  77565. */
  77566. export interface CameraInputsMap<TCamera extends Camera> {
  77567. /**
  77568. * Accessor to the input by input type.
  77569. */
  77570. [name: string]: ICameraInput<TCamera>;
  77571. /**
  77572. * Accessor to the input by input index.
  77573. */
  77574. [idx: number]: ICameraInput<TCamera>;
  77575. }
  77576. /**
  77577. * This represents the input manager used within a camera.
  77578. * It helps dealing with all the different kind of input attached to a camera.
  77579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77580. */
  77581. export class CameraInputsManager<TCamera extends Camera> {
  77582. /**
  77583. * Defines the list of inputs attahed to the camera.
  77584. */
  77585. attached: CameraInputsMap<TCamera>;
  77586. /**
  77587. * Defines the dom element the camera is collecting inputs from.
  77588. * This is null if the controls have not been attached.
  77589. */
  77590. attachedElement: Nullable<HTMLElement>;
  77591. /**
  77592. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77593. */
  77594. noPreventDefault: boolean;
  77595. /**
  77596. * Defined the camera the input manager belongs to.
  77597. */
  77598. camera: TCamera;
  77599. /**
  77600. * Update the current camera state depending on the inputs that have been used this frame.
  77601. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77602. */
  77603. checkInputs: () => void;
  77604. /**
  77605. * Instantiate a new Camera Input Manager.
  77606. * @param camera Defines the camera the input manager blongs to
  77607. */
  77608. constructor(camera: TCamera);
  77609. /**
  77610. * Add an input method to a camera
  77611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77612. * @param input camera input method
  77613. */
  77614. add(input: ICameraInput<TCamera>): void;
  77615. /**
  77616. * Remove a specific input method from a camera
  77617. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  77618. * @param inputToRemove camera input method
  77619. */
  77620. remove(inputToRemove: ICameraInput<TCamera>): void;
  77621. /**
  77622. * Remove a specific input type from a camera
  77623. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  77624. * @param inputType the type of the input to remove
  77625. */
  77626. removeByType(inputType: string): void;
  77627. private _addCheckInputs;
  77628. /**
  77629. * Attach the input controls to the currently attached dom element to listen the events from.
  77630. * @param input Defines the input to attach
  77631. */
  77632. attachInput(input: ICameraInput<TCamera>): void;
  77633. /**
  77634. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  77635. * @param element Defines the dom element to collect the events from
  77636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77637. */
  77638. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  77639. /**
  77640. * Detach the current manager inputs controls from a specific dom element.
  77641. * @param element Defines the dom element to collect the events from
  77642. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  77643. */
  77644. detachElement(element: HTMLElement, disconnect?: boolean): void;
  77645. /**
  77646. * Rebuild the dynamic inputCheck function from the current list of
  77647. * defined inputs in the manager.
  77648. */
  77649. rebuildInputCheck(): void;
  77650. /**
  77651. * Remove all attached input methods from a camera
  77652. */
  77653. clear(): void;
  77654. /**
  77655. * Serialize the current input manager attached to a camera.
  77656. * This ensures than once parsed,
  77657. * the input associated to the camera will be identical to the current ones
  77658. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  77659. */
  77660. serialize(serializedCamera: any): void;
  77661. /**
  77662. * Parses an input manager serialized JSON to restore the previous list of inputs
  77663. * and states associated to a camera.
  77664. * @param parsedCamera Defines the JSON to parse
  77665. */
  77666. parse(parsedCamera: any): void;
  77667. }
  77668. }
  77669. declare module BABYLON {
  77670. /**
  77671. * Class used to store data that will be store in GPU memory
  77672. */
  77673. export class Buffer {
  77674. private _engine;
  77675. private _buffer;
  77676. /** @hidden */
  77677. _data: Nullable<DataArray>;
  77678. private _updatable;
  77679. private _instanced;
  77680. private _divisor;
  77681. /**
  77682. * Gets the byte stride.
  77683. */
  77684. readonly byteStride: number;
  77685. /**
  77686. * Constructor
  77687. * @param engine the engine
  77688. * @param data the data to use for this buffer
  77689. * @param updatable whether the data is updatable
  77690. * @param stride the stride (optional)
  77691. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  77692. * @param instanced whether the buffer is instanced (optional)
  77693. * @param useBytes set to true if the stride in in bytes (optional)
  77694. * @param divisor sets an optional divisor for instances (1 by default)
  77695. */
  77696. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  77697. /**
  77698. * Create a new VertexBuffer based on the current buffer
  77699. * @param kind defines the vertex buffer kind (position, normal, etc.)
  77700. * @param offset defines offset in the buffer (0 by default)
  77701. * @param size defines the size in floats of attributes (position is 3 for instance)
  77702. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  77703. * @param instanced defines if the vertex buffer contains indexed data
  77704. * @param useBytes defines if the offset and stride are in bytes *
  77705. * @param divisor sets an optional divisor for instances (1 by default)
  77706. * @returns the new vertex buffer
  77707. */
  77708. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  77709. /**
  77710. * Gets a boolean indicating if the Buffer is updatable?
  77711. * @returns true if the buffer is updatable
  77712. */
  77713. isUpdatable(): boolean;
  77714. /**
  77715. * Gets current buffer's data
  77716. * @returns a DataArray or null
  77717. */
  77718. getData(): Nullable<DataArray>;
  77719. /**
  77720. * Gets underlying native buffer
  77721. * @returns underlying native buffer
  77722. */
  77723. getBuffer(): Nullable<DataBuffer>;
  77724. /**
  77725. * Gets the stride in float32 units (i.e. byte stride / 4).
  77726. * May not be an integer if the byte stride is not divisible by 4.
  77727. * @returns the stride in float32 units
  77728. * @deprecated Please use byteStride instead.
  77729. */
  77730. getStrideSize(): number;
  77731. /**
  77732. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77733. * @param data defines the data to store
  77734. */
  77735. create(data?: Nullable<DataArray>): void;
  77736. /** @hidden */
  77737. _rebuild(): void;
  77738. /**
  77739. * Update current buffer data
  77740. * @param data defines the data to store
  77741. */
  77742. update(data: DataArray): void;
  77743. /**
  77744. * Updates the data directly.
  77745. * @param data the new data
  77746. * @param offset the new offset
  77747. * @param vertexCount the vertex count (optional)
  77748. * @param useBytes set to true if the offset is in bytes
  77749. */
  77750. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  77751. /**
  77752. * Release all resources
  77753. */
  77754. dispose(): void;
  77755. }
  77756. /**
  77757. * Specialized buffer used to store vertex data
  77758. */
  77759. export class VertexBuffer {
  77760. /** @hidden */
  77761. _buffer: Buffer;
  77762. private _kind;
  77763. private _size;
  77764. private _ownsBuffer;
  77765. private _instanced;
  77766. private _instanceDivisor;
  77767. /**
  77768. * The byte type.
  77769. */
  77770. static readonly BYTE: number;
  77771. /**
  77772. * The unsigned byte type.
  77773. */
  77774. static readonly UNSIGNED_BYTE: number;
  77775. /**
  77776. * The short type.
  77777. */
  77778. static readonly SHORT: number;
  77779. /**
  77780. * The unsigned short type.
  77781. */
  77782. static readonly UNSIGNED_SHORT: number;
  77783. /**
  77784. * The integer type.
  77785. */
  77786. static readonly INT: number;
  77787. /**
  77788. * The unsigned integer type.
  77789. */
  77790. static readonly UNSIGNED_INT: number;
  77791. /**
  77792. * The float type.
  77793. */
  77794. static readonly FLOAT: number;
  77795. /**
  77796. * Gets or sets the instance divisor when in instanced mode
  77797. */
  77798. get instanceDivisor(): number;
  77799. set instanceDivisor(value: number);
  77800. /**
  77801. * Gets the byte stride.
  77802. */
  77803. readonly byteStride: number;
  77804. /**
  77805. * Gets the byte offset.
  77806. */
  77807. readonly byteOffset: number;
  77808. /**
  77809. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  77810. */
  77811. readonly normalized: boolean;
  77812. /**
  77813. * Gets the data type of each component in the array.
  77814. */
  77815. readonly type: number;
  77816. /**
  77817. * Constructor
  77818. * @param engine the engine
  77819. * @param data the data to use for this vertex buffer
  77820. * @param kind the vertex buffer kind
  77821. * @param updatable whether the data is updatable
  77822. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  77823. * @param stride the stride (optional)
  77824. * @param instanced whether the buffer is instanced (optional)
  77825. * @param offset the offset of the data (optional)
  77826. * @param size the number of components (optional)
  77827. * @param type the type of the component (optional)
  77828. * @param normalized whether the data contains normalized data (optional)
  77829. * @param useBytes set to true if stride and offset are in bytes (optional)
  77830. * @param divisor defines the instance divisor to use (1 by default)
  77831. */
  77832. 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);
  77833. /** @hidden */
  77834. _rebuild(): void;
  77835. /**
  77836. * Returns the kind of the VertexBuffer (string)
  77837. * @returns a string
  77838. */
  77839. getKind(): string;
  77840. /**
  77841. * Gets a boolean indicating if the VertexBuffer is updatable?
  77842. * @returns true if the buffer is updatable
  77843. */
  77844. isUpdatable(): boolean;
  77845. /**
  77846. * Gets current buffer's data
  77847. * @returns a DataArray or null
  77848. */
  77849. getData(): Nullable<DataArray>;
  77850. /**
  77851. * Gets underlying native buffer
  77852. * @returns underlying native buffer
  77853. */
  77854. getBuffer(): Nullable<DataBuffer>;
  77855. /**
  77856. * Gets the stride in float32 units (i.e. byte stride / 4).
  77857. * May not be an integer if the byte stride is not divisible by 4.
  77858. * @returns the stride in float32 units
  77859. * @deprecated Please use byteStride instead.
  77860. */
  77861. getStrideSize(): number;
  77862. /**
  77863. * Returns the offset as a multiple of the type byte length.
  77864. * @returns the offset in bytes
  77865. * @deprecated Please use byteOffset instead.
  77866. */
  77867. getOffset(): number;
  77868. /**
  77869. * Returns the number of components per vertex attribute (integer)
  77870. * @returns the size in float
  77871. */
  77872. getSize(): number;
  77873. /**
  77874. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  77875. * @returns true if this buffer is instanced
  77876. */
  77877. getIsInstanced(): boolean;
  77878. /**
  77879. * Returns the instancing divisor, zero for non-instanced (integer).
  77880. * @returns a number
  77881. */
  77882. getInstanceDivisor(): number;
  77883. /**
  77884. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77885. * @param data defines the data to store
  77886. */
  77887. create(data?: DataArray): void;
  77888. /**
  77889. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  77890. * This function will create a new buffer if the current one is not updatable
  77891. * @param data defines the data to store
  77892. */
  77893. update(data: DataArray): void;
  77894. /**
  77895. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  77896. * Returns the directly updated WebGLBuffer.
  77897. * @param data the new data
  77898. * @param offset the new offset
  77899. * @param useBytes set to true if the offset is in bytes
  77900. */
  77901. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  77902. /**
  77903. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  77904. */
  77905. dispose(): void;
  77906. /**
  77907. * Enumerates each value of this vertex buffer as numbers.
  77908. * @param count the number of values to enumerate
  77909. * @param callback the callback function called for each value
  77910. */
  77911. forEach(count: number, callback: (value: number, index: number) => void): void;
  77912. /**
  77913. * Positions
  77914. */
  77915. static readonly PositionKind: string;
  77916. /**
  77917. * Normals
  77918. */
  77919. static readonly NormalKind: string;
  77920. /**
  77921. * Tangents
  77922. */
  77923. static readonly TangentKind: string;
  77924. /**
  77925. * Texture coordinates
  77926. */
  77927. static readonly UVKind: string;
  77928. /**
  77929. * Texture coordinates 2
  77930. */
  77931. static readonly UV2Kind: string;
  77932. /**
  77933. * Texture coordinates 3
  77934. */
  77935. static readonly UV3Kind: string;
  77936. /**
  77937. * Texture coordinates 4
  77938. */
  77939. static readonly UV4Kind: string;
  77940. /**
  77941. * Texture coordinates 5
  77942. */
  77943. static readonly UV5Kind: string;
  77944. /**
  77945. * Texture coordinates 6
  77946. */
  77947. static readonly UV6Kind: string;
  77948. /**
  77949. * Colors
  77950. */
  77951. static readonly ColorKind: string;
  77952. /**
  77953. * Matrix indices (for bones)
  77954. */
  77955. static readonly MatricesIndicesKind: string;
  77956. /**
  77957. * Matrix weights (for bones)
  77958. */
  77959. static readonly MatricesWeightsKind: string;
  77960. /**
  77961. * Additional matrix indices (for bones)
  77962. */
  77963. static readonly MatricesIndicesExtraKind: string;
  77964. /**
  77965. * Additional matrix weights (for bones)
  77966. */
  77967. static readonly MatricesWeightsExtraKind: string;
  77968. /**
  77969. * Deduces the stride given a kind.
  77970. * @param kind The kind string to deduce
  77971. * @returns The deduced stride
  77972. */
  77973. static DeduceStride(kind: string): number;
  77974. /**
  77975. * Gets the byte length of the given type.
  77976. * @param type the type
  77977. * @returns the number of bytes
  77978. */
  77979. static GetTypeByteLength(type: number): number;
  77980. /**
  77981. * Enumerates each value of the given parameters as numbers.
  77982. * @param data the data to enumerate
  77983. * @param byteOffset the byte offset of the data
  77984. * @param byteStride the byte stride of the data
  77985. * @param componentCount the number of components per element
  77986. * @param componentType the type of the component
  77987. * @param count the number of values to enumerate
  77988. * @param normalized whether the data is normalized
  77989. * @param callback the callback function called for each value
  77990. */
  77991. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  77992. private static _GetFloatValue;
  77993. }
  77994. }
  77995. declare module BABYLON {
  77996. /**
  77997. * @hidden
  77998. */
  77999. export class IntersectionInfo {
  78000. bu: Nullable<number>;
  78001. bv: Nullable<number>;
  78002. distance: number;
  78003. faceId: number;
  78004. subMeshId: number;
  78005. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  78006. }
  78007. }
  78008. declare module BABYLON {
  78009. /**
  78010. * Represens a plane by the equation ax + by + cz + d = 0
  78011. */
  78012. export class Plane {
  78013. private static _TmpMatrix;
  78014. /**
  78015. * Normal of the plane (a,b,c)
  78016. */
  78017. normal: Vector3;
  78018. /**
  78019. * d component of the plane
  78020. */
  78021. d: number;
  78022. /**
  78023. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  78024. * @param a a component of the plane
  78025. * @param b b component of the plane
  78026. * @param c c component of the plane
  78027. * @param d d component of the plane
  78028. */
  78029. constructor(a: number, b: number, c: number, d: number);
  78030. /**
  78031. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  78032. */
  78033. asArray(): number[];
  78034. /**
  78035. * @returns a new plane copied from the current Plane.
  78036. */
  78037. clone(): Plane;
  78038. /**
  78039. * @returns the string "Plane".
  78040. */
  78041. getClassName(): string;
  78042. /**
  78043. * @returns the Plane hash code.
  78044. */
  78045. getHashCode(): number;
  78046. /**
  78047. * Normalize the current Plane in place.
  78048. * @returns the updated Plane.
  78049. */
  78050. normalize(): Plane;
  78051. /**
  78052. * Applies a transformation the plane and returns the result
  78053. * @param transformation the transformation matrix to be applied to the plane
  78054. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  78055. */
  78056. transform(transformation: DeepImmutable<Matrix>): Plane;
  78057. /**
  78058. * Calcualtte the dot product between the point and the plane normal
  78059. * @param point point to calculate the dot product with
  78060. * @returns the dot product (float) of the point coordinates and the plane normal.
  78061. */
  78062. dotCoordinate(point: DeepImmutable<Vector3>): number;
  78063. /**
  78064. * Updates the current Plane from the plane defined by the three given points.
  78065. * @param point1 one of the points used to contruct the plane
  78066. * @param point2 one of the points used to contruct the plane
  78067. * @param point3 one of the points used to contruct the plane
  78068. * @returns the updated Plane.
  78069. */
  78070. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78071. /**
  78072. * Checks if the plane is facing a given direction
  78073. * @param direction the direction to check if the plane is facing
  78074. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  78075. * @returns True is the vector "direction" is the same side than the plane normal.
  78076. */
  78077. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  78078. /**
  78079. * Calculates the distance to a point
  78080. * @param point point to calculate distance to
  78081. * @returns the signed distance (float) from the given point to the Plane.
  78082. */
  78083. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  78084. /**
  78085. * Creates a plane from an array
  78086. * @param array the array to create a plane from
  78087. * @returns a new Plane from the given array.
  78088. */
  78089. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  78090. /**
  78091. * Creates a plane from three points
  78092. * @param point1 point used to create the plane
  78093. * @param point2 point used to create the plane
  78094. * @param point3 point used to create the plane
  78095. * @returns a new Plane defined by the three given points.
  78096. */
  78097. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78098. /**
  78099. * Creates a plane from an origin point and a normal
  78100. * @param origin origin of the plane to be constructed
  78101. * @param normal normal of the plane to be constructed
  78102. * @returns a new Plane the normal vector to this plane at the given origin point.
  78103. * Note : the vector "normal" is updated because normalized.
  78104. */
  78105. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  78106. /**
  78107. * Calculates the distance from a plane and a point
  78108. * @param origin origin of the plane to be constructed
  78109. * @param normal normal of the plane to be constructed
  78110. * @param point point to calculate distance to
  78111. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  78112. */
  78113. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  78114. }
  78115. }
  78116. declare module BABYLON {
  78117. /**
  78118. * Class used to store bounding sphere information
  78119. */
  78120. export class BoundingSphere {
  78121. /**
  78122. * Gets the center of the bounding sphere in local space
  78123. */
  78124. readonly center: Vector3;
  78125. /**
  78126. * Radius of the bounding sphere in local space
  78127. */
  78128. radius: number;
  78129. /**
  78130. * Gets the center of the bounding sphere in world space
  78131. */
  78132. readonly centerWorld: Vector3;
  78133. /**
  78134. * Radius of the bounding sphere in world space
  78135. */
  78136. radiusWorld: number;
  78137. /**
  78138. * Gets the minimum vector in local space
  78139. */
  78140. readonly minimum: Vector3;
  78141. /**
  78142. * Gets the maximum vector in local space
  78143. */
  78144. readonly maximum: Vector3;
  78145. private _worldMatrix;
  78146. private static readonly TmpVector3;
  78147. /**
  78148. * Creates a new bounding sphere
  78149. * @param min defines the minimum vector (in local space)
  78150. * @param max defines the maximum vector (in local space)
  78151. * @param worldMatrix defines the new world matrix
  78152. */
  78153. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  78154. /**
  78155. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  78156. * @param min defines the new minimum vector (in local space)
  78157. * @param max defines the new maximum vector (in local space)
  78158. * @param worldMatrix defines the new world matrix
  78159. */
  78160. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  78161. /**
  78162. * Scale the current bounding sphere by applying a scale factor
  78163. * @param factor defines the scale factor to apply
  78164. * @returns the current bounding box
  78165. */
  78166. scale(factor: number): BoundingSphere;
  78167. /**
  78168. * Gets the world matrix of the bounding box
  78169. * @returns a matrix
  78170. */
  78171. getWorldMatrix(): DeepImmutable<Matrix>;
  78172. /** @hidden */
  78173. _update(worldMatrix: DeepImmutable<Matrix>): void;
  78174. /**
  78175. * Tests if the bounding sphere is intersecting the frustum planes
  78176. * @param frustumPlanes defines the frustum planes to test
  78177. * @returns true if there is an intersection
  78178. */
  78179. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78180. /**
  78181. * Tests if the bounding sphere center is in between the frustum planes.
  78182. * Used for optimistic fast inclusion.
  78183. * @param frustumPlanes defines the frustum planes to test
  78184. * @returns true if the sphere center is in between the frustum planes
  78185. */
  78186. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78187. /**
  78188. * Tests if a point is inside the bounding sphere
  78189. * @param point defines the point to test
  78190. * @returns true if the point is inside the bounding sphere
  78191. */
  78192. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  78193. /**
  78194. * Checks if two sphere intersct
  78195. * @param sphere0 sphere 0
  78196. * @param sphere1 sphere 1
  78197. * @returns true if the speres intersect
  78198. */
  78199. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  78200. }
  78201. }
  78202. declare module BABYLON {
  78203. /**
  78204. * Class used to store bounding box information
  78205. */
  78206. export class BoundingBox implements ICullable {
  78207. /**
  78208. * Gets the 8 vectors representing the bounding box in local space
  78209. */
  78210. readonly vectors: Vector3[];
  78211. /**
  78212. * Gets the center of the bounding box in local space
  78213. */
  78214. readonly center: Vector3;
  78215. /**
  78216. * Gets the center of the bounding box in world space
  78217. */
  78218. readonly centerWorld: Vector3;
  78219. /**
  78220. * Gets the extend size in local space
  78221. */
  78222. readonly extendSize: Vector3;
  78223. /**
  78224. * Gets the extend size in world space
  78225. */
  78226. readonly extendSizeWorld: Vector3;
  78227. /**
  78228. * Gets the OBB (object bounding box) directions
  78229. */
  78230. readonly directions: Vector3[];
  78231. /**
  78232. * Gets the 8 vectors representing the bounding box in world space
  78233. */
  78234. readonly vectorsWorld: Vector3[];
  78235. /**
  78236. * Gets the minimum vector in world space
  78237. */
  78238. readonly minimumWorld: Vector3;
  78239. /**
  78240. * Gets the maximum vector in world space
  78241. */
  78242. readonly maximumWorld: Vector3;
  78243. /**
  78244. * Gets the minimum vector in local space
  78245. */
  78246. readonly minimum: Vector3;
  78247. /**
  78248. * Gets the maximum vector in local space
  78249. */
  78250. readonly maximum: Vector3;
  78251. private _worldMatrix;
  78252. private static readonly TmpVector3;
  78253. /**
  78254. * @hidden
  78255. */
  78256. _tag: number;
  78257. /**
  78258. * Creates a new bounding box
  78259. * @param min defines the minimum vector (in local space)
  78260. * @param max defines the maximum vector (in local space)
  78261. * @param worldMatrix defines the new world matrix
  78262. */
  78263. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  78264. /**
  78265. * Recreates the entire bounding box from scratch as if we call the constructor in place
  78266. * @param min defines the new minimum vector (in local space)
  78267. * @param max defines the new maximum vector (in local space)
  78268. * @param worldMatrix defines the new world matrix
  78269. */
  78270. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  78271. /**
  78272. * Scale the current bounding box by applying a scale factor
  78273. * @param factor defines the scale factor to apply
  78274. * @returns the current bounding box
  78275. */
  78276. scale(factor: number): BoundingBox;
  78277. /**
  78278. * Gets the world matrix of the bounding box
  78279. * @returns a matrix
  78280. */
  78281. getWorldMatrix(): DeepImmutable<Matrix>;
  78282. /** @hidden */
  78283. _update(world: DeepImmutable<Matrix>): void;
  78284. /**
  78285. * Tests if the bounding box is intersecting the frustum planes
  78286. * @param frustumPlanes defines the frustum planes to test
  78287. * @returns true if there is an intersection
  78288. */
  78289. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78290. /**
  78291. * Tests if the bounding box is entirely inside the frustum planes
  78292. * @param frustumPlanes defines the frustum planes to test
  78293. * @returns true if there is an inclusion
  78294. */
  78295. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78296. /**
  78297. * Tests if a point is inside the bounding box
  78298. * @param point defines the point to test
  78299. * @returns true if the point is inside the bounding box
  78300. */
  78301. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  78302. /**
  78303. * Tests if the bounding box intersects with a bounding sphere
  78304. * @param sphere defines the sphere to test
  78305. * @returns true if there is an intersection
  78306. */
  78307. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  78308. /**
  78309. * Tests if the bounding box intersects with a box defined by a min and max vectors
  78310. * @param min defines the min vector to use
  78311. * @param max defines the max vector to use
  78312. * @returns true if there is an intersection
  78313. */
  78314. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  78315. /**
  78316. * Tests if two bounding boxes are intersections
  78317. * @param box0 defines the first box to test
  78318. * @param box1 defines the second box to test
  78319. * @returns true if there is an intersection
  78320. */
  78321. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  78322. /**
  78323. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  78324. * @param minPoint defines the minimum vector of the bounding box
  78325. * @param maxPoint defines the maximum vector of the bounding box
  78326. * @param sphereCenter defines the sphere center
  78327. * @param sphereRadius defines the sphere radius
  78328. * @returns true if there is an intersection
  78329. */
  78330. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  78331. /**
  78332. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  78333. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  78334. * @param frustumPlanes defines the frustum planes to test
  78335. * @return true if there is an inclusion
  78336. */
  78337. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78338. /**
  78339. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  78340. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  78341. * @param frustumPlanes defines the frustum planes to test
  78342. * @return true if there is an intersection
  78343. */
  78344. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78345. }
  78346. }
  78347. declare module BABYLON {
  78348. /** @hidden */
  78349. export class Collider {
  78350. /** Define if a collision was found */
  78351. collisionFound: boolean;
  78352. /**
  78353. * Define last intersection point in local space
  78354. */
  78355. intersectionPoint: Vector3;
  78356. /**
  78357. * Define last collided mesh
  78358. */
  78359. collidedMesh: Nullable<AbstractMesh>;
  78360. private _collisionPoint;
  78361. private _planeIntersectionPoint;
  78362. private _tempVector;
  78363. private _tempVector2;
  78364. private _tempVector3;
  78365. private _tempVector4;
  78366. private _edge;
  78367. private _baseToVertex;
  78368. private _destinationPoint;
  78369. private _slidePlaneNormal;
  78370. private _displacementVector;
  78371. /** @hidden */
  78372. _radius: Vector3;
  78373. /** @hidden */
  78374. _retry: number;
  78375. private _velocity;
  78376. private _basePoint;
  78377. private _epsilon;
  78378. /** @hidden */
  78379. _velocityWorldLength: number;
  78380. /** @hidden */
  78381. _basePointWorld: Vector3;
  78382. private _velocityWorld;
  78383. private _normalizedVelocity;
  78384. /** @hidden */
  78385. _initialVelocity: Vector3;
  78386. /** @hidden */
  78387. _initialPosition: Vector3;
  78388. private _nearestDistance;
  78389. private _collisionMask;
  78390. get collisionMask(): number;
  78391. set collisionMask(mask: number);
  78392. /**
  78393. * Gets the plane normal used to compute the sliding response (in local space)
  78394. */
  78395. get slidePlaneNormal(): Vector3;
  78396. /** @hidden */
  78397. _initialize(source: Vector3, dir: Vector3, e: number): void;
  78398. /** @hidden */
  78399. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  78400. /** @hidden */
  78401. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  78402. /** @hidden */
  78403. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  78404. /** @hidden */
  78405. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  78406. /** @hidden */
  78407. _getResponse(pos: Vector3, vel: Vector3): void;
  78408. }
  78409. }
  78410. declare module BABYLON {
  78411. /**
  78412. * Interface for cullable objects
  78413. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  78414. */
  78415. export interface ICullable {
  78416. /**
  78417. * Checks if the object or part of the object is in the frustum
  78418. * @param frustumPlanes Camera near/planes
  78419. * @returns true if the object is in frustum otherwise false
  78420. */
  78421. isInFrustum(frustumPlanes: Plane[]): boolean;
  78422. /**
  78423. * Checks if a cullable object (mesh...) is in the camera frustum
  78424. * Unlike isInFrustum this cheks the full bounding box
  78425. * @param frustumPlanes Camera near/planes
  78426. * @returns true if the object is in frustum otherwise false
  78427. */
  78428. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  78429. }
  78430. /**
  78431. * Info for a bounding data of a mesh
  78432. */
  78433. export class BoundingInfo implements ICullable {
  78434. /**
  78435. * Bounding box for the mesh
  78436. */
  78437. readonly boundingBox: BoundingBox;
  78438. /**
  78439. * Bounding sphere for the mesh
  78440. */
  78441. readonly boundingSphere: BoundingSphere;
  78442. private _isLocked;
  78443. private static readonly TmpVector3;
  78444. /**
  78445. * Constructs bounding info
  78446. * @param minimum min vector of the bounding box/sphere
  78447. * @param maximum max vector of the bounding box/sphere
  78448. * @param worldMatrix defines the new world matrix
  78449. */
  78450. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  78451. /**
  78452. * Recreates the entire bounding info from scratch as if we call the constructor in place
  78453. * @param min defines the new minimum vector (in local space)
  78454. * @param max defines the new maximum vector (in local space)
  78455. * @param worldMatrix defines the new world matrix
  78456. */
  78457. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  78458. /**
  78459. * min vector of the bounding box/sphere
  78460. */
  78461. get minimum(): Vector3;
  78462. /**
  78463. * max vector of the bounding box/sphere
  78464. */
  78465. get maximum(): Vector3;
  78466. /**
  78467. * If the info is locked and won't be updated to avoid perf overhead
  78468. */
  78469. get isLocked(): boolean;
  78470. set isLocked(value: boolean);
  78471. /**
  78472. * Updates the bounding sphere and box
  78473. * @param world world matrix to be used to update
  78474. */
  78475. update(world: DeepImmutable<Matrix>): void;
  78476. /**
  78477. * Recreate the bounding info to be centered around a specific point given a specific extend.
  78478. * @param center New center of the bounding info
  78479. * @param extend New extend of the bounding info
  78480. * @returns the current bounding info
  78481. */
  78482. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  78483. /**
  78484. * Scale the current bounding info by applying a scale factor
  78485. * @param factor defines the scale factor to apply
  78486. * @returns the current bounding info
  78487. */
  78488. scale(factor: number): BoundingInfo;
  78489. /**
  78490. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  78491. * @param frustumPlanes defines the frustum to test
  78492. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  78493. * @returns true if the bounding info is in the frustum planes
  78494. */
  78495. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  78496. /**
  78497. * Gets the world distance between the min and max points of the bounding box
  78498. */
  78499. get diagonalLength(): number;
  78500. /**
  78501. * Checks if a cullable object (mesh...) is in the camera frustum
  78502. * Unlike isInFrustum this cheks the full bounding box
  78503. * @param frustumPlanes Camera near/planes
  78504. * @returns true if the object is in frustum otherwise false
  78505. */
  78506. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78507. /** @hidden */
  78508. _checkCollision(collider: Collider): boolean;
  78509. /**
  78510. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  78511. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  78512. * @param point the point to check intersection with
  78513. * @returns if the point intersects
  78514. */
  78515. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  78516. /**
  78517. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  78518. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  78519. * @param boundingInfo the bounding info to check intersection with
  78520. * @param precise if the intersection should be done using OBB
  78521. * @returns if the bounding info intersects
  78522. */
  78523. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  78524. }
  78525. }
  78526. declare module BABYLON {
  78527. /**
  78528. * Extracts minimum and maximum values from a list of indexed positions
  78529. * @param positions defines the positions to use
  78530. * @param indices defines the indices to the positions
  78531. * @param indexStart defines the start index
  78532. * @param indexCount defines the end index
  78533. * @param bias defines bias value to add to the result
  78534. * @return minimum and maximum values
  78535. */
  78536. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  78537. minimum: Vector3;
  78538. maximum: Vector3;
  78539. };
  78540. /**
  78541. * Extracts minimum and maximum values from a list of positions
  78542. * @param positions defines the positions to use
  78543. * @param start defines the start index in the positions array
  78544. * @param count defines the number of positions to handle
  78545. * @param bias defines bias value to add to the result
  78546. * @param stride defines the stride size to use (distance between two positions in the positions array)
  78547. * @return minimum and maximum values
  78548. */
  78549. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  78550. minimum: Vector3;
  78551. maximum: Vector3;
  78552. };
  78553. }
  78554. declare module BABYLON {
  78555. /** @hidden */
  78556. export class WebGLDataBuffer extends DataBuffer {
  78557. private _buffer;
  78558. constructor(resource: WebGLBuffer);
  78559. get underlyingResource(): any;
  78560. }
  78561. }
  78562. declare module BABYLON {
  78563. /** @hidden */
  78564. export class WebGLPipelineContext implements IPipelineContext {
  78565. engine: ThinEngine;
  78566. program: Nullable<WebGLProgram>;
  78567. context?: WebGLRenderingContext;
  78568. vertexShader?: WebGLShader;
  78569. fragmentShader?: WebGLShader;
  78570. isParallelCompiled: boolean;
  78571. onCompiled?: () => void;
  78572. transformFeedback?: WebGLTransformFeedback | null;
  78573. vertexCompilationError: Nullable<string>;
  78574. fragmentCompilationError: Nullable<string>;
  78575. programLinkError: Nullable<string>;
  78576. programValidationError: Nullable<string>;
  78577. get isAsync(): boolean;
  78578. get isReady(): boolean;
  78579. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  78580. }
  78581. }
  78582. declare module BABYLON {
  78583. interface ThinEngine {
  78584. /**
  78585. * Create an uniform buffer
  78586. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  78587. * @param elements defines the content of the uniform buffer
  78588. * @returns the webGL uniform buffer
  78589. */
  78590. createUniformBuffer(elements: FloatArray): DataBuffer;
  78591. /**
  78592. * Create a dynamic uniform buffer
  78593. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  78594. * @param elements defines the content of the uniform buffer
  78595. * @returns the webGL uniform buffer
  78596. */
  78597. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  78598. /**
  78599. * Update an existing uniform buffer
  78600. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  78601. * @param uniformBuffer defines the target uniform buffer
  78602. * @param elements defines the content to update
  78603. * @param offset defines the offset in the uniform buffer where update should start
  78604. * @param count defines the size of the data to update
  78605. */
  78606. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  78607. /**
  78608. * Bind an uniform buffer to the current webGL context
  78609. * @param buffer defines the buffer to bind
  78610. */
  78611. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  78612. /**
  78613. * Bind a buffer to the current webGL context at a given location
  78614. * @param buffer defines the buffer to bind
  78615. * @param location defines the index where to bind the buffer
  78616. */
  78617. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  78618. /**
  78619. * Bind a specific block at a given index in a specific shader program
  78620. * @param pipelineContext defines the pipeline context to use
  78621. * @param blockName defines the block name
  78622. * @param index defines the index where to bind the block
  78623. */
  78624. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  78625. }
  78626. }
  78627. declare module BABYLON {
  78628. /**
  78629. * Uniform buffer objects.
  78630. *
  78631. * Handles blocks of uniform on the GPU.
  78632. *
  78633. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  78634. *
  78635. * For more information, please refer to :
  78636. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  78637. */
  78638. export class UniformBuffer {
  78639. private _engine;
  78640. private _buffer;
  78641. private _data;
  78642. private _bufferData;
  78643. private _dynamic?;
  78644. private _uniformLocations;
  78645. private _uniformSizes;
  78646. private _uniformLocationPointer;
  78647. private _needSync;
  78648. private _noUBO;
  78649. private _currentEffect;
  78650. /** @hidden */
  78651. _alreadyBound: boolean;
  78652. private static _MAX_UNIFORM_SIZE;
  78653. private static _tempBuffer;
  78654. /**
  78655. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  78656. * This is dynamic to allow compat with webgl 1 and 2.
  78657. * You will need to pass the name of the uniform as well as the value.
  78658. */
  78659. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  78660. /**
  78661. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  78662. * This is dynamic to allow compat with webgl 1 and 2.
  78663. * You will need to pass the name of the uniform as well as the value.
  78664. */
  78665. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  78666. /**
  78667. * Lambda to Update a single float in a uniform buffer.
  78668. * This is dynamic to allow compat with webgl 1 and 2.
  78669. * You will need to pass the name of the uniform as well as the value.
  78670. */
  78671. updateFloat: (name: string, x: number) => void;
  78672. /**
  78673. * Lambda to Update a vec2 of float in a uniform buffer.
  78674. * This is dynamic to allow compat with webgl 1 and 2.
  78675. * You will need to pass the name of the uniform as well as the value.
  78676. */
  78677. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  78678. /**
  78679. * Lambda to Update a vec3 of float in a uniform buffer.
  78680. * This is dynamic to allow compat with webgl 1 and 2.
  78681. * You will need to pass the name of the uniform as well as the value.
  78682. */
  78683. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  78684. /**
  78685. * Lambda to Update a vec4 of float in a uniform buffer.
  78686. * This is dynamic to allow compat with webgl 1 and 2.
  78687. * You will need to pass the name of the uniform as well as the value.
  78688. */
  78689. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  78690. /**
  78691. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  78692. * This is dynamic to allow compat with webgl 1 and 2.
  78693. * You will need to pass the name of the uniform as well as the value.
  78694. */
  78695. updateMatrix: (name: string, mat: Matrix) => void;
  78696. /**
  78697. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  78698. * This is dynamic to allow compat with webgl 1 and 2.
  78699. * You will need to pass the name of the uniform as well as the value.
  78700. */
  78701. updateVector3: (name: string, vector: Vector3) => void;
  78702. /**
  78703. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  78704. * This is dynamic to allow compat with webgl 1 and 2.
  78705. * You will need to pass the name of the uniform as well as the value.
  78706. */
  78707. updateVector4: (name: string, vector: Vector4) => void;
  78708. /**
  78709. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  78710. * This is dynamic to allow compat with webgl 1 and 2.
  78711. * You will need to pass the name of the uniform as well as the value.
  78712. */
  78713. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  78714. /**
  78715. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  78716. * This is dynamic to allow compat with webgl 1 and 2.
  78717. * You will need to pass the name of the uniform as well as the value.
  78718. */
  78719. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  78720. /**
  78721. * Instantiates a new Uniform buffer objects.
  78722. *
  78723. * Handles blocks of uniform on the GPU.
  78724. *
  78725. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  78726. *
  78727. * For more information, please refer to :
  78728. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  78729. * @param engine Define the engine the buffer is associated with
  78730. * @param data Define the data contained in the buffer
  78731. * @param dynamic Define if the buffer is updatable
  78732. */
  78733. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  78734. /**
  78735. * Indicates if the buffer is using the WebGL2 UBO implementation,
  78736. * or just falling back on setUniformXXX calls.
  78737. */
  78738. get useUbo(): boolean;
  78739. /**
  78740. * Indicates if the WebGL underlying uniform buffer is in sync
  78741. * with the javascript cache data.
  78742. */
  78743. get isSync(): boolean;
  78744. /**
  78745. * Indicates if the WebGL underlying uniform buffer is dynamic.
  78746. * Also, a dynamic UniformBuffer will disable cache verification and always
  78747. * update the underlying WebGL uniform buffer to the GPU.
  78748. * @returns if Dynamic, otherwise false
  78749. */
  78750. isDynamic(): boolean;
  78751. /**
  78752. * The data cache on JS side.
  78753. * @returns the underlying data as a float array
  78754. */
  78755. getData(): Float32Array;
  78756. /**
  78757. * The underlying WebGL Uniform buffer.
  78758. * @returns the webgl buffer
  78759. */
  78760. getBuffer(): Nullable<DataBuffer>;
  78761. /**
  78762. * std140 layout specifies how to align data within an UBO structure.
  78763. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  78764. * for specs.
  78765. */
  78766. private _fillAlignment;
  78767. /**
  78768. * Adds an uniform in the buffer.
  78769. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  78770. * for the layout to be correct !
  78771. * @param name Name of the uniform, as used in the uniform block in the shader.
  78772. * @param size Data size, or data directly.
  78773. */
  78774. addUniform(name: string, size: number | number[]): void;
  78775. /**
  78776. * Adds a Matrix 4x4 to the uniform buffer.
  78777. * @param name Name of the uniform, as used in the uniform block in the shader.
  78778. * @param mat A 4x4 matrix.
  78779. */
  78780. addMatrix(name: string, mat: Matrix): void;
  78781. /**
  78782. * Adds a vec2 to the uniform buffer.
  78783. * @param name Name of the uniform, as used in the uniform block in the shader.
  78784. * @param x Define the x component value of the vec2
  78785. * @param y Define the y component value of the vec2
  78786. */
  78787. addFloat2(name: string, x: number, y: number): void;
  78788. /**
  78789. * Adds a vec3 to the uniform buffer.
  78790. * @param name Name of the uniform, as used in the uniform block in the shader.
  78791. * @param x Define the x component value of the vec3
  78792. * @param y Define the y component value of the vec3
  78793. * @param z Define the z component value of the vec3
  78794. */
  78795. addFloat3(name: string, x: number, y: number, z: number): void;
  78796. /**
  78797. * Adds a vec3 to the uniform buffer.
  78798. * @param name Name of the uniform, as used in the uniform block in the shader.
  78799. * @param color Define the vec3 from a Color
  78800. */
  78801. addColor3(name: string, color: Color3): void;
  78802. /**
  78803. * Adds a vec4 to the uniform buffer.
  78804. * @param name Name of the uniform, as used in the uniform block in the shader.
  78805. * @param color Define the rgb components from a Color
  78806. * @param alpha Define the a component of the vec4
  78807. */
  78808. addColor4(name: string, color: Color3, alpha: number): void;
  78809. /**
  78810. * Adds a vec3 to the uniform buffer.
  78811. * @param name Name of the uniform, as used in the uniform block in the shader.
  78812. * @param vector Define the vec3 components from a Vector
  78813. */
  78814. addVector3(name: string, vector: Vector3): void;
  78815. /**
  78816. * Adds a Matrix 3x3 to the uniform buffer.
  78817. * @param name Name of the uniform, as used in the uniform block in the shader.
  78818. */
  78819. addMatrix3x3(name: string): void;
  78820. /**
  78821. * Adds a Matrix 2x2 to the uniform buffer.
  78822. * @param name Name of the uniform, as used in the uniform block in the shader.
  78823. */
  78824. addMatrix2x2(name: string): void;
  78825. /**
  78826. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  78827. */
  78828. create(): void;
  78829. /** @hidden */
  78830. _rebuild(): void;
  78831. /**
  78832. * Updates the WebGL Uniform Buffer on the GPU.
  78833. * If the `dynamic` flag is set to true, no cache comparison is done.
  78834. * Otherwise, the buffer will be updated only if the cache differs.
  78835. */
  78836. update(): void;
  78837. /**
  78838. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  78839. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78840. * @param data Define the flattened data
  78841. * @param size Define the size of the data.
  78842. */
  78843. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  78844. private _valueCache;
  78845. private _cacheMatrix;
  78846. private _updateMatrix3x3ForUniform;
  78847. private _updateMatrix3x3ForEffect;
  78848. private _updateMatrix2x2ForEffect;
  78849. private _updateMatrix2x2ForUniform;
  78850. private _updateFloatForEffect;
  78851. private _updateFloatForUniform;
  78852. private _updateFloat2ForEffect;
  78853. private _updateFloat2ForUniform;
  78854. private _updateFloat3ForEffect;
  78855. private _updateFloat3ForUniform;
  78856. private _updateFloat4ForEffect;
  78857. private _updateFloat4ForUniform;
  78858. private _updateMatrixForEffect;
  78859. private _updateMatrixForUniform;
  78860. private _updateVector3ForEffect;
  78861. private _updateVector3ForUniform;
  78862. private _updateVector4ForEffect;
  78863. private _updateVector4ForUniform;
  78864. private _updateColor3ForEffect;
  78865. private _updateColor3ForUniform;
  78866. private _updateColor4ForEffect;
  78867. private _updateColor4ForUniform;
  78868. /**
  78869. * Sets a sampler uniform on the effect.
  78870. * @param name Define the name of the sampler.
  78871. * @param texture Define the texture to set in the sampler
  78872. */
  78873. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  78874. /**
  78875. * Directly updates the value of the uniform in the cache AND on the GPU.
  78876. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78877. * @param data Define the flattened data
  78878. */
  78879. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  78880. /**
  78881. * Binds this uniform buffer to an effect.
  78882. * @param effect Define the effect to bind the buffer to
  78883. * @param name Name of the uniform block in the shader.
  78884. */
  78885. bindToEffect(effect: Effect, name: string): void;
  78886. /**
  78887. * Disposes the uniform buffer.
  78888. */
  78889. dispose(): void;
  78890. }
  78891. }
  78892. declare module BABYLON {
  78893. /**
  78894. * Enum that determines the text-wrapping mode to use.
  78895. */
  78896. export enum InspectableType {
  78897. /**
  78898. * Checkbox for booleans
  78899. */
  78900. Checkbox = 0,
  78901. /**
  78902. * Sliders for numbers
  78903. */
  78904. Slider = 1,
  78905. /**
  78906. * Vector3
  78907. */
  78908. Vector3 = 2,
  78909. /**
  78910. * Quaternions
  78911. */
  78912. Quaternion = 3,
  78913. /**
  78914. * Color3
  78915. */
  78916. Color3 = 4,
  78917. /**
  78918. * String
  78919. */
  78920. String = 5
  78921. }
  78922. /**
  78923. * Interface used to define custom inspectable properties.
  78924. * This interface is used by the inspector to display custom property grids
  78925. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78926. */
  78927. export interface IInspectable {
  78928. /**
  78929. * Gets the label to display
  78930. */
  78931. label: string;
  78932. /**
  78933. * Gets the name of the property to edit
  78934. */
  78935. propertyName: string;
  78936. /**
  78937. * Gets the type of the editor to use
  78938. */
  78939. type: InspectableType;
  78940. /**
  78941. * Gets the minimum value of the property when using in "slider" mode
  78942. */
  78943. min?: number;
  78944. /**
  78945. * Gets the maximum value of the property when using in "slider" mode
  78946. */
  78947. max?: number;
  78948. /**
  78949. * Gets the setp to use when using in "slider" mode
  78950. */
  78951. step?: number;
  78952. }
  78953. }
  78954. declare module BABYLON {
  78955. /**
  78956. * Class used to provide helper for timing
  78957. */
  78958. export class TimingTools {
  78959. /**
  78960. * Polyfill for setImmediate
  78961. * @param action defines the action to execute after the current execution block
  78962. */
  78963. static SetImmediate(action: () => void): void;
  78964. }
  78965. }
  78966. declare module BABYLON {
  78967. /**
  78968. * Class used to enable instatition of objects by class name
  78969. */
  78970. export class InstantiationTools {
  78971. /**
  78972. * Use this object to register external classes like custom textures or material
  78973. * to allow the laoders to instantiate them
  78974. */
  78975. static RegisteredExternalClasses: {
  78976. [key: string]: Object;
  78977. };
  78978. /**
  78979. * Tries to instantiate a new object from a given class name
  78980. * @param className defines the class name to instantiate
  78981. * @returns the new object or null if the system was not able to do the instantiation
  78982. */
  78983. static Instantiate(className: string): any;
  78984. }
  78985. }
  78986. declare module BABYLON {
  78987. /**
  78988. * Define options used to create a depth texture
  78989. */
  78990. export class DepthTextureCreationOptions {
  78991. /** Specifies whether or not a stencil should be allocated in the texture */
  78992. generateStencil?: boolean;
  78993. /** Specifies whether or not bilinear filtering is enable on the texture */
  78994. bilinearFiltering?: boolean;
  78995. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  78996. comparisonFunction?: number;
  78997. /** Specifies if the created texture is a cube texture */
  78998. isCube?: boolean;
  78999. }
  79000. }
  79001. declare module BABYLON {
  79002. interface ThinEngine {
  79003. /**
  79004. * Creates a depth stencil cube texture.
  79005. * This is only available in WebGL 2.
  79006. * @param size The size of face edge in the cube texture.
  79007. * @param options The options defining the cube texture.
  79008. * @returns The cube texture
  79009. */
  79010. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  79011. /**
  79012. * Creates a cube texture
  79013. * @param rootUrl defines the url where the files to load is located
  79014. * @param scene defines the current scene
  79015. * @param files defines the list of files to load (1 per face)
  79016. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  79017. * @param onLoad defines an optional callback raised when the texture is loaded
  79018. * @param onError defines an optional callback raised if there is an issue to load the texture
  79019. * @param format defines the format of the data
  79020. * @param forcedExtension defines the extension to use to pick the right loader
  79021. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  79022. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  79023. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  79024. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  79025. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  79026. * @returns the cube texture as an InternalTexture
  79027. */
  79028. 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;
  79029. /**
  79030. * Creates a cube texture
  79031. * @param rootUrl defines the url where the files to load is located
  79032. * @param scene defines the current scene
  79033. * @param files defines the list of files to load (1 per face)
  79034. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  79035. * @param onLoad defines an optional callback raised when the texture is loaded
  79036. * @param onError defines an optional callback raised if there is an issue to load the texture
  79037. * @param format defines the format of the data
  79038. * @param forcedExtension defines the extension to use to pick the right loader
  79039. * @returns the cube texture as an InternalTexture
  79040. */
  79041. 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;
  79042. /**
  79043. * Creates a cube texture
  79044. * @param rootUrl defines the url where the files to load is located
  79045. * @param scene defines the current scene
  79046. * @param files defines the list of files to load (1 per face)
  79047. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  79048. * @param onLoad defines an optional callback raised when the texture is loaded
  79049. * @param onError defines an optional callback raised if there is an issue to load the texture
  79050. * @param format defines the format of the data
  79051. * @param forcedExtension defines the extension to use to pick the right loader
  79052. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  79053. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  79054. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  79055. * @returns the cube texture as an InternalTexture
  79056. */
  79057. 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;
  79058. /** @hidden */
  79059. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  79060. /** @hidden */
  79061. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  79062. /** @hidden */
  79063. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  79064. /** @hidden */
  79065. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  79066. /**
  79067. * @hidden
  79068. */
  79069. _setCubeMapTextureParams(loadMipmap: boolean): void;
  79070. }
  79071. }
  79072. declare module BABYLON {
  79073. /**
  79074. * Class for creating a cube texture
  79075. */
  79076. export class CubeTexture extends BaseTexture {
  79077. private _delayedOnLoad;
  79078. /**
  79079. * The url of the texture
  79080. */
  79081. url: string;
  79082. /**
  79083. * Gets or sets the center of the bounding box associated with the cube texture.
  79084. * It must define where the camera used to render the texture was set
  79085. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  79086. */
  79087. boundingBoxPosition: Vector3;
  79088. private _boundingBoxSize;
  79089. /**
  79090. * Gets or sets the size of the bounding box associated with the cube texture
  79091. * When defined, the cubemap will switch to local mode
  79092. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  79093. * @example https://www.babylonjs-playground.com/#RNASML
  79094. */
  79095. set boundingBoxSize(value: Vector3);
  79096. /**
  79097. * Returns the bounding box size
  79098. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  79099. */
  79100. get boundingBoxSize(): Vector3;
  79101. protected _rotationY: number;
  79102. /**
  79103. * Sets texture matrix rotation angle around Y axis in radians.
  79104. */
  79105. set rotationY(value: number);
  79106. /**
  79107. * Gets texture matrix rotation angle around Y axis radians.
  79108. */
  79109. get rotationY(): number;
  79110. /**
  79111. * Are mip maps generated for this texture or not.
  79112. */
  79113. get noMipmap(): boolean;
  79114. private _noMipmap;
  79115. private _files;
  79116. protected _forcedExtension: Nullable<string>;
  79117. private _extensions;
  79118. private _textureMatrix;
  79119. private _format;
  79120. private _createPolynomials;
  79121. /** @hidden */
  79122. _prefiltered: boolean;
  79123. /**
  79124. * Creates a cube texture from an array of image urls
  79125. * @param files defines an array of image urls
  79126. * @param scene defines the hosting scene
  79127. * @param noMipmap specifies if mip maps are not used
  79128. * @returns a cube texture
  79129. */
  79130. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  79131. /**
  79132. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  79133. * @param url defines the url of the prefiltered texture
  79134. * @param scene defines the scene the texture is attached to
  79135. * @param forcedExtension defines the extension of the file if different from the url
  79136. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  79137. * @return the prefiltered texture
  79138. */
  79139. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  79140. /**
  79141. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  79142. * as prefiltered data.
  79143. * @param rootUrl defines the url of the texture or the root name of the six images
  79144. * @param scene defines the scene the texture is attached to
  79145. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  79146. * @param noMipmap defines if mipmaps should be created or not
  79147. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  79148. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  79149. * @param onError defines a callback triggered in case of error during load
  79150. * @param format defines the internal format to use for the texture once loaded
  79151. * @param prefiltered defines whether or not the texture is created from prefiltered data
  79152. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  79153. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  79154. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  79155. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  79156. * @return the cube texture
  79157. */
  79158. 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);
  79159. /**
  79160. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  79161. */
  79162. get isPrefiltered(): boolean;
  79163. /**
  79164. * Get the current class name of the texture useful for serialization or dynamic coding.
  79165. * @returns "CubeTexture"
  79166. */
  79167. getClassName(): string;
  79168. /**
  79169. * Update the url (and optional buffer) of this texture if url was null during construction.
  79170. * @param url the url of the texture
  79171. * @param forcedExtension defines the extension to use
  79172. * @param onLoad callback called when the texture is loaded (defaults to null)
  79173. * @param prefiltered Defines whether the updated texture is prefiltered or not
  79174. */
  79175. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  79176. /**
  79177. * Delays loading of the cube texture
  79178. * @param forcedExtension defines the extension to use
  79179. */
  79180. delayLoad(forcedExtension?: string): void;
  79181. /**
  79182. * Returns the reflection texture matrix
  79183. * @returns the reflection texture matrix
  79184. */
  79185. getReflectionTextureMatrix(): Matrix;
  79186. /**
  79187. * Sets the reflection texture matrix
  79188. * @param value Reflection texture matrix
  79189. */
  79190. setReflectionTextureMatrix(value: Matrix): void;
  79191. /**
  79192. * Parses text to create a cube texture
  79193. * @param parsedTexture define the serialized text to read from
  79194. * @param scene defines the hosting scene
  79195. * @param rootUrl defines the root url of the cube texture
  79196. * @returns a cube texture
  79197. */
  79198. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  79199. /**
  79200. * Makes a clone, or deep copy, of the cube texture
  79201. * @returns a new cube texture
  79202. */
  79203. clone(): CubeTexture;
  79204. }
  79205. }
  79206. declare module BABYLON {
  79207. /**
  79208. * Manages the defines for the Material
  79209. */
  79210. export class MaterialDefines {
  79211. /** @hidden */
  79212. protected _keys: string[];
  79213. private _isDirty;
  79214. /** @hidden */
  79215. _renderId: number;
  79216. /** @hidden */
  79217. _areLightsDirty: boolean;
  79218. /** @hidden */
  79219. _areLightsDisposed: boolean;
  79220. /** @hidden */
  79221. _areAttributesDirty: boolean;
  79222. /** @hidden */
  79223. _areTexturesDirty: boolean;
  79224. /** @hidden */
  79225. _areFresnelDirty: boolean;
  79226. /** @hidden */
  79227. _areMiscDirty: boolean;
  79228. /** @hidden */
  79229. _areImageProcessingDirty: boolean;
  79230. /** @hidden */
  79231. _normals: boolean;
  79232. /** @hidden */
  79233. _uvs: boolean;
  79234. /** @hidden */
  79235. _needNormals: boolean;
  79236. /** @hidden */
  79237. _needUVs: boolean;
  79238. [id: string]: any;
  79239. /**
  79240. * Specifies if the material needs to be re-calculated
  79241. */
  79242. get isDirty(): boolean;
  79243. /**
  79244. * Marks the material to indicate that it has been re-calculated
  79245. */
  79246. markAsProcessed(): void;
  79247. /**
  79248. * Marks the material to indicate that it needs to be re-calculated
  79249. */
  79250. markAsUnprocessed(): void;
  79251. /**
  79252. * Marks the material to indicate all of its defines need to be re-calculated
  79253. */
  79254. markAllAsDirty(): void;
  79255. /**
  79256. * Marks the material to indicate that image processing needs to be re-calculated
  79257. */
  79258. markAsImageProcessingDirty(): void;
  79259. /**
  79260. * Marks the material to indicate the lights need to be re-calculated
  79261. * @param disposed Defines whether the light is dirty due to dispose or not
  79262. */
  79263. markAsLightDirty(disposed?: boolean): void;
  79264. /**
  79265. * Marks the attribute state as changed
  79266. */
  79267. markAsAttributesDirty(): void;
  79268. /**
  79269. * Marks the texture state as changed
  79270. */
  79271. markAsTexturesDirty(): void;
  79272. /**
  79273. * Marks the fresnel state as changed
  79274. */
  79275. markAsFresnelDirty(): void;
  79276. /**
  79277. * Marks the misc state as changed
  79278. */
  79279. markAsMiscDirty(): void;
  79280. /**
  79281. * Rebuilds the material defines
  79282. */
  79283. rebuild(): void;
  79284. /**
  79285. * Specifies if two material defines are equal
  79286. * @param other - A material define instance to compare to
  79287. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  79288. */
  79289. isEqual(other: MaterialDefines): boolean;
  79290. /**
  79291. * Clones this instance's defines to another instance
  79292. * @param other - material defines to clone values to
  79293. */
  79294. cloneTo(other: MaterialDefines): void;
  79295. /**
  79296. * Resets the material define values
  79297. */
  79298. reset(): void;
  79299. /**
  79300. * Converts the material define values to a string
  79301. * @returns - String of material define information
  79302. */
  79303. toString(): string;
  79304. }
  79305. }
  79306. declare module BABYLON {
  79307. /**
  79308. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  79309. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  79310. * 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;
  79311. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  79312. */
  79313. export class ColorCurves {
  79314. private _dirty;
  79315. private _tempColor;
  79316. private _globalCurve;
  79317. private _highlightsCurve;
  79318. private _midtonesCurve;
  79319. private _shadowsCurve;
  79320. private _positiveCurve;
  79321. private _negativeCurve;
  79322. private _globalHue;
  79323. private _globalDensity;
  79324. private _globalSaturation;
  79325. private _globalExposure;
  79326. /**
  79327. * Gets the global Hue value.
  79328. * 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).
  79329. */
  79330. get globalHue(): number;
  79331. /**
  79332. * Sets the global Hue value.
  79333. * 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).
  79334. */
  79335. set globalHue(value: number);
  79336. /**
  79337. * Gets the global Density value.
  79338. * 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.
  79339. * Values less than zero provide a filter of opposite hue.
  79340. */
  79341. get globalDensity(): number;
  79342. /**
  79343. * Sets the global Density value.
  79344. * 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.
  79345. * Values less than zero provide a filter of opposite hue.
  79346. */
  79347. set globalDensity(value: number);
  79348. /**
  79349. * Gets the global Saturation value.
  79350. * 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.
  79351. */
  79352. get globalSaturation(): number;
  79353. /**
  79354. * Sets the global Saturation value.
  79355. * 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.
  79356. */
  79357. set globalSaturation(value: number);
  79358. /**
  79359. * Gets the global Exposure value.
  79360. * 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.
  79361. */
  79362. get globalExposure(): number;
  79363. /**
  79364. * Sets the global Exposure value.
  79365. * 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.
  79366. */
  79367. set globalExposure(value: number);
  79368. private _highlightsHue;
  79369. private _highlightsDensity;
  79370. private _highlightsSaturation;
  79371. private _highlightsExposure;
  79372. /**
  79373. * Gets the highlights Hue value.
  79374. * 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).
  79375. */
  79376. get highlightsHue(): number;
  79377. /**
  79378. * Sets the highlights Hue value.
  79379. * 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).
  79380. */
  79381. set highlightsHue(value: number);
  79382. /**
  79383. * Gets the highlights Density value.
  79384. * 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.
  79385. * Values less than zero provide a filter of opposite hue.
  79386. */
  79387. get highlightsDensity(): number;
  79388. /**
  79389. * Sets the highlights Density value.
  79390. * 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.
  79391. * Values less than zero provide a filter of opposite hue.
  79392. */
  79393. set highlightsDensity(value: number);
  79394. /**
  79395. * Gets the highlights Saturation value.
  79396. * 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.
  79397. */
  79398. get highlightsSaturation(): number;
  79399. /**
  79400. * Sets the highlights Saturation value.
  79401. * 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.
  79402. */
  79403. set highlightsSaturation(value: number);
  79404. /**
  79405. * Gets the highlights Exposure value.
  79406. * 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.
  79407. */
  79408. get highlightsExposure(): number;
  79409. /**
  79410. * Sets the highlights Exposure value.
  79411. * 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.
  79412. */
  79413. set highlightsExposure(value: number);
  79414. private _midtonesHue;
  79415. private _midtonesDensity;
  79416. private _midtonesSaturation;
  79417. private _midtonesExposure;
  79418. /**
  79419. * Gets the midtones Hue value.
  79420. * 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).
  79421. */
  79422. get midtonesHue(): number;
  79423. /**
  79424. * Sets the midtones Hue value.
  79425. * 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).
  79426. */
  79427. set midtonesHue(value: number);
  79428. /**
  79429. * Gets the midtones Density value.
  79430. * 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.
  79431. * Values less than zero provide a filter of opposite hue.
  79432. */
  79433. get midtonesDensity(): number;
  79434. /**
  79435. * Sets the midtones Density value.
  79436. * 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.
  79437. * Values less than zero provide a filter of opposite hue.
  79438. */
  79439. set midtonesDensity(value: number);
  79440. /**
  79441. * Gets the midtones Saturation value.
  79442. * 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.
  79443. */
  79444. get midtonesSaturation(): number;
  79445. /**
  79446. * Sets the midtones Saturation value.
  79447. * 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.
  79448. */
  79449. set midtonesSaturation(value: number);
  79450. /**
  79451. * Gets the midtones Exposure value.
  79452. * 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.
  79453. */
  79454. get midtonesExposure(): number;
  79455. /**
  79456. * Sets the midtones Exposure value.
  79457. * 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.
  79458. */
  79459. set midtonesExposure(value: number);
  79460. private _shadowsHue;
  79461. private _shadowsDensity;
  79462. private _shadowsSaturation;
  79463. private _shadowsExposure;
  79464. /**
  79465. * Gets the shadows Hue value.
  79466. * 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).
  79467. */
  79468. get shadowsHue(): number;
  79469. /**
  79470. * Sets the shadows Hue value.
  79471. * 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).
  79472. */
  79473. set shadowsHue(value: number);
  79474. /**
  79475. * Gets the shadows Density value.
  79476. * 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.
  79477. * Values less than zero provide a filter of opposite hue.
  79478. */
  79479. get shadowsDensity(): number;
  79480. /**
  79481. * Sets the shadows Density value.
  79482. * 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.
  79483. * Values less than zero provide a filter of opposite hue.
  79484. */
  79485. set shadowsDensity(value: number);
  79486. /**
  79487. * Gets the shadows Saturation value.
  79488. * 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.
  79489. */
  79490. get shadowsSaturation(): number;
  79491. /**
  79492. * Sets the shadows Saturation value.
  79493. * 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.
  79494. */
  79495. set shadowsSaturation(value: number);
  79496. /**
  79497. * Gets the shadows Exposure value.
  79498. * 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.
  79499. */
  79500. get shadowsExposure(): number;
  79501. /**
  79502. * Sets the shadows Exposure value.
  79503. * 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.
  79504. */
  79505. set shadowsExposure(value: number);
  79506. /**
  79507. * Returns the class name
  79508. * @returns The class name
  79509. */
  79510. getClassName(): string;
  79511. /**
  79512. * Binds the color curves to the shader.
  79513. * @param colorCurves The color curve to bind
  79514. * @param effect The effect to bind to
  79515. * @param positiveUniform The positive uniform shader parameter
  79516. * @param neutralUniform The neutral uniform shader parameter
  79517. * @param negativeUniform The negative uniform shader parameter
  79518. */
  79519. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  79520. /**
  79521. * Prepare the list of uniforms associated with the ColorCurves effects.
  79522. * @param uniformsList The list of uniforms used in the effect
  79523. */
  79524. static PrepareUniforms(uniformsList: string[]): void;
  79525. /**
  79526. * Returns color grading data based on a hue, density, saturation and exposure value.
  79527. * @param filterHue The hue of the color filter.
  79528. * @param filterDensity The density of the color filter.
  79529. * @param saturation The saturation.
  79530. * @param exposure The exposure.
  79531. * @param result The result data container.
  79532. */
  79533. private getColorGradingDataToRef;
  79534. /**
  79535. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  79536. * @param value The input slider value in range [-100,100].
  79537. * @returns Adjusted value.
  79538. */
  79539. private static applyColorGradingSliderNonlinear;
  79540. /**
  79541. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  79542. * @param hue The hue (H) input.
  79543. * @param saturation The saturation (S) input.
  79544. * @param brightness The brightness (B) input.
  79545. * @result An RGBA color represented as Vector4.
  79546. */
  79547. private static fromHSBToRef;
  79548. /**
  79549. * Returns a value clamped between min and max
  79550. * @param value The value to clamp
  79551. * @param min The minimum of value
  79552. * @param max The maximum of value
  79553. * @returns The clamped value.
  79554. */
  79555. private static clamp;
  79556. /**
  79557. * Clones the current color curve instance.
  79558. * @return The cloned curves
  79559. */
  79560. clone(): ColorCurves;
  79561. /**
  79562. * Serializes the current color curve instance to a json representation.
  79563. * @return a JSON representation
  79564. */
  79565. serialize(): any;
  79566. /**
  79567. * Parses the color curve from a json representation.
  79568. * @param source the JSON source to parse
  79569. * @return The parsed curves
  79570. */
  79571. static Parse(source: any): ColorCurves;
  79572. }
  79573. }
  79574. declare module BABYLON {
  79575. /**
  79576. * Interface to follow in your material defines to integrate easily the
  79577. * Image proccessing functions.
  79578. * @hidden
  79579. */
  79580. export interface IImageProcessingConfigurationDefines {
  79581. IMAGEPROCESSING: boolean;
  79582. VIGNETTE: boolean;
  79583. VIGNETTEBLENDMODEMULTIPLY: boolean;
  79584. VIGNETTEBLENDMODEOPAQUE: boolean;
  79585. TONEMAPPING: boolean;
  79586. TONEMAPPING_ACES: boolean;
  79587. CONTRAST: boolean;
  79588. EXPOSURE: boolean;
  79589. COLORCURVES: boolean;
  79590. COLORGRADING: boolean;
  79591. COLORGRADING3D: boolean;
  79592. SAMPLER3DGREENDEPTH: boolean;
  79593. SAMPLER3DBGRMAP: boolean;
  79594. IMAGEPROCESSINGPOSTPROCESS: boolean;
  79595. }
  79596. /**
  79597. * @hidden
  79598. */
  79599. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  79600. IMAGEPROCESSING: boolean;
  79601. VIGNETTE: boolean;
  79602. VIGNETTEBLENDMODEMULTIPLY: boolean;
  79603. VIGNETTEBLENDMODEOPAQUE: boolean;
  79604. TONEMAPPING: boolean;
  79605. TONEMAPPING_ACES: boolean;
  79606. CONTRAST: boolean;
  79607. COLORCURVES: boolean;
  79608. COLORGRADING: boolean;
  79609. COLORGRADING3D: boolean;
  79610. SAMPLER3DGREENDEPTH: boolean;
  79611. SAMPLER3DBGRMAP: boolean;
  79612. IMAGEPROCESSINGPOSTPROCESS: boolean;
  79613. EXPOSURE: boolean;
  79614. constructor();
  79615. }
  79616. /**
  79617. * This groups together the common properties used for image processing either in direct forward pass
  79618. * or through post processing effect depending on the use of the image processing pipeline in your scene
  79619. * or not.
  79620. */
  79621. export class ImageProcessingConfiguration {
  79622. /**
  79623. * Default tone mapping applied in BabylonJS.
  79624. */
  79625. static readonly TONEMAPPING_STANDARD: number;
  79626. /**
  79627. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  79628. * to other engines rendering to increase portability.
  79629. */
  79630. static readonly TONEMAPPING_ACES: number;
  79631. /**
  79632. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  79633. */
  79634. colorCurves: Nullable<ColorCurves>;
  79635. private _colorCurvesEnabled;
  79636. /**
  79637. * Gets wether the color curves effect is enabled.
  79638. */
  79639. get colorCurvesEnabled(): boolean;
  79640. /**
  79641. * Sets wether the color curves effect is enabled.
  79642. */
  79643. set colorCurvesEnabled(value: boolean);
  79644. private _colorGradingTexture;
  79645. /**
  79646. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  79647. */
  79648. get colorGradingTexture(): Nullable<BaseTexture>;
  79649. /**
  79650. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  79651. */
  79652. set colorGradingTexture(value: Nullable<BaseTexture>);
  79653. private _colorGradingEnabled;
  79654. /**
  79655. * Gets wether the color grading effect is enabled.
  79656. */
  79657. get colorGradingEnabled(): boolean;
  79658. /**
  79659. * Sets wether the color grading effect is enabled.
  79660. */
  79661. set colorGradingEnabled(value: boolean);
  79662. private _colorGradingWithGreenDepth;
  79663. /**
  79664. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  79665. */
  79666. get colorGradingWithGreenDepth(): boolean;
  79667. /**
  79668. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  79669. */
  79670. set colorGradingWithGreenDepth(value: boolean);
  79671. private _colorGradingBGR;
  79672. /**
  79673. * Gets wether the color grading texture contains BGR values.
  79674. */
  79675. get colorGradingBGR(): boolean;
  79676. /**
  79677. * Sets wether the color grading texture contains BGR values.
  79678. */
  79679. set colorGradingBGR(value: boolean);
  79680. /** @hidden */
  79681. _exposure: number;
  79682. /**
  79683. * Gets the Exposure used in the effect.
  79684. */
  79685. get exposure(): number;
  79686. /**
  79687. * Sets the Exposure used in the effect.
  79688. */
  79689. set exposure(value: number);
  79690. private _toneMappingEnabled;
  79691. /**
  79692. * Gets wether the tone mapping effect is enabled.
  79693. */
  79694. get toneMappingEnabled(): boolean;
  79695. /**
  79696. * Sets wether the tone mapping effect is enabled.
  79697. */
  79698. set toneMappingEnabled(value: boolean);
  79699. private _toneMappingType;
  79700. /**
  79701. * Gets the type of tone mapping effect.
  79702. */
  79703. get toneMappingType(): number;
  79704. /**
  79705. * Sets the type of tone mapping effect used in BabylonJS.
  79706. */
  79707. set toneMappingType(value: number);
  79708. protected _contrast: number;
  79709. /**
  79710. * Gets the contrast used in the effect.
  79711. */
  79712. get contrast(): number;
  79713. /**
  79714. * Sets the contrast used in the effect.
  79715. */
  79716. set contrast(value: number);
  79717. /**
  79718. * Vignette stretch size.
  79719. */
  79720. vignetteStretch: number;
  79721. /**
  79722. * Vignette centre X Offset.
  79723. */
  79724. vignetteCentreX: number;
  79725. /**
  79726. * Vignette centre Y Offset.
  79727. */
  79728. vignetteCentreY: number;
  79729. /**
  79730. * Vignette weight or intensity of the vignette effect.
  79731. */
  79732. vignetteWeight: number;
  79733. /**
  79734. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  79735. * if vignetteEnabled is set to true.
  79736. */
  79737. vignetteColor: Color4;
  79738. /**
  79739. * Camera field of view used by the Vignette effect.
  79740. */
  79741. vignetteCameraFov: number;
  79742. private _vignetteBlendMode;
  79743. /**
  79744. * Gets the vignette blend mode allowing different kind of effect.
  79745. */
  79746. get vignetteBlendMode(): number;
  79747. /**
  79748. * Sets the vignette blend mode allowing different kind of effect.
  79749. */
  79750. set vignetteBlendMode(value: number);
  79751. private _vignetteEnabled;
  79752. /**
  79753. * Gets wether the vignette effect is enabled.
  79754. */
  79755. get vignetteEnabled(): boolean;
  79756. /**
  79757. * Sets wether the vignette effect is enabled.
  79758. */
  79759. set vignetteEnabled(value: boolean);
  79760. private _applyByPostProcess;
  79761. /**
  79762. * Gets wether the image processing is applied through a post process or not.
  79763. */
  79764. get applyByPostProcess(): boolean;
  79765. /**
  79766. * Sets wether the image processing is applied through a post process or not.
  79767. */
  79768. set applyByPostProcess(value: boolean);
  79769. private _isEnabled;
  79770. /**
  79771. * Gets wether the image processing is enabled or not.
  79772. */
  79773. get isEnabled(): boolean;
  79774. /**
  79775. * Sets wether the image processing is enabled or not.
  79776. */
  79777. set isEnabled(value: boolean);
  79778. /**
  79779. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  79780. */
  79781. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  79782. /**
  79783. * Method called each time the image processing information changes requires to recompile the effect.
  79784. */
  79785. protected _updateParameters(): void;
  79786. /**
  79787. * Gets the current class name.
  79788. * @return "ImageProcessingConfiguration"
  79789. */
  79790. getClassName(): string;
  79791. /**
  79792. * Prepare the list of uniforms associated with the Image Processing effects.
  79793. * @param uniforms The list of uniforms used in the effect
  79794. * @param defines the list of defines currently in use
  79795. */
  79796. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  79797. /**
  79798. * Prepare the list of samplers associated with the Image Processing effects.
  79799. * @param samplersList The list of uniforms used in the effect
  79800. * @param defines the list of defines currently in use
  79801. */
  79802. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  79803. /**
  79804. * Prepare the list of defines associated to the shader.
  79805. * @param defines the list of defines to complete
  79806. * @param forPostProcess Define if we are currently in post process mode or not
  79807. */
  79808. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  79809. /**
  79810. * Returns true if all the image processing information are ready.
  79811. * @returns True if ready, otherwise, false
  79812. */
  79813. isReady(): boolean;
  79814. /**
  79815. * Binds the image processing to the shader.
  79816. * @param effect The effect to bind to
  79817. * @param overrideAspectRatio Override the aspect ratio of the effect
  79818. */
  79819. bind(effect: Effect, overrideAspectRatio?: number): void;
  79820. /**
  79821. * Clones the current image processing instance.
  79822. * @return The cloned image processing
  79823. */
  79824. clone(): ImageProcessingConfiguration;
  79825. /**
  79826. * Serializes the current image processing instance to a json representation.
  79827. * @return a JSON representation
  79828. */
  79829. serialize(): any;
  79830. /**
  79831. * Parses the image processing from a json representation.
  79832. * @param source the JSON source to parse
  79833. * @return The parsed image processing
  79834. */
  79835. static Parse(source: any): ImageProcessingConfiguration;
  79836. private static _VIGNETTEMODE_MULTIPLY;
  79837. private static _VIGNETTEMODE_OPAQUE;
  79838. /**
  79839. * Used to apply the vignette as a mix with the pixel color.
  79840. */
  79841. static get VIGNETTEMODE_MULTIPLY(): number;
  79842. /**
  79843. * Used to apply the vignette as a replacement of the pixel color.
  79844. */
  79845. static get VIGNETTEMODE_OPAQUE(): number;
  79846. }
  79847. }
  79848. declare module BABYLON {
  79849. /** @hidden */
  79850. export var postprocessVertexShader: {
  79851. name: string;
  79852. shader: string;
  79853. };
  79854. }
  79855. declare module BABYLON {
  79856. interface ThinEngine {
  79857. /**
  79858. * Creates a new render target texture
  79859. * @param size defines the size of the texture
  79860. * @param options defines the options used to create the texture
  79861. * @returns a new render target texture stored in an InternalTexture
  79862. */
  79863. createRenderTargetTexture(size: number | {
  79864. width: number;
  79865. height: number;
  79866. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  79867. /**
  79868. * Creates a depth stencil texture.
  79869. * This is only available in WebGL 2 or with the depth texture extension available.
  79870. * @param size The size of face edge in the texture.
  79871. * @param options The options defining the texture.
  79872. * @returns The texture
  79873. */
  79874. createDepthStencilTexture(size: number | {
  79875. width: number;
  79876. height: number;
  79877. }, options: DepthTextureCreationOptions): InternalTexture;
  79878. /** @hidden */
  79879. _createDepthStencilTexture(size: number | {
  79880. width: number;
  79881. height: number;
  79882. }, options: DepthTextureCreationOptions): InternalTexture;
  79883. }
  79884. }
  79885. declare module BABYLON {
  79886. /** Defines supported spaces */
  79887. export enum Space {
  79888. /** Local (object) space */
  79889. LOCAL = 0,
  79890. /** World space */
  79891. WORLD = 1,
  79892. /** Bone space */
  79893. BONE = 2
  79894. }
  79895. /** Defines the 3 main axes */
  79896. export class Axis {
  79897. /** X axis */
  79898. static X: Vector3;
  79899. /** Y axis */
  79900. static Y: Vector3;
  79901. /** Z axis */
  79902. static Z: Vector3;
  79903. }
  79904. }
  79905. declare module BABYLON {
  79906. /**
  79907. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  79908. * This is the base of the follow, arc rotate cameras and Free camera
  79909. * @see http://doc.babylonjs.com/features/cameras
  79910. */
  79911. export class TargetCamera extends Camera {
  79912. private static _RigCamTransformMatrix;
  79913. private static _TargetTransformMatrix;
  79914. private static _TargetFocalPoint;
  79915. /**
  79916. * Define the current direction the camera is moving to
  79917. */
  79918. cameraDirection: Vector3;
  79919. /**
  79920. * Define the current rotation the camera is rotating to
  79921. */
  79922. cameraRotation: Vector2;
  79923. /**
  79924. * When set, the up vector of the camera will be updated by the rotation of the camera
  79925. */
  79926. updateUpVectorFromRotation: boolean;
  79927. private _tmpQuaternion;
  79928. /**
  79929. * Define the current rotation of the camera
  79930. */
  79931. rotation: Vector3;
  79932. /**
  79933. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  79934. */
  79935. rotationQuaternion: Quaternion;
  79936. /**
  79937. * Define the current speed of the camera
  79938. */
  79939. speed: number;
  79940. /**
  79941. * Add constraint to the camera to prevent it to move freely in all directions and
  79942. * around all axis.
  79943. */
  79944. noRotationConstraint: boolean;
  79945. /**
  79946. * Define the current target of the camera as an object or a position.
  79947. */
  79948. lockedTarget: any;
  79949. /** @hidden */
  79950. _currentTarget: Vector3;
  79951. /** @hidden */
  79952. _initialFocalDistance: number;
  79953. /** @hidden */
  79954. _viewMatrix: Matrix;
  79955. /** @hidden */
  79956. _camMatrix: Matrix;
  79957. /** @hidden */
  79958. _cameraTransformMatrix: Matrix;
  79959. /** @hidden */
  79960. _cameraRotationMatrix: Matrix;
  79961. /** @hidden */
  79962. _referencePoint: Vector3;
  79963. /** @hidden */
  79964. _transformedReferencePoint: Vector3;
  79965. protected _globalCurrentTarget: Vector3;
  79966. protected _globalCurrentUpVector: Vector3;
  79967. /** @hidden */
  79968. _reset: () => void;
  79969. private _defaultUp;
  79970. /**
  79971. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  79972. * This is the base of the follow, arc rotate cameras and Free camera
  79973. * @see http://doc.babylonjs.com/features/cameras
  79974. * @param name Defines the name of the camera in the scene
  79975. * @param position Defines the start position of the camera in the scene
  79976. * @param scene Defines the scene the camera belongs to
  79977. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79978. */
  79979. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79980. /**
  79981. * Gets the position in front of the camera at a given distance.
  79982. * @param distance The distance from the camera we want the position to be
  79983. * @returns the position
  79984. */
  79985. getFrontPosition(distance: number): Vector3;
  79986. /** @hidden */
  79987. _getLockedTargetPosition(): Nullable<Vector3>;
  79988. private _storedPosition;
  79989. private _storedRotation;
  79990. private _storedRotationQuaternion;
  79991. /**
  79992. * Store current camera state of the camera (fov, position, rotation, etc..)
  79993. * @returns the camera
  79994. */
  79995. storeState(): Camera;
  79996. /**
  79997. * Restored camera state. You must call storeState() first
  79998. * @returns whether it was successful or not
  79999. * @hidden
  80000. */
  80001. _restoreStateValues(): boolean;
  80002. /** @hidden */
  80003. _initCache(): void;
  80004. /** @hidden */
  80005. _updateCache(ignoreParentClass?: boolean): void;
  80006. /** @hidden */
  80007. _isSynchronizedViewMatrix(): boolean;
  80008. /** @hidden */
  80009. _computeLocalCameraSpeed(): number;
  80010. /**
  80011. * Defines the target the camera should look at.
  80012. * @param target Defines the new target as a Vector or a mesh
  80013. */
  80014. setTarget(target: Vector3): void;
  80015. /**
  80016. * Return the current target position of the camera. This value is expressed in local space.
  80017. * @returns the target position
  80018. */
  80019. getTarget(): Vector3;
  80020. /** @hidden */
  80021. _decideIfNeedsToMove(): boolean;
  80022. /** @hidden */
  80023. _updatePosition(): void;
  80024. /** @hidden */
  80025. _checkInputs(): void;
  80026. protected _updateCameraRotationMatrix(): void;
  80027. /**
  80028. * 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)
  80029. * @returns the current camera
  80030. */
  80031. private _rotateUpVectorWithCameraRotationMatrix;
  80032. private _cachedRotationZ;
  80033. private _cachedQuaternionRotationZ;
  80034. /** @hidden */
  80035. _getViewMatrix(): Matrix;
  80036. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  80037. /**
  80038. * @hidden
  80039. */
  80040. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  80041. /**
  80042. * @hidden
  80043. */
  80044. _updateRigCameras(): void;
  80045. private _getRigCamPositionAndTarget;
  80046. /**
  80047. * Gets the current object class name.
  80048. * @return the class name
  80049. */
  80050. getClassName(): string;
  80051. }
  80052. }
  80053. declare module BABYLON {
  80054. /**
  80055. * Gather the list of keyboard event types as constants.
  80056. */
  80057. export class KeyboardEventTypes {
  80058. /**
  80059. * The keydown event is fired when a key becomes active (pressed).
  80060. */
  80061. static readonly KEYDOWN: number;
  80062. /**
  80063. * The keyup event is fired when a key has been released.
  80064. */
  80065. static readonly KEYUP: number;
  80066. }
  80067. /**
  80068. * This class is used to store keyboard related info for the onKeyboardObservable event.
  80069. */
  80070. export class KeyboardInfo {
  80071. /**
  80072. * Defines the type of event (KeyboardEventTypes)
  80073. */
  80074. type: number;
  80075. /**
  80076. * Defines the related dom event
  80077. */
  80078. event: KeyboardEvent;
  80079. /**
  80080. * Instantiates a new keyboard info.
  80081. * This class is used to store keyboard related info for the onKeyboardObservable event.
  80082. * @param type Defines the type of event (KeyboardEventTypes)
  80083. * @param event Defines the related dom event
  80084. */
  80085. constructor(
  80086. /**
  80087. * Defines the type of event (KeyboardEventTypes)
  80088. */
  80089. type: number,
  80090. /**
  80091. * Defines the related dom event
  80092. */
  80093. event: KeyboardEvent);
  80094. }
  80095. /**
  80096. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  80097. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  80098. */
  80099. export class KeyboardInfoPre extends KeyboardInfo {
  80100. /**
  80101. * Defines the type of event (KeyboardEventTypes)
  80102. */
  80103. type: number;
  80104. /**
  80105. * Defines the related dom event
  80106. */
  80107. event: KeyboardEvent;
  80108. /**
  80109. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  80110. */
  80111. skipOnPointerObservable: boolean;
  80112. /**
  80113. * Instantiates a new keyboard pre info.
  80114. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  80115. * @param type Defines the type of event (KeyboardEventTypes)
  80116. * @param event Defines the related dom event
  80117. */
  80118. constructor(
  80119. /**
  80120. * Defines the type of event (KeyboardEventTypes)
  80121. */
  80122. type: number,
  80123. /**
  80124. * Defines the related dom event
  80125. */
  80126. event: KeyboardEvent);
  80127. }
  80128. }
  80129. declare module BABYLON {
  80130. /**
  80131. * Manage the keyboard inputs to control the movement of a free camera.
  80132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80133. */
  80134. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  80135. /**
  80136. * Defines the camera the input is attached to.
  80137. */
  80138. camera: FreeCamera;
  80139. /**
  80140. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80141. */
  80142. keysUp: number[];
  80143. /**
  80144. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80145. */
  80146. keysDown: number[];
  80147. /**
  80148. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80149. */
  80150. keysLeft: number[];
  80151. /**
  80152. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80153. */
  80154. keysRight: number[];
  80155. private _keys;
  80156. private _onCanvasBlurObserver;
  80157. private _onKeyboardObserver;
  80158. private _engine;
  80159. private _scene;
  80160. /**
  80161. * Attach the input controls to a specific dom element to get the input from.
  80162. * @param element Defines the element the controls should be listened from
  80163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80164. */
  80165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80166. /**
  80167. * Detach the current controls from the specified dom element.
  80168. * @param element Defines the element to stop listening the inputs from
  80169. */
  80170. detachControl(element: Nullable<HTMLElement>): void;
  80171. /**
  80172. * Update the current camera state depending on the inputs that have been used this frame.
  80173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80174. */
  80175. checkInputs(): void;
  80176. /**
  80177. * Gets the class name of the current intput.
  80178. * @returns the class name
  80179. */
  80180. getClassName(): string;
  80181. /** @hidden */
  80182. _onLostFocus(): void;
  80183. /**
  80184. * Get the friendly name associated with the input class.
  80185. * @returns the input friendly name
  80186. */
  80187. getSimpleName(): string;
  80188. }
  80189. }
  80190. declare module BABYLON {
  80191. /**
  80192. * Interface describing all the common properties and methods a shadow light needs to implement.
  80193. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  80194. * as well as binding the different shadow properties to the effects.
  80195. */
  80196. export interface IShadowLight extends Light {
  80197. /**
  80198. * The light id in the scene (used in scene.findLighById for instance)
  80199. */
  80200. id: string;
  80201. /**
  80202. * The position the shdow will be casted from.
  80203. */
  80204. position: Vector3;
  80205. /**
  80206. * In 2d mode (needCube being false), the direction used to cast the shadow.
  80207. */
  80208. direction: Vector3;
  80209. /**
  80210. * The transformed position. Position of the light in world space taking parenting in account.
  80211. */
  80212. transformedPosition: Vector3;
  80213. /**
  80214. * The transformed direction. Direction of the light in world space taking parenting in account.
  80215. */
  80216. transformedDirection: Vector3;
  80217. /**
  80218. * The friendly name of the light in the scene.
  80219. */
  80220. name: string;
  80221. /**
  80222. * Defines the shadow projection clipping minimum z value.
  80223. */
  80224. shadowMinZ: number;
  80225. /**
  80226. * Defines the shadow projection clipping maximum z value.
  80227. */
  80228. shadowMaxZ: number;
  80229. /**
  80230. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  80231. * @returns true if the information has been computed, false if it does not need to (no parenting)
  80232. */
  80233. computeTransformedInformation(): boolean;
  80234. /**
  80235. * Gets the scene the light belongs to.
  80236. * @returns The scene
  80237. */
  80238. getScene(): Scene;
  80239. /**
  80240. * Callback defining a custom Projection Matrix Builder.
  80241. * This can be used to override the default projection matrix computation.
  80242. */
  80243. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  80244. /**
  80245. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  80246. * @param matrix The materix to updated with the projection information
  80247. * @param viewMatrix The transform matrix of the light
  80248. * @param renderList The list of mesh to render in the map
  80249. * @returns The current light
  80250. */
  80251. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  80252. /**
  80253. * Gets the current depth scale used in ESM.
  80254. * @returns The scale
  80255. */
  80256. getDepthScale(): number;
  80257. /**
  80258. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  80259. * @returns true if a cube texture needs to be use
  80260. */
  80261. needCube(): boolean;
  80262. /**
  80263. * Detects if the projection matrix requires to be recomputed this frame.
  80264. * @returns true if it requires to be recomputed otherwise, false.
  80265. */
  80266. needProjectionMatrixCompute(): boolean;
  80267. /**
  80268. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  80269. */
  80270. forceProjectionMatrixCompute(): void;
  80271. /**
  80272. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  80273. * @param faceIndex The index of the face we are computed the direction to generate shadow
  80274. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  80275. */
  80276. getShadowDirection(faceIndex?: number): Vector3;
  80277. /**
  80278. * Gets the minZ used for shadow according to both the scene and the light.
  80279. * @param activeCamera The camera we are returning the min for
  80280. * @returns the depth min z
  80281. */
  80282. getDepthMinZ(activeCamera: Camera): number;
  80283. /**
  80284. * Gets the maxZ used for shadow according to both the scene and the light.
  80285. * @param activeCamera The camera we are returning the max for
  80286. * @returns the depth max z
  80287. */
  80288. getDepthMaxZ(activeCamera: Camera): number;
  80289. }
  80290. /**
  80291. * Base implementation IShadowLight
  80292. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  80293. */
  80294. export abstract class ShadowLight extends Light implements IShadowLight {
  80295. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  80296. protected _position: Vector3;
  80297. protected _setPosition(value: Vector3): void;
  80298. /**
  80299. * Sets the position the shadow will be casted from. Also use as the light position for both
  80300. * point and spot lights.
  80301. */
  80302. get position(): Vector3;
  80303. /**
  80304. * Sets the position the shadow will be casted from. Also use as the light position for both
  80305. * point and spot lights.
  80306. */
  80307. set position(value: Vector3);
  80308. protected _direction: Vector3;
  80309. protected _setDirection(value: Vector3): void;
  80310. /**
  80311. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  80312. * Also use as the light direction on spot and directional lights.
  80313. */
  80314. get direction(): Vector3;
  80315. /**
  80316. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  80317. * Also use as the light direction on spot and directional lights.
  80318. */
  80319. set direction(value: Vector3);
  80320. protected _shadowMinZ: number;
  80321. /**
  80322. * Gets the shadow projection clipping minimum z value.
  80323. */
  80324. get shadowMinZ(): number;
  80325. /**
  80326. * Sets the shadow projection clipping minimum z value.
  80327. */
  80328. set shadowMinZ(value: number);
  80329. protected _shadowMaxZ: number;
  80330. /**
  80331. * Sets the shadow projection clipping maximum z value.
  80332. */
  80333. get shadowMaxZ(): number;
  80334. /**
  80335. * Gets the shadow projection clipping maximum z value.
  80336. */
  80337. set shadowMaxZ(value: number);
  80338. /**
  80339. * Callback defining a custom Projection Matrix Builder.
  80340. * This can be used to override the default projection matrix computation.
  80341. */
  80342. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  80343. /**
  80344. * The transformed position. Position of the light in world space taking parenting in account.
  80345. */
  80346. transformedPosition: Vector3;
  80347. /**
  80348. * The transformed direction. Direction of the light in world space taking parenting in account.
  80349. */
  80350. transformedDirection: Vector3;
  80351. private _needProjectionMatrixCompute;
  80352. /**
  80353. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  80354. * @returns true if the information has been computed, false if it does not need to (no parenting)
  80355. */
  80356. computeTransformedInformation(): boolean;
  80357. /**
  80358. * Return the depth scale used for the shadow map.
  80359. * @returns the depth scale.
  80360. */
  80361. getDepthScale(): number;
  80362. /**
  80363. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  80364. * @param faceIndex The index of the face we are computed the direction to generate shadow
  80365. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  80366. */
  80367. getShadowDirection(faceIndex?: number): Vector3;
  80368. /**
  80369. * Returns the ShadowLight absolute position in the World.
  80370. * @returns the position vector in world space
  80371. */
  80372. getAbsolutePosition(): Vector3;
  80373. /**
  80374. * Sets the ShadowLight direction toward the passed target.
  80375. * @param target The point to target in local space
  80376. * @returns the updated ShadowLight direction
  80377. */
  80378. setDirectionToTarget(target: Vector3): Vector3;
  80379. /**
  80380. * Returns the light rotation in euler definition.
  80381. * @returns the x y z rotation in local space.
  80382. */
  80383. getRotation(): Vector3;
  80384. /**
  80385. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  80386. * @returns true if a cube texture needs to be use
  80387. */
  80388. needCube(): boolean;
  80389. /**
  80390. * Detects if the projection matrix requires to be recomputed this frame.
  80391. * @returns true if it requires to be recomputed otherwise, false.
  80392. */
  80393. needProjectionMatrixCompute(): boolean;
  80394. /**
  80395. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  80396. */
  80397. forceProjectionMatrixCompute(): void;
  80398. /** @hidden */
  80399. _initCache(): void;
  80400. /** @hidden */
  80401. _isSynchronized(): boolean;
  80402. /**
  80403. * Computes the world matrix of the node
  80404. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80405. * @returns the world matrix
  80406. */
  80407. computeWorldMatrix(force?: boolean): Matrix;
  80408. /**
  80409. * Gets the minZ used for shadow according to both the scene and the light.
  80410. * @param activeCamera The camera we are returning the min for
  80411. * @returns the depth min z
  80412. */
  80413. getDepthMinZ(activeCamera: Camera): number;
  80414. /**
  80415. * Gets the maxZ used for shadow according to both the scene and the light.
  80416. * @param activeCamera The camera we are returning the max for
  80417. * @returns the depth max z
  80418. */
  80419. getDepthMaxZ(activeCamera: Camera): number;
  80420. /**
  80421. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  80422. * @param matrix The materix to updated with the projection information
  80423. * @param viewMatrix The transform matrix of the light
  80424. * @param renderList The list of mesh to render in the map
  80425. * @returns The current light
  80426. */
  80427. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  80428. }
  80429. }
  80430. declare module BABYLON {
  80431. /**
  80432. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  80433. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  80434. */
  80435. export class EffectFallbacks implements IEffectFallbacks {
  80436. private _defines;
  80437. private _currentRank;
  80438. private _maxRank;
  80439. private _mesh;
  80440. /**
  80441. * Removes the fallback from the bound mesh.
  80442. */
  80443. unBindMesh(): void;
  80444. /**
  80445. * Adds a fallback on the specified property.
  80446. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  80447. * @param define The name of the define in the shader
  80448. */
  80449. addFallback(rank: number, define: string): void;
  80450. /**
  80451. * Sets the mesh to use CPU skinning when needing to fallback.
  80452. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  80453. * @param mesh The mesh to use the fallbacks.
  80454. */
  80455. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  80456. /**
  80457. * Checks to see if more fallbacks are still availible.
  80458. */
  80459. get hasMoreFallbacks(): boolean;
  80460. /**
  80461. * Removes the defines that should be removed when falling back.
  80462. * @param currentDefines defines the current define statements for the shader.
  80463. * @param effect defines the current effect we try to compile
  80464. * @returns The resulting defines with defines of the current rank removed.
  80465. */
  80466. reduce(currentDefines: string, effect: Effect): string;
  80467. }
  80468. }
  80469. declare module BABYLON {
  80470. /**
  80471. * "Static Class" containing the most commonly used helper while dealing with material for
  80472. * rendering purpose.
  80473. *
  80474. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  80475. *
  80476. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  80477. */
  80478. export class MaterialHelper {
  80479. /**
  80480. * Bind the current view position to an effect.
  80481. * @param effect The effect to be bound
  80482. * @param scene The scene the eyes position is used from
  80483. */
  80484. static BindEyePosition(effect: Effect, scene: Scene): void;
  80485. /**
  80486. * Helps preparing the defines values about the UVs in used in the effect.
  80487. * UVs are shared as much as we can accross channels in the shaders.
  80488. * @param texture The texture we are preparing the UVs for
  80489. * @param defines The defines to update
  80490. * @param key The channel key "diffuse", "specular"... used in the shader
  80491. */
  80492. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  80493. /**
  80494. * Binds a texture matrix value to its corrsponding uniform
  80495. * @param texture The texture to bind the matrix for
  80496. * @param uniformBuffer The uniform buffer receivin the data
  80497. * @param key The channel key "diffuse", "specular"... used in the shader
  80498. */
  80499. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  80500. /**
  80501. * Gets the current status of the fog (should it be enabled?)
  80502. * @param mesh defines the mesh to evaluate for fog support
  80503. * @param scene defines the hosting scene
  80504. * @returns true if fog must be enabled
  80505. */
  80506. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  80507. /**
  80508. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  80509. * @param mesh defines the current mesh
  80510. * @param scene defines the current scene
  80511. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  80512. * @param pointsCloud defines if point cloud rendering has to be turned on
  80513. * @param fogEnabled defines if fog has to be turned on
  80514. * @param alphaTest defines if alpha testing has to be turned on
  80515. * @param defines defines the current list of defines
  80516. */
  80517. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  80518. /**
  80519. * Helper used to prepare the list of defines associated with frame values for shader compilation
  80520. * @param scene defines the current scene
  80521. * @param engine defines the current engine
  80522. * @param defines specifies the list of active defines
  80523. * @param useInstances defines if instances have to be turned on
  80524. * @param useClipPlane defines if clip plane have to be turned on
  80525. */
  80526. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  80527. /**
  80528. * Prepares the defines for bones
  80529. * @param mesh The mesh containing the geometry data we will draw
  80530. * @param defines The defines to update
  80531. */
  80532. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  80533. /**
  80534. * Prepares the defines for morph targets
  80535. * @param mesh The mesh containing the geometry data we will draw
  80536. * @param defines The defines to update
  80537. */
  80538. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  80539. /**
  80540. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  80541. * @param mesh The mesh containing the geometry data we will draw
  80542. * @param defines The defines to update
  80543. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  80544. * @param useBones Precise whether bones should be used or not (override mesh info)
  80545. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  80546. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  80547. * @returns false if defines are considered not dirty and have not been checked
  80548. */
  80549. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  80550. /**
  80551. * Prepares the defines related to multiview
  80552. * @param scene The scene we are intending to draw
  80553. * @param defines The defines to update
  80554. */
  80555. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  80556. /**
  80557. * Prepares the defines related to the light information passed in parameter
  80558. * @param scene The scene we are intending to draw
  80559. * @param mesh The mesh the effect is compiling for
  80560. * @param light The light the effect is compiling for
  80561. * @param lightIndex The index of the light
  80562. * @param defines The defines to update
  80563. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  80564. * @param state Defines the current state regarding what is needed (normals, etc...)
  80565. */
  80566. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  80567. needNormals: boolean;
  80568. needRebuild: boolean;
  80569. shadowEnabled: boolean;
  80570. specularEnabled: boolean;
  80571. lightmapMode: boolean;
  80572. }): void;
  80573. /**
  80574. * Prepares the defines related to the light information passed in parameter
  80575. * @param scene The scene we are intending to draw
  80576. * @param mesh The mesh the effect is compiling for
  80577. * @param defines The defines to update
  80578. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  80579. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  80580. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  80581. * @returns true if normals will be required for the rest of the effect
  80582. */
  80583. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  80584. /**
  80585. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  80586. * @param lightIndex defines the light index
  80587. * @param uniformsList The uniform list
  80588. * @param samplersList The sampler list
  80589. * @param projectedLightTexture defines if projected texture must be used
  80590. * @param uniformBuffersList defines an optional list of uniform buffers
  80591. */
  80592. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  80593. /**
  80594. * Prepares the uniforms and samplers list to be used in the effect
  80595. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  80596. * @param samplersList The sampler list
  80597. * @param defines The defines helping in the list generation
  80598. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  80599. */
  80600. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  80601. /**
  80602. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  80603. * @param defines The defines to update while falling back
  80604. * @param fallbacks The authorized effect fallbacks
  80605. * @param maxSimultaneousLights The maximum number of lights allowed
  80606. * @param rank the current rank of the Effect
  80607. * @returns The newly affected rank
  80608. */
  80609. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  80610. private static _TmpMorphInfluencers;
  80611. /**
  80612. * Prepares the list of attributes required for morph targets according to the effect defines.
  80613. * @param attribs The current list of supported attribs
  80614. * @param mesh The mesh to prepare the morph targets attributes for
  80615. * @param influencers The number of influencers
  80616. */
  80617. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  80618. /**
  80619. * Prepares the list of attributes required for morph targets according to the effect defines.
  80620. * @param attribs The current list of supported attribs
  80621. * @param mesh The mesh to prepare the morph targets attributes for
  80622. * @param defines The current Defines of the effect
  80623. */
  80624. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  80625. /**
  80626. * Prepares the list of attributes required for bones according to the effect defines.
  80627. * @param attribs The current list of supported attribs
  80628. * @param mesh The mesh to prepare the bones attributes for
  80629. * @param defines The current Defines of the effect
  80630. * @param fallbacks The current efffect fallback strategy
  80631. */
  80632. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  80633. /**
  80634. * Check and prepare the list of attributes required for instances according to the effect defines.
  80635. * @param attribs The current list of supported attribs
  80636. * @param defines The current MaterialDefines of the effect
  80637. */
  80638. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  80639. /**
  80640. * Add the list of attributes required for instances to the attribs array.
  80641. * @param attribs The current list of supported attribs
  80642. */
  80643. static PushAttributesForInstances(attribs: string[]): void;
  80644. /**
  80645. * Binds the light information to the effect.
  80646. * @param light The light containing the generator
  80647. * @param effect The effect we are binding the data to
  80648. * @param lightIndex The light index in the effect used to render
  80649. */
  80650. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  80651. /**
  80652. * Binds the lights information from the scene to the effect for the given mesh.
  80653. * @param light Light to bind
  80654. * @param lightIndex Light index
  80655. * @param scene The scene where the light belongs to
  80656. * @param effect The effect we are binding the data to
  80657. * @param useSpecular Defines if specular is supported
  80658. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80659. */
  80660. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  80661. /**
  80662. * Binds the lights information from the scene to the effect for the given mesh.
  80663. * @param scene The scene the lights belongs to
  80664. * @param mesh The mesh we are binding the information to render
  80665. * @param effect The effect we are binding the data to
  80666. * @param defines The generated defines for the effect
  80667. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  80668. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80669. */
  80670. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  80671. private static _tempFogColor;
  80672. /**
  80673. * Binds the fog information from the scene to the effect for the given mesh.
  80674. * @param scene The scene the lights belongs to
  80675. * @param mesh The mesh we are binding the information to render
  80676. * @param effect The effect we are binding the data to
  80677. * @param linearSpace Defines if the fog effect is applied in linear space
  80678. */
  80679. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  80680. /**
  80681. * Binds the bones information from the mesh to the effect.
  80682. * @param mesh The mesh we are binding the information to render
  80683. * @param effect The effect we are binding the data to
  80684. */
  80685. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  80686. /**
  80687. * Binds the morph targets information from the mesh to the effect.
  80688. * @param abstractMesh The mesh we are binding the information to render
  80689. * @param effect The effect we are binding the data to
  80690. */
  80691. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  80692. /**
  80693. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  80694. * @param defines The generated defines used in the effect
  80695. * @param effect The effect we are binding the data to
  80696. * @param scene The scene we are willing to render with logarithmic scale for
  80697. */
  80698. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  80699. /**
  80700. * Binds the clip plane information from the scene to the effect.
  80701. * @param scene The scene the clip plane information are extracted from
  80702. * @param effect The effect we are binding the data to
  80703. */
  80704. static BindClipPlane(effect: Effect, scene: Scene): void;
  80705. }
  80706. }
  80707. declare module BABYLON {
  80708. /** @hidden */
  80709. export var packingFunctions: {
  80710. name: string;
  80711. shader: string;
  80712. };
  80713. }
  80714. declare module BABYLON {
  80715. /** @hidden */
  80716. export var shadowMapPixelShader: {
  80717. name: string;
  80718. shader: string;
  80719. };
  80720. }
  80721. declare module BABYLON {
  80722. /** @hidden */
  80723. export var bonesDeclaration: {
  80724. name: string;
  80725. shader: string;
  80726. };
  80727. }
  80728. declare module BABYLON {
  80729. /** @hidden */
  80730. export var morphTargetsVertexGlobalDeclaration: {
  80731. name: string;
  80732. shader: string;
  80733. };
  80734. }
  80735. declare module BABYLON {
  80736. /** @hidden */
  80737. export var morphTargetsVertexDeclaration: {
  80738. name: string;
  80739. shader: string;
  80740. };
  80741. }
  80742. declare module BABYLON {
  80743. /** @hidden */
  80744. export var instancesDeclaration: {
  80745. name: string;
  80746. shader: string;
  80747. };
  80748. }
  80749. declare module BABYLON {
  80750. /** @hidden */
  80751. export var helperFunctions: {
  80752. name: string;
  80753. shader: string;
  80754. };
  80755. }
  80756. declare module BABYLON {
  80757. /** @hidden */
  80758. export var morphTargetsVertex: {
  80759. name: string;
  80760. shader: string;
  80761. };
  80762. }
  80763. declare module BABYLON {
  80764. /** @hidden */
  80765. export var instancesVertex: {
  80766. name: string;
  80767. shader: string;
  80768. };
  80769. }
  80770. declare module BABYLON {
  80771. /** @hidden */
  80772. export var bonesVertex: {
  80773. name: string;
  80774. shader: string;
  80775. };
  80776. }
  80777. declare module BABYLON {
  80778. /** @hidden */
  80779. export var shadowMapVertexShader: {
  80780. name: string;
  80781. shader: string;
  80782. };
  80783. }
  80784. declare module BABYLON {
  80785. /** @hidden */
  80786. export var depthBoxBlurPixelShader: {
  80787. name: string;
  80788. shader: string;
  80789. };
  80790. }
  80791. declare module BABYLON {
  80792. /**
  80793. * Defines the options associated with the creation of a custom shader for a shadow generator.
  80794. */
  80795. export interface ICustomShaderOptions {
  80796. /**
  80797. * Gets or sets the custom shader name to use
  80798. */
  80799. shaderName: string;
  80800. /**
  80801. * The list of attribute names used in the shader
  80802. */
  80803. attributes?: string[];
  80804. /**
  80805. * The list of unifrom names used in the shader
  80806. */
  80807. uniforms?: string[];
  80808. /**
  80809. * The list of sampler names used in the shader
  80810. */
  80811. samplers?: string[];
  80812. /**
  80813. * The list of defines used in the shader
  80814. */
  80815. defines?: string[];
  80816. }
  80817. /**
  80818. * Interface to implement to create a shadow generator compatible with BJS.
  80819. */
  80820. export interface IShadowGenerator {
  80821. /**
  80822. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80823. * @returns The render target texture if present otherwise, null
  80824. */
  80825. getShadowMap(): Nullable<RenderTargetTexture>;
  80826. /**
  80827. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80828. * @returns The render target texture if the shadow map is present otherwise, null
  80829. */
  80830. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80831. /**
  80832. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80833. * @param subMesh The submesh we want to render in the shadow map
  80834. * @param useInstances Defines wether will draw in the map using instances
  80835. * @returns true if ready otherwise, false
  80836. */
  80837. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80838. /**
  80839. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80840. * @param defines Defines of the material we want to update
  80841. * @param lightIndex Index of the light in the enabled light list of the material
  80842. */
  80843. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  80844. /**
  80845. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80846. * defined in the generator but impacting the effect).
  80847. * It implies the unifroms available on the materials are the standard BJS ones.
  80848. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80849. * @param effect The effect we are binfing the information for
  80850. */
  80851. bindShadowLight(lightIndex: string, effect: Effect): void;
  80852. /**
  80853. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80854. * (eq to shadow prjection matrix * light transform matrix)
  80855. * @returns The transform matrix used to create the shadow map
  80856. */
  80857. getTransformMatrix(): Matrix;
  80858. /**
  80859. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80860. * Cube and 2D textures for instance.
  80861. */
  80862. recreateShadowMap(): void;
  80863. /**
  80864. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80865. * @param onCompiled Callback triggered at the and of the effects compilation
  80866. * @param options Sets of optional options forcing the compilation with different modes
  80867. */
  80868. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80869. useInstances: boolean;
  80870. }>): void;
  80871. /**
  80872. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80873. * @param options Sets of optional options forcing the compilation with different modes
  80874. * @returns A promise that resolves when the compilation completes
  80875. */
  80876. forceCompilationAsync(options?: Partial<{
  80877. useInstances: boolean;
  80878. }>): Promise<void>;
  80879. /**
  80880. * Serializes the shadow generator setup to a json object.
  80881. * @returns The serialized JSON object
  80882. */
  80883. serialize(): any;
  80884. /**
  80885. * Disposes the Shadow map and related Textures and effects.
  80886. */
  80887. dispose(): void;
  80888. }
  80889. /**
  80890. * Default implementation IShadowGenerator.
  80891. * This is the main object responsible of generating shadows in the framework.
  80892. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  80893. */
  80894. export class ShadowGenerator implements IShadowGenerator {
  80895. /**
  80896. * Shadow generator mode None: no filtering applied.
  80897. */
  80898. static readonly FILTER_NONE: number;
  80899. /**
  80900. * Shadow generator mode ESM: Exponential Shadow Mapping.
  80901. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80902. */
  80903. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  80904. /**
  80905. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  80906. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  80907. */
  80908. static readonly FILTER_POISSONSAMPLING: number;
  80909. /**
  80910. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  80911. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80912. */
  80913. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  80914. /**
  80915. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  80916. * edge artifacts on steep falloff.
  80917. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80918. */
  80919. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  80920. /**
  80921. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  80922. * edge artifacts on steep falloff.
  80923. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80924. */
  80925. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  80926. /**
  80927. * Shadow generator mode PCF: Percentage Closer Filtering
  80928. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80929. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  80930. */
  80931. static readonly FILTER_PCF: number;
  80932. /**
  80933. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  80934. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80935. * Contact Hardening
  80936. */
  80937. static readonly FILTER_PCSS: number;
  80938. /**
  80939. * Reserved for PCF and PCSS
  80940. * Highest Quality.
  80941. *
  80942. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  80943. *
  80944. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  80945. */
  80946. static readonly QUALITY_HIGH: number;
  80947. /**
  80948. * Reserved for PCF and PCSS
  80949. * Good tradeoff for quality/perf cross devices
  80950. *
  80951. * Execute PCF on a 3*3 kernel.
  80952. *
  80953. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  80954. */
  80955. static readonly QUALITY_MEDIUM: number;
  80956. /**
  80957. * Reserved for PCF and PCSS
  80958. * The lowest quality but the fastest.
  80959. *
  80960. * Execute PCF on a 1*1 kernel.
  80961. *
  80962. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  80963. */
  80964. static readonly QUALITY_LOW: number;
  80965. /** Gets or sets the custom shader name to use */
  80966. customShaderOptions: ICustomShaderOptions;
  80967. /**
  80968. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  80969. */
  80970. onBeforeShadowMapRenderObservable: Observable<Effect>;
  80971. /**
  80972. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  80973. */
  80974. onAfterShadowMapRenderObservable: Observable<Effect>;
  80975. /**
  80976. * Observable triggered before a mesh is rendered in the shadow map.
  80977. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  80978. */
  80979. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  80980. /**
  80981. * Observable triggered after a mesh is rendered in the shadow map.
  80982. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  80983. */
  80984. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  80985. private _bias;
  80986. /**
  80987. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  80988. */
  80989. get bias(): number;
  80990. /**
  80991. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  80992. */
  80993. set bias(bias: number);
  80994. private _normalBias;
  80995. /**
  80996. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80997. */
  80998. get normalBias(): number;
  80999. /**
  81000. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  81001. */
  81002. set normalBias(normalBias: number);
  81003. private _blurBoxOffset;
  81004. /**
  81005. * Gets the blur box offset: offset applied during the blur pass.
  81006. * Only useful if useKernelBlur = false
  81007. */
  81008. get blurBoxOffset(): number;
  81009. /**
  81010. * Sets the blur box offset: offset applied during the blur pass.
  81011. * Only useful if useKernelBlur = false
  81012. */
  81013. set blurBoxOffset(value: number);
  81014. private _blurScale;
  81015. /**
  81016. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  81017. * 2 means half of the size.
  81018. */
  81019. get blurScale(): number;
  81020. /**
  81021. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  81022. * 2 means half of the size.
  81023. */
  81024. set blurScale(value: number);
  81025. private _blurKernel;
  81026. /**
  81027. * Gets the blur kernel: kernel size of the blur pass.
  81028. * Only useful if useKernelBlur = true
  81029. */
  81030. get blurKernel(): number;
  81031. /**
  81032. * Sets the blur kernel: kernel size of the blur pass.
  81033. * Only useful if useKernelBlur = true
  81034. */
  81035. set blurKernel(value: number);
  81036. private _useKernelBlur;
  81037. /**
  81038. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  81039. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  81040. */
  81041. get useKernelBlur(): boolean;
  81042. /**
  81043. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  81044. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  81045. */
  81046. set useKernelBlur(value: boolean);
  81047. private _depthScale;
  81048. /**
  81049. * Gets the depth scale used in ESM mode.
  81050. */
  81051. get depthScale(): number;
  81052. /**
  81053. * Sets the depth scale used in ESM mode.
  81054. * This can override the scale stored on the light.
  81055. */
  81056. set depthScale(value: number);
  81057. private _filter;
  81058. /**
  81059. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  81060. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  81061. */
  81062. get filter(): number;
  81063. /**
  81064. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  81065. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  81066. */
  81067. set filter(value: number);
  81068. /**
  81069. * Gets if the current filter is set to Poisson Sampling.
  81070. */
  81071. get usePoissonSampling(): boolean;
  81072. /**
  81073. * Sets the current filter to Poisson Sampling.
  81074. */
  81075. set usePoissonSampling(value: boolean);
  81076. /**
  81077. * Gets if the current filter is set to ESM.
  81078. */
  81079. get useExponentialShadowMap(): boolean;
  81080. /**
  81081. * Sets the current filter is to ESM.
  81082. */
  81083. set useExponentialShadowMap(value: boolean);
  81084. /**
  81085. * Gets if the current filter is set to filtered ESM.
  81086. */
  81087. get useBlurExponentialShadowMap(): boolean;
  81088. /**
  81089. * Gets if the current filter is set to filtered ESM.
  81090. */
  81091. set useBlurExponentialShadowMap(value: boolean);
  81092. /**
  81093. * Gets if the current filter is set to "close ESM" (using the inverse of the
  81094. * exponential to prevent steep falloff artifacts).
  81095. */
  81096. get useCloseExponentialShadowMap(): boolean;
  81097. /**
  81098. * Sets the current filter to "close ESM" (using the inverse of the
  81099. * exponential to prevent steep falloff artifacts).
  81100. */
  81101. set useCloseExponentialShadowMap(value: boolean);
  81102. /**
  81103. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  81104. * exponential to prevent steep falloff artifacts).
  81105. */
  81106. get useBlurCloseExponentialShadowMap(): boolean;
  81107. /**
  81108. * Sets the current filter to filtered "close ESM" (using the inverse of the
  81109. * exponential to prevent steep falloff artifacts).
  81110. */
  81111. set useBlurCloseExponentialShadowMap(value: boolean);
  81112. /**
  81113. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  81114. */
  81115. get usePercentageCloserFiltering(): boolean;
  81116. /**
  81117. * Sets the current filter to "PCF" (percentage closer filtering).
  81118. */
  81119. set usePercentageCloserFiltering(value: boolean);
  81120. private _filteringQuality;
  81121. /**
  81122. * Gets the PCF or PCSS Quality.
  81123. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  81124. */
  81125. get filteringQuality(): number;
  81126. /**
  81127. * Sets the PCF or PCSS Quality.
  81128. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  81129. */
  81130. set filteringQuality(filteringQuality: number);
  81131. /**
  81132. * Gets if the current filter is set to "PCSS" (contact hardening).
  81133. */
  81134. get useContactHardeningShadow(): boolean;
  81135. /**
  81136. * Sets the current filter to "PCSS" (contact hardening).
  81137. */
  81138. set useContactHardeningShadow(value: boolean);
  81139. private _contactHardeningLightSizeUVRatio;
  81140. /**
  81141. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  81142. * Using a ratio helps keeping shape stability independently of the map size.
  81143. *
  81144. * It does not account for the light projection as it was having too much
  81145. * instability during the light setup or during light position changes.
  81146. *
  81147. * Only valid if useContactHardeningShadow is true.
  81148. */
  81149. get contactHardeningLightSizeUVRatio(): number;
  81150. /**
  81151. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  81152. * Using a ratio helps keeping shape stability independently of the map size.
  81153. *
  81154. * It does not account for the light projection as it was having too much
  81155. * instability during the light setup or during light position changes.
  81156. *
  81157. * Only valid if useContactHardeningShadow is true.
  81158. */
  81159. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  81160. private _darkness;
  81161. /** Gets or sets the actual darkness of a shadow */
  81162. get darkness(): number;
  81163. set darkness(value: number);
  81164. /**
  81165. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  81166. * 0 means strongest and 1 would means no shadow.
  81167. * @returns the darkness.
  81168. */
  81169. getDarkness(): number;
  81170. /**
  81171. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  81172. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  81173. * @returns the shadow generator allowing fluent coding.
  81174. */
  81175. setDarkness(darkness: number): ShadowGenerator;
  81176. private _transparencyShadow;
  81177. /** Gets or sets the ability to have transparent shadow */
  81178. get transparencyShadow(): boolean;
  81179. set transparencyShadow(value: boolean);
  81180. /**
  81181. * Sets the ability to have transparent shadow (boolean).
  81182. * @param transparent True if transparent else False
  81183. * @returns the shadow generator allowing fluent coding
  81184. */
  81185. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  81186. private _shadowMap;
  81187. private _shadowMap2;
  81188. /**
  81189. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  81190. * @returns The render target texture if present otherwise, null
  81191. */
  81192. getShadowMap(): Nullable<RenderTargetTexture>;
  81193. /**
  81194. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  81195. * @returns The render target texture if the shadow map is present otherwise, null
  81196. */
  81197. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  81198. /**
  81199. * Gets the class name of that object
  81200. * @returns "ShadowGenerator"
  81201. */
  81202. getClassName(): string;
  81203. /**
  81204. * Helper function to add a mesh and its descendants to the list of shadow casters.
  81205. * @param mesh Mesh to add
  81206. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  81207. * @returns the Shadow Generator itself
  81208. */
  81209. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  81210. /**
  81211. * Helper function to remove a mesh and its descendants from the list of shadow casters
  81212. * @param mesh Mesh to remove
  81213. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  81214. * @returns the Shadow Generator itself
  81215. */
  81216. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  81217. /**
  81218. * Controls the extent to which the shadows fade out at the edge of the frustum
  81219. * Used only by directionals and spots
  81220. */
  81221. frustumEdgeFalloff: number;
  81222. private _light;
  81223. /**
  81224. * Returns the associated light object.
  81225. * @returns the light generating the shadow
  81226. */
  81227. getLight(): IShadowLight;
  81228. /**
  81229. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  81230. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  81231. * It might on the other hand introduce peter panning.
  81232. */
  81233. forceBackFacesOnly: boolean;
  81234. private _scene;
  81235. private _lightDirection;
  81236. private _effect;
  81237. private _viewMatrix;
  81238. private _projectionMatrix;
  81239. private _transformMatrix;
  81240. private _cachedPosition;
  81241. private _cachedDirection;
  81242. private _cachedDefines;
  81243. private _currentRenderID;
  81244. private _boxBlurPostprocess;
  81245. private _kernelBlurXPostprocess;
  81246. private _kernelBlurYPostprocess;
  81247. private _blurPostProcesses;
  81248. private _mapSize;
  81249. private _currentFaceIndex;
  81250. private _currentFaceIndexCache;
  81251. private _textureType;
  81252. private _defaultTextureMatrix;
  81253. private _storedUniqueId;
  81254. /** @hidden */
  81255. static _SceneComponentInitialization: (scene: Scene) => void;
  81256. /**
  81257. * Creates a ShadowGenerator object.
  81258. * A ShadowGenerator is the required tool to use the shadows.
  81259. * Each light casting shadows needs to use its own ShadowGenerator.
  81260. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  81261. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  81262. * @param light The light object generating the shadows.
  81263. * @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.
  81264. */
  81265. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  81266. private _initializeGenerator;
  81267. private _initializeShadowMap;
  81268. private _initializeBlurRTTAndPostProcesses;
  81269. private _renderForShadowMap;
  81270. private _renderSubMeshForShadowMap;
  81271. private _applyFilterValues;
  81272. /**
  81273. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  81274. * @param onCompiled Callback triggered at the and of the effects compilation
  81275. * @param options Sets of optional options forcing the compilation with different modes
  81276. */
  81277. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  81278. useInstances: boolean;
  81279. }>): void;
  81280. /**
  81281. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  81282. * @param options Sets of optional options forcing the compilation with different modes
  81283. * @returns A promise that resolves when the compilation completes
  81284. */
  81285. forceCompilationAsync(options?: Partial<{
  81286. useInstances: boolean;
  81287. }>): Promise<void>;
  81288. /**
  81289. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  81290. * @param subMesh The submesh we want to render in the shadow map
  81291. * @param useInstances Defines wether will draw in the map using instances
  81292. * @returns true if ready otherwise, false
  81293. */
  81294. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  81295. /**
  81296. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  81297. * @param defines Defines of the material we want to update
  81298. * @param lightIndex Index of the light in the enabled light list of the material
  81299. */
  81300. prepareDefines(defines: any, lightIndex: number): void;
  81301. /**
  81302. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  81303. * defined in the generator but impacting the effect).
  81304. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  81305. * @param effect The effect we are binfing the information for
  81306. */
  81307. bindShadowLight(lightIndex: string, effect: Effect): void;
  81308. /**
  81309. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  81310. * (eq to shadow prjection matrix * light transform matrix)
  81311. * @returns The transform matrix used to create the shadow map
  81312. */
  81313. getTransformMatrix(): Matrix;
  81314. /**
  81315. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  81316. * Cube and 2D textures for instance.
  81317. */
  81318. recreateShadowMap(): void;
  81319. private _disposeBlurPostProcesses;
  81320. private _disposeRTTandPostProcesses;
  81321. /**
  81322. * Disposes the ShadowGenerator.
  81323. * Returns nothing.
  81324. */
  81325. dispose(): void;
  81326. /**
  81327. * Serializes the shadow generator setup to a json object.
  81328. * @returns The serialized JSON object
  81329. */
  81330. serialize(): any;
  81331. /**
  81332. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  81333. * @param parsedShadowGenerator The JSON object to parse
  81334. * @param scene The scene to create the shadow map for
  81335. * @returns The parsed shadow generator
  81336. */
  81337. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  81338. }
  81339. }
  81340. declare module BABYLON {
  81341. /**
  81342. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  81343. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  81344. * 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.
  81345. */
  81346. export abstract class Light extends Node {
  81347. /**
  81348. * Falloff Default: light is falling off following the material specification:
  81349. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  81350. */
  81351. static readonly FALLOFF_DEFAULT: number;
  81352. /**
  81353. * Falloff Physical: light is falling off following the inverse squared distance law.
  81354. */
  81355. static readonly FALLOFF_PHYSICAL: number;
  81356. /**
  81357. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  81358. * to enhance interoperability with other engines.
  81359. */
  81360. static readonly FALLOFF_GLTF: number;
  81361. /**
  81362. * Falloff Standard: light is falling off like in the standard material
  81363. * to enhance interoperability with other materials.
  81364. */
  81365. static readonly FALLOFF_STANDARD: number;
  81366. /**
  81367. * If every light affecting the material is in this lightmapMode,
  81368. * material.lightmapTexture adds or multiplies
  81369. * (depends on material.useLightmapAsShadowmap)
  81370. * after every other light calculations.
  81371. */
  81372. static readonly LIGHTMAP_DEFAULT: number;
  81373. /**
  81374. * material.lightmapTexture as only diffuse lighting from this light
  81375. * adds only specular lighting from this light
  81376. * adds dynamic shadows
  81377. */
  81378. static readonly LIGHTMAP_SPECULAR: number;
  81379. /**
  81380. * material.lightmapTexture as only lighting
  81381. * no light calculation from this light
  81382. * only adds dynamic shadows from this light
  81383. */
  81384. static readonly LIGHTMAP_SHADOWSONLY: number;
  81385. /**
  81386. * Each light type uses the default quantity according to its type:
  81387. * point/spot lights use luminous intensity
  81388. * directional lights use illuminance
  81389. */
  81390. static readonly INTENSITYMODE_AUTOMATIC: number;
  81391. /**
  81392. * lumen (lm)
  81393. */
  81394. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  81395. /**
  81396. * candela (lm/sr)
  81397. */
  81398. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  81399. /**
  81400. * lux (lm/m^2)
  81401. */
  81402. static readonly INTENSITYMODE_ILLUMINANCE: number;
  81403. /**
  81404. * nit (cd/m^2)
  81405. */
  81406. static readonly INTENSITYMODE_LUMINANCE: number;
  81407. /**
  81408. * Light type const id of the point light.
  81409. */
  81410. static readonly LIGHTTYPEID_POINTLIGHT: number;
  81411. /**
  81412. * Light type const id of the directional light.
  81413. */
  81414. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  81415. /**
  81416. * Light type const id of the spot light.
  81417. */
  81418. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  81419. /**
  81420. * Light type const id of the hemispheric light.
  81421. */
  81422. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  81423. /**
  81424. * Diffuse gives the basic color to an object.
  81425. */
  81426. diffuse: Color3;
  81427. /**
  81428. * Specular produces a highlight color on an object.
  81429. * Note: This is note affecting PBR materials.
  81430. */
  81431. specular: Color3;
  81432. /**
  81433. * Defines the falloff type for this light. This lets overrriding how punctual light are
  81434. * falling off base on range or angle.
  81435. * This can be set to any values in Light.FALLOFF_x.
  81436. *
  81437. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  81438. * other types of materials.
  81439. */
  81440. falloffType: number;
  81441. /**
  81442. * Strength of the light.
  81443. * Note: By default it is define in the framework own unit.
  81444. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  81445. */
  81446. intensity: number;
  81447. private _range;
  81448. protected _inverseSquaredRange: number;
  81449. /**
  81450. * Defines how far from the source the light is impacting in scene units.
  81451. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  81452. */
  81453. get range(): number;
  81454. /**
  81455. * Defines how far from the source the light is impacting in scene units.
  81456. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  81457. */
  81458. set range(value: number);
  81459. /**
  81460. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  81461. * of light.
  81462. */
  81463. private _photometricScale;
  81464. private _intensityMode;
  81465. /**
  81466. * Gets the photometric scale used to interpret the intensity.
  81467. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  81468. */
  81469. get intensityMode(): number;
  81470. /**
  81471. * Sets the photometric scale used to interpret the intensity.
  81472. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  81473. */
  81474. set intensityMode(value: number);
  81475. private _radius;
  81476. /**
  81477. * Gets the light radius used by PBR Materials to simulate soft area lights.
  81478. */
  81479. get radius(): number;
  81480. /**
  81481. * sets the light radius used by PBR Materials to simulate soft area lights.
  81482. */
  81483. set radius(value: number);
  81484. private _renderPriority;
  81485. /**
  81486. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  81487. * exceeding the number allowed of the materials.
  81488. */
  81489. renderPriority: number;
  81490. private _shadowEnabled;
  81491. /**
  81492. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  81493. * the current shadow generator.
  81494. */
  81495. get shadowEnabled(): boolean;
  81496. /**
  81497. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  81498. * the current shadow generator.
  81499. */
  81500. set shadowEnabled(value: boolean);
  81501. private _includedOnlyMeshes;
  81502. /**
  81503. * Gets the only meshes impacted by this light.
  81504. */
  81505. get includedOnlyMeshes(): AbstractMesh[];
  81506. /**
  81507. * Sets the only meshes impacted by this light.
  81508. */
  81509. set includedOnlyMeshes(value: AbstractMesh[]);
  81510. private _excludedMeshes;
  81511. /**
  81512. * Gets the meshes not impacted by this light.
  81513. */
  81514. get excludedMeshes(): AbstractMesh[];
  81515. /**
  81516. * Sets the meshes not impacted by this light.
  81517. */
  81518. set excludedMeshes(value: AbstractMesh[]);
  81519. private _excludeWithLayerMask;
  81520. /**
  81521. * Gets the layer id use to find what meshes are not impacted by the light.
  81522. * Inactive if 0
  81523. */
  81524. get excludeWithLayerMask(): number;
  81525. /**
  81526. * Sets the layer id use to find what meshes are not impacted by the light.
  81527. * Inactive if 0
  81528. */
  81529. set excludeWithLayerMask(value: number);
  81530. private _includeOnlyWithLayerMask;
  81531. /**
  81532. * Gets the layer id use to find what meshes are impacted by the light.
  81533. * Inactive if 0
  81534. */
  81535. get includeOnlyWithLayerMask(): number;
  81536. /**
  81537. * Sets the layer id use to find what meshes are impacted by the light.
  81538. * Inactive if 0
  81539. */
  81540. set includeOnlyWithLayerMask(value: number);
  81541. private _lightmapMode;
  81542. /**
  81543. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  81544. */
  81545. get lightmapMode(): number;
  81546. /**
  81547. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  81548. */
  81549. set lightmapMode(value: number);
  81550. /**
  81551. * Shadow generator associted to the light.
  81552. * @hidden Internal use only.
  81553. */
  81554. _shadowGenerator: Nullable<IShadowGenerator>;
  81555. /**
  81556. * @hidden Internal use only.
  81557. */
  81558. _excludedMeshesIds: string[];
  81559. /**
  81560. * @hidden Internal use only.
  81561. */
  81562. _includedOnlyMeshesIds: string[];
  81563. /**
  81564. * The current light unifom buffer.
  81565. * @hidden Internal use only.
  81566. */
  81567. _uniformBuffer: UniformBuffer;
  81568. /** @hidden */
  81569. _renderId: number;
  81570. /**
  81571. * Creates a Light object in the scene.
  81572. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81573. * @param name The firendly name of the light
  81574. * @param scene The scene the light belongs too
  81575. */
  81576. constructor(name: string, scene: Scene);
  81577. protected abstract _buildUniformLayout(): void;
  81578. /**
  81579. * Sets the passed Effect "effect" with the Light information.
  81580. * @param effect The effect to update
  81581. * @param lightIndex The index of the light in the effect to update
  81582. * @returns The light
  81583. */
  81584. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  81585. /**
  81586. * Sets the passed Effect "effect" with the Light textures.
  81587. * @param effect The effect to update
  81588. * @param lightIndex The index of the light in the effect to update
  81589. * @returns The light
  81590. */
  81591. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  81592. /**
  81593. * Binds the lights information from the scene to the effect for the given mesh.
  81594. * @param lightIndex Light index
  81595. * @param scene The scene where the light belongs to
  81596. * @param effect The effect we are binding the data to
  81597. * @param useSpecular Defines if specular is supported
  81598. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  81599. */
  81600. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  81601. /**
  81602. * Sets the passed Effect "effect" with the Light information.
  81603. * @param effect The effect to update
  81604. * @param lightDataUniformName The uniform used to store light data (position or direction)
  81605. * @returns The light
  81606. */
  81607. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  81608. /**
  81609. * Returns the string "Light".
  81610. * @returns the class name
  81611. */
  81612. getClassName(): string;
  81613. /** @hidden */
  81614. readonly _isLight: boolean;
  81615. /**
  81616. * Converts the light information to a readable string for debug purpose.
  81617. * @param fullDetails Supports for multiple levels of logging within scene loading
  81618. * @returns the human readable light info
  81619. */
  81620. toString(fullDetails?: boolean): string;
  81621. /** @hidden */
  81622. protected _syncParentEnabledState(): void;
  81623. /**
  81624. * Set the enabled state of this node.
  81625. * @param value - the new enabled state
  81626. */
  81627. setEnabled(value: boolean): void;
  81628. /**
  81629. * Returns the Light associated shadow generator if any.
  81630. * @return the associated shadow generator.
  81631. */
  81632. getShadowGenerator(): Nullable<IShadowGenerator>;
  81633. /**
  81634. * Returns a Vector3, the absolute light position in the World.
  81635. * @returns the world space position of the light
  81636. */
  81637. getAbsolutePosition(): Vector3;
  81638. /**
  81639. * Specifies if the light will affect the passed mesh.
  81640. * @param mesh The mesh to test against the light
  81641. * @return true the mesh is affected otherwise, false.
  81642. */
  81643. canAffectMesh(mesh: AbstractMesh): boolean;
  81644. /**
  81645. * Sort function to order lights for rendering.
  81646. * @param a First Light object to compare to second.
  81647. * @param b Second Light object to compare first.
  81648. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  81649. */
  81650. static CompareLightsPriority(a: Light, b: Light): number;
  81651. /**
  81652. * Releases resources associated with this node.
  81653. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81654. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81655. */
  81656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81657. /**
  81658. * Returns the light type ID (integer).
  81659. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81660. */
  81661. getTypeID(): number;
  81662. /**
  81663. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  81664. * @returns the scaled intensity in intensity mode unit
  81665. */
  81666. getScaledIntensity(): number;
  81667. /**
  81668. * Returns a new Light object, named "name", from the current one.
  81669. * @param name The name of the cloned light
  81670. * @returns the new created light
  81671. */
  81672. clone(name: string): Nullable<Light>;
  81673. /**
  81674. * Serializes the current light into a Serialization object.
  81675. * @returns the serialized object.
  81676. */
  81677. serialize(): any;
  81678. /**
  81679. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  81680. * This new light is named "name" and added to the passed scene.
  81681. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  81682. * @param name The friendly name of the light
  81683. * @param scene The scene the new light will belong to
  81684. * @returns the constructor function
  81685. */
  81686. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  81687. /**
  81688. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  81689. * @param parsedLight The JSON representation of the light
  81690. * @param scene The scene to create the parsed light in
  81691. * @returns the created light after parsing
  81692. */
  81693. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  81694. private _hookArrayForExcluded;
  81695. private _hookArrayForIncludedOnly;
  81696. private _resyncMeshes;
  81697. /**
  81698. * Forces the meshes to update their light related information in their rendering used effects
  81699. * @hidden Internal Use Only
  81700. */
  81701. _markMeshesAsLightDirty(): void;
  81702. /**
  81703. * Recomputes the cached photometric scale if needed.
  81704. */
  81705. private _computePhotometricScale;
  81706. /**
  81707. * Returns the Photometric Scale according to the light type and intensity mode.
  81708. */
  81709. private _getPhotometricScale;
  81710. /**
  81711. * Reorder the light in the scene according to their defined priority.
  81712. * @hidden Internal Use Only
  81713. */
  81714. _reorderLightsInScene(): void;
  81715. /**
  81716. * Prepares the list of defines specific to the light type.
  81717. * @param defines the list of defines
  81718. * @param lightIndex defines the index of the light for the effect
  81719. */
  81720. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81721. }
  81722. }
  81723. declare module BABYLON {
  81724. /**
  81725. * Interface used to define Action
  81726. */
  81727. export interface IAction {
  81728. /**
  81729. * Trigger for the action
  81730. */
  81731. trigger: number;
  81732. /** Options of the trigger */
  81733. triggerOptions: any;
  81734. /**
  81735. * Gets the trigger parameters
  81736. * @returns the trigger parameters
  81737. */
  81738. getTriggerParameter(): any;
  81739. /**
  81740. * Internal only - executes current action event
  81741. * @hidden
  81742. */
  81743. _executeCurrent(evt?: ActionEvent): void;
  81744. /**
  81745. * Serialize placeholder for child classes
  81746. * @param parent of child
  81747. * @returns the serialized object
  81748. */
  81749. serialize(parent: any): any;
  81750. /**
  81751. * Internal only
  81752. * @hidden
  81753. */
  81754. _prepare(): void;
  81755. /**
  81756. * Internal only - manager for action
  81757. * @hidden
  81758. */
  81759. _actionManager: AbstractActionManager;
  81760. /**
  81761. * Adds action to chain of actions, may be a DoNothingAction
  81762. * @param action defines the next action to execute
  81763. * @returns The action passed in
  81764. * @see https://www.babylonjs-playground.com/#1T30HR#0
  81765. */
  81766. then(action: IAction): IAction;
  81767. }
  81768. /**
  81769. * The action to be carried out following a trigger
  81770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  81771. */
  81772. export class Action implements IAction {
  81773. /** the trigger, with or without parameters, for the action */
  81774. triggerOptions: any;
  81775. /**
  81776. * Trigger for the action
  81777. */
  81778. trigger: number;
  81779. /**
  81780. * Internal only - manager for action
  81781. * @hidden
  81782. */
  81783. _actionManager: ActionManager;
  81784. private _nextActiveAction;
  81785. private _child;
  81786. private _condition?;
  81787. private _triggerParameter;
  81788. /**
  81789. * An event triggered prior to action being executed.
  81790. */
  81791. onBeforeExecuteObservable: Observable<Action>;
  81792. /**
  81793. * Creates a new Action
  81794. * @param triggerOptions the trigger, with or without parameters, for the action
  81795. * @param condition an optional determinant of action
  81796. */
  81797. constructor(
  81798. /** the trigger, with or without parameters, for the action */
  81799. triggerOptions: any, condition?: Condition);
  81800. /**
  81801. * Internal only
  81802. * @hidden
  81803. */
  81804. _prepare(): void;
  81805. /**
  81806. * Gets the trigger parameters
  81807. * @returns the trigger parameters
  81808. */
  81809. getTriggerParameter(): any;
  81810. /**
  81811. * Internal only - executes current action event
  81812. * @hidden
  81813. */
  81814. _executeCurrent(evt?: ActionEvent): void;
  81815. /**
  81816. * Execute placeholder for child classes
  81817. * @param evt optional action event
  81818. */
  81819. execute(evt?: ActionEvent): void;
  81820. /**
  81821. * Skips to next active action
  81822. */
  81823. skipToNextActiveAction(): void;
  81824. /**
  81825. * Adds action to chain of actions, may be a DoNothingAction
  81826. * @param action defines the next action to execute
  81827. * @returns The action passed in
  81828. * @see https://www.babylonjs-playground.com/#1T30HR#0
  81829. */
  81830. then(action: Action): Action;
  81831. /**
  81832. * Internal only
  81833. * @hidden
  81834. */
  81835. _getProperty(propertyPath: string): string;
  81836. /**
  81837. * Internal only
  81838. * @hidden
  81839. */
  81840. _getEffectiveTarget(target: any, propertyPath: string): any;
  81841. /**
  81842. * Serialize placeholder for child classes
  81843. * @param parent of child
  81844. * @returns the serialized object
  81845. */
  81846. serialize(parent: any): any;
  81847. /**
  81848. * Internal only called by serialize
  81849. * @hidden
  81850. */
  81851. protected _serialize(serializedAction: any, parent?: any): any;
  81852. /**
  81853. * Internal only
  81854. * @hidden
  81855. */
  81856. static _SerializeValueAsString: (value: any) => string;
  81857. /**
  81858. * Internal only
  81859. * @hidden
  81860. */
  81861. static _GetTargetProperty: (target: Node | Scene) => {
  81862. name: string;
  81863. targetType: string;
  81864. value: string;
  81865. };
  81866. }
  81867. }
  81868. declare module BABYLON {
  81869. /**
  81870. * A Condition applied to an Action
  81871. */
  81872. export class Condition {
  81873. /**
  81874. * Internal only - manager for action
  81875. * @hidden
  81876. */
  81877. _actionManager: ActionManager;
  81878. /**
  81879. * Internal only
  81880. * @hidden
  81881. */
  81882. _evaluationId: number;
  81883. /**
  81884. * Internal only
  81885. * @hidden
  81886. */
  81887. _currentResult: boolean;
  81888. /**
  81889. * Creates a new Condition
  81890. * @param actionManager the manager of the action the condition is applied to
  81891. */
  81892. constructor(actionManager: ActionManager);
  81893. /**
  81894. * Check if the current condition is valid
  81895. * @returns a boolean
  81896. */
  81897. isValid(): boolean;
  81898. /**
  81899. * Internal only
  81900. * @hidden
  81901. */
  81902. _getProperty(propertyPath: string): string;
  81903. /**
  81904. * Internal only
  81905. * @hidden
  81906. */
  81907. _getEffectiveTarget(target: any, propertyPath: string): any;
  81908. /**
  81909. * Serialize placeholder for child classes
  81910. * @returns the serialized object
  81911. */
  81912. serialize(): any;
  81913. /**
  81914. * Internal only
  81915. * @hidden
  81916. */
  81917. protected _serialize(serializedCondition: any): any;
  81918. }
  81919. /**
  81920. * Defines specific conditional operators as extensions of Condition
  81921. */
  81922. export class ValueCondition extends Condition {
  81923. /** path to specify the property of the target the conditional operator uses */
  81924. propertyPath: string;
  81925. /** the value compared by the conditional operator against the current value of the property */
  81926. value: any;
  81927. /** the conditional operator, default ValueCondition.IsEqual */
  81928. operator: number;
  81929. /**
  81930. * Internal only
  81931. * @hidden
  81932. */
  81933. private static _IsEqual;
  81934. /**
  81935. * Internal only
  81936. * @hidden
  81937. */
  81938. private static _IsDifferent;
  81939. /**
  81940. * Internal only
  81941. * @hidden
  81942. */
  81943. private static _IsGreater;
  81944. /**
  81945. * Internal only
  81946. * @hidden
  81947. */
  81948. private static _IsLesser;
  81949. /**
  81950. * returns the number for IsEqual
  81951. */
  81952. static get IsEqual(): number;
  81953. /**
  81954. * Returns the number for IsDifferent
  81955. */
  81956. static get IsDifferent(): number;
  81957. /**
  81958. * Returns the number for IsGreater
  81959. */
  81960. static get IsGreater(): number;
  81961. /**
  81962. * Returns the number for IsLesser
  81963. */
  81964. static get IsLesser(): number;
  81965. /**
  81966. * Internal only The action manager for the condition
  81967. * @hidden
  81968. */
  81969. _actionManager: ActionManager;
  81970. /**
  81971. * Internal only
  81972. * @hidden
  81973. */
  81974. private _target;
  81975. /**
  81976. * Internal only
  81977. * @hidden
  81978. */
  81979. private _effectiveTarget;
  81980. /**
  81981. * Internal only
  81982. * @hidden
  81983. */
  81984. private _property;
  81985. /**
  81986. * Creates a new ValueCondition
  81987. * @param actionManager manager for the action the condition applies to
  81988. * @param target for the action
  81989. * @param propertyPath path to specify the property of the target the conditional operator uses
  81990. * @param value the value compared by the conditional operator against the current value of the property
  81991. * @param operator the conditional operator, default ValueCondition.IsEqual
  81992. */
  81993. constructor(actionManager: ActionManager, target: any,
  81994. /** path to specify the property of the target the conditional operator uses */
  81995. propertyPath: string,
  81996. /** the value compared by the conditional operator against the current value of the property */
  81997. value: any,
  81998. /** the conditional operator, default ValueCondition.IsEqual */
  81999. operator?: number);
  82000. /**
  82001. * Compares the given value with the property value for the specified conditional operator
  82002. * @returns the result of the comparison
  82003. */
  82004. isValid(): boolean;
  82005. /**
  82006. * Serialize the ValueCondition into a JSON compatible object
  82007. * @returns serialization object
  82008. */
  82009. serialize(): any;
  82010. /**
  82011. * Gets the name of the conditional operator for the ValueCondition
  82012. * @param operator the conditional operator
  82013. * @returns the name
  82014. */
  82015. static GetOperatorName(operator: number): string;
  82016. }
  82017. /**
  82018. * Defines a predicate condition as an extension of Condition
  82019. */
  82020. export class PredicateCondition extends Condition {
  82021. /** defines the predicate function used to validate the condition */
  82022. predicate: () => boolean;
  82023. /**
  82024. * Internal only - manager for action
  82025. * @hidden
  82026. */
  82027. _actionManager: ActionManager;
  82028. /**
  82029. * Creates a new PredicateCondition
  82030. * @param actionManager manager for the action the condition applies to
  82031. * @param predicate defines the predicate function used to validate the condition
  82032. */
  82033. constructor(actionManager: ActionManager,
  82034. /** defines the predicate function used to validate the condition */
  82035. predicate: () => boolean);
  82036. /**
  82037. * @returns the validity of the predicate condition
  82038. */
  82039. isValid(): boolean;
  82040. }
  82041. /**
  82042. * Defines a state condition as an extension of Condition
  82043. */
  82044. export class StateCondition extends Condition {
  82045. /** Value to compare with target state */
  82046. value: string;
  82047. /**
  82048. * Internal only - manager for action
  82049. * @hidden
  82050. */
  82051. _actionManager: ActionManager;
  82052. /**
  82053. * Internal only
  82054. * @hidden
  82055. */
  82056. private _target;
  82057. /**
  82058. * Creates a new StateCondition
  82059. * @param actionManager manager for the action the condition applies to
  82060. * @param target of the condition
  82061. * @param value to compare with target state
  82062. */
  82063. constructor(actionManager: ActionManager, target: any,
  82064. /** Value to compare with target state */
  82065. value: string);
  82066. /**
  82067. * Gets a boolean indicating if the current condition is met
  82068. * @returns the validity of the state
  82069. */
  82070. isValid(): boolean;
  82071. /**
  82072. * Serialize the StateCondition into a JSON compatible object
  82073. * @returns serialization object
  82074. */
  82075. serialize(): any;
  82076. }
  82077. }
  82078. declare module BABYLON {
  82079. /**
  82080. * This defines an action responsible to toggle a boolean once triggered.
  82081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82082. */
  82083. export class SwitchBooleanAction extends Action {
  82084. /**
  82085. * The path to the boolean property in the target object
  82086. */
  82087. propertyPath: string;
  82088. private _target;
  82089. private _effectiveTarget;
  82090. private _property;
  82091. /**
  82092. * Instantiate the action
  82093. * @param triggerOptions defines the trigger options
  82094. * @param target defines the object containing the boolean
  82095. * @param propertyPath defines the path to the boolean property in the target object
  82096. * @param condition defines the trigger related conditions
  82097. */
  82098. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  82099. /** @hidden */
  82100. _prepare(): void;
  82101. /**
  82102. * Execute the action toggle the boolean value.
  82103. */
  82104. execute(): void;
  82105. /**
  82106. * Serializes the actions and its related information.
  82107. * @param parent defines the object to serialize in
  82108. * @returns the serialized object
  82109. */
  82110. serialize(parent: any): any;
  82111. }
  82112. /**
  82113. * This defines an action responsible to set a the state field of the target
  82114. * to a desired value once triggered.
  82115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82116. */
  82117. export class SetStateAction extends Action {
  82118. /**
  82119. * The value to store in the state field.
  82120. */
  82121. value: string;
  82122. private _target;
  82123. /**
  82124. * Instantiate the action
  82125. * @param triggerOptions defines the trigger options
  82126. * @param target defines the object containing the state property
  82127. * @param value defines the value to store in the state field
  82128. * @param condition defines the trigger related conditions
  82129. */
  82130. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  82131. /**
  82132. * Execute the action and store the value on the target state property.
  82133. */
  82134. execute(): void;
  82135. /**
  82136. * Serializes the actions and its related information.
  82137. * @param parent defines the object to serialize in
  82138. * @returns the serialized object
  82139. */
  82140. serialize(parent: any): any;
  82141. }
  82142. /**
  82143. * This defines an action responsible to set a property of the target
  82144. * to a desired value once triggered.
  82145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82146. */
  82147. export class SetValueAction extends Action {
  82148. /**
  82149. * The path of the property to set in the target.
  82150. */
  82151. propertyPath: string;
  82152. /**
  82153. * The value to set in the property
  82154. */
  82155. value: any;
  82156. private _target;
  82157. private _effectiveTarget;
  82158. private _property;
  82159. /**
  82160. * Instantiate the action
  82161. * @param triggerOptions defines the trigger options
  82162. * @param target defines the object containing the property
  82163. * @param propertyPath defines the path of the property to set in the target
  82164. * @param value defines the value to set in the property
  82165. * @param condition defines the trigger related conditions
  82166. */
  82167. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  82168. /** @hidden */
  82169. _prepare(): void;
  82170. /**
  82171. * Execute the action and set the targetted property to the desired value.
  82172. */
  82173. execute(): void;
  82174. /**
  82175. * Serializes the actions and its related information.
  82176. * @param parent defines the object to serialize in
  82177. * @returns the serialized object
  82178. */
  82179. serialize(parent: any): any;
  82180. }
  82181. /**
  82182. * This defines an action responsible to increment the target value
  82183. * to a desired value once triggered.
  82184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82185. */
  82186. export class IncrementValueAction extends Action {
  82187. /**
  82188. * The path of the property to increment in the target.
  82189. */
  82190. propertyPath: string;
  82191. /**
  82192. * The value we should increment the property by.
  82193. */
  82194. value: any;
  82195. private _target;
  82196. private _effectiveTarget;
  82197. private _property;
  82198. /**
  82199. * Instantiate the action
  82200. * @param triggerOptions defines the trigger options
  82201. * @param target defines the object containing the property
  82202. * @param propertyPath defines the path of the property to increment in the target
  82203. * @param value defines the value value we should increment the property by
  82204. * @param condition defines the trigger related conditions
  82205. */
  82206. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  82207. /** @hidden */
  82208. _prepare(): void;
  82209. /**
  82210. * Execute the action and increment the target of the value amount.
  82211. */
  82212. execute(): void;
  82213. /**
  82214. * Serializes the actions and its related information.
  82215. * @param parent defines the object to serialize in
  82216. * @returns the serialized object
  82217. */
  82218. serialize(parent: any): any;
  82219. }
  82220. /**
  82221. * This defines an action responsible to start an animation once triggered.
  82222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82223. */
  82224. export class PlayAnimationAction extends Action {
  82225. /**
  82226. * Where the animation should start (animation frame)
  82227. */
  82228. from: number;
  82229. /**
  82230. * Where the animation should stop (animation frame)
  82231. */
  82232. to: number;
  82233. /**
  82234. * Define if the animation should loop or stop after the first play.
  82235. */
  82236. loop?: boolean;
  82237. private _target;
  82238. /**
  82239. * Instantiate the action
  82240. * @param triggerOptions defines the trigger options
  82241. * @param target defines the target animation or animation name
  82242. * @param from defines from where the animation should start (animation frame)
  82243. * @param end defines where the animation should stop (animation frame)
  82244. * @param loop defines if the animation should loop or stop after the first play
  82245. * @param condition defines the trigger related conditions
  82246. */
  82247. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  82248. /** @hidden */
  82249. _prepare(): void;
  82250. /**
  82251. * Execute the action and play the animation.
  82252. */
  82253. execute(): void;
  82254. /**
  82255. * Serializes the actions and its related information.
  82256. * @param parent defines the object to serialize in
  82257. * @returns the serialized object
  82258. */
  82259. serialize(parent: any): any;
  82260. }
  82261. /**
  82262. * This defines an action responsible to stop an animation once triggered.
  82263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82264. */
  82265. export class StopAnimationAction extends Action {
  82266. private _target;
  82267. /**
  82268. * Instantiate the action
  82269. * @param triggerOptions defines the trigger options
  82270. * @param target defines the target animation or animation name
  82271. * @param condition defines the trigger related conditions
  82272. */
  82273. constructor(triggerOptions: any, target: any, condition?: Condition);
  82274. /** @hidden */
  82275. _prepare(): void;
  82276. /**
  82277. * Execute the action and stop the animation.
  82278. */
  82279. execute(): void;
  82280. /**
  82281. * Serializes the actions and its related information.
  82282. * @param parent defines the object to serialize in
  82283. * @returns the serialized object
  82284. */
  82285. serialize(parent: any): any;
  82286. }
  82287. /**
  82288. * This defines an action responsible that does nothing once triggered.
  82289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82290. */
  82291. export class DoNothingAction extends Action {
  82292. /**
  82293. * Instantiate the action
  82294. * @param triggerOptions defines the trigger options
  82295. * @param condition defines the trigger related conditions
  82296. */
  82297. constructor(triggerOptions?: any, condition?: Condition);
  82298. /**
  82299. * Execute the action and do nothing.
  82300. */
  82301. execute(): void;
  82302. /**
  82303. * Serializes the actions and its related information.
  82304. * @param parent defines the object to serialize in
  82305. * @returns the serialized object
  82306. */
  82307. serialize(parent: any): any;
  82308. }
  82309. /**
  82310. * This defines an action responsible to trigger several actions once triggered.
  82311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82312. */
  82313. export class CombineAction extends Action {
  82314. /**
  82315. * The list of aggregated animations to run.
  82316. */
  82317. children: Action[];
  82318. /**
  82319. * Instantiate the action
  82320. * @param triggerOptions defines the trigger options
  82321. * @param children defines the list of aggregated animations to run
  82322. * @param condition defines the trigger related conditions
  82323. */
  82324. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  82325. /** @hidden */
  82326. _prepare(): void;
  82327. /**
  82328. * Execute the action and executes all the aggregated actions.
  82329. */
  82330. execute(evt: ActionEvent): void;
  82331. /**
  82332. * Serializes the actions and its related information.
  82333. * @param parent defines the object to serialize in
  82334. * @returns the serialized object
  82335. */
  82336. serialize(parent: any): any;
  82337. }
  82338. /**
  82339. * This defines an action responsible to run code (external event) once triggered.
  82340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82341. */
  82342. export class ExecuteCodeAction extends Action {
  82343. /**
  82344. * The callback function to run.
  82345. */
  82346. func: (evt: ActionEvent) => void;
  82347. /**
  82348. * Instantiate the action
  82349. * @param triggerOptions defines the trigger options
  82350. * @param func defines the callback function to run
  82351. * @param condition defines the trigger related conditions
  82352. */
  82353. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  82354. /**
  82355. * Execute the action and run the attached code.
  82356. */
  82357. execute(evt: ActionEvent): void;
  82358. }
  82359. /**
  82360. * This defines an action responsible to set the parent property of the target once triggered.
  82361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82362. */
  82363. export class SetParentAction extends Action {
  82364. private _parent;
  82365. private _target;
  82366. /**
  82367. * Instantiate the action
  82368. * @param triggerOptions defines the trigger options
  82369. * @param target defines the target containing the parent property
  82370. * @param parent defines from where the animation should start (animation frame)
  82371. * @param condition defines the trigger related conditions
  82372. */
  82373. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  82374. /** @hidden */
  82375. _prepare(): void;
  82376. /**
  82377. * Execute the action and set the parent property.
  82378. */
  82379. execute(): void;
  82380. /**
  82381. * Serializes the actions and its related information.
  82382. * @param parent defines the object to serialize in
  82383. * @returns the serialized object
  82384. */
  82385. serialize(parent: any): any;
  82386. }
  82387. }
  82388. declare module BABYLON {
  82389. /**
  82390. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  82391. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  82392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82393. */
  82394. export class ActionManager extends AbstractActionManager {
  82395. /**
  82396. * Nothing
  82397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82398. */
  82399. static readonly NothingTrigger: number;
  82400. /**
  82401. * On pick
  82402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82403. */
  82404. static readonly OnPickTrigger: number;
  82405. /**
  82406. * On left pick
  82407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82408. */
  82409. static readonly OnLeftPickTrigger: number;
  82410. /**
  82411. * On right pick
  82412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82413. */
  82414. static readonly OnRightPickTrigger: number;
  82415. /**
  82416. * On center pick
  82417. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82418. */
  82419. static readonly OnCenterPickTrigger: number;
  82420. /**
  82421. * On pick down
  82422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82423. */
  82424. static readonly OnPickDownTrigger: number;
  82425. /**
  82426. * On double pick
  82427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82428. */
  82429. static readonly OnDoublePickTrigger: number;
  82430. /**
  82431. * On pick up
  82432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82433. */
  82434. static readonly OnPickUpTrigger: number;
  82435. /**
  82436. * On pick out.
  82437. * This trigger will only be raised if you also declared a OnPickDown
  82438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82439. */
  82440. static readonly OnPickOutTrigger: number;
  82441. /**
  82442. * On long press
  82443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82444. */
  82445. static readonly OnLongPressTrigger: number;
  82446. /**
  82447. * On pointer over
  82448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82449. */
  82450. static readonly OnPointerOverTrigger: number;
  82451. /**
  82452. * On pointer out
  82453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82454. */
  82455. static readonly OnPointerOutTrigger: number;
  82456. /**
  82457. * On every frame
  82458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82459. */
  82460. static readonly OnEveryFrameTrigger: number;
  82461. /**
  82462. * On intersection enter
  82463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82464. */
  82465. static readonly OnIntersectionEnterTrigger: number;
  82466. /**
  82467. * On intersection exit
  82468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82469. */
  82470. static readonly OnIntersectionExitTrigger: number;
  82471. /**
  82472. * On key down
  82473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82474. */
  82475. static readonly OnKeyDownTrigger: number;
  82476. /**
  82477. * On key up
  82478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82479. */
  82480. static readonly OnKeyUpTrigger: number;
  82481. private _scene;
  82482. /**
  82483. * Creates a new action manager
  82484. * @param scene defines the hosting scene
  82485. */
  82486. constructor(scene: Scene);
  82487. /**
  82488. * Releases all associated resources
  82489. */
  82490. dispose(): void;
  82491. /**
  82492. * Gets hosting scene
  82493. * @returns the hosting scene
  82494. */
  82495. getScene(): Scene;
  82496. /**
  82497. * Does this action manager handles actions of any of the given triggers
  82498. * @param triggers defines the triggers to be tested
  82499. * @return a boolean indicating whether one (or more) of the triggers is handled
  82500. */
  82501. hasSpecificTriggers(triggers: number[]): boolean;
  82502. /**
  82503. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  82504. * speed.
  82505. * @param triggerA defines the trigger to be tested
  82506. * @param triggerB defines the trigger to be tested
  82507. * @return a boolean indicating whether one (or more) of the triggers is handled
  82508. */
  82509. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  82510. /**
  82511. * Does this action manager handles actions of a given trigger
  82512. * @param trigger defines the trigger to be tested
  82513. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  82514. * @return whether the trigger is handled
  82515. */
  82516. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  82517. /**
  82518. * Does this action manager has pointer triggers
  82519. */
  82520. get hasPointerTriggers(): boolean;
  82521. /**
  82522. * Does this action manager has pick triggers
  82523. */
  82524. get hasPickTriggers(): boolean;
  82525. /**
  82526. * Registers an action to this action manager
  82527. * @param action defines the action to be registered
  82528. * @return the action amended (prepared) after registration
  82529. */
  82530. registerAction(action: IAction): Nullable<IAction>;
  82531. /**
  82532. * Unregisters an action to this action manager
  82533. * @param action defines the action to be unregistered
  82534. * @return a boolean indicating whether the action has been unregistered
  82535. */
  82536. unregisterAction(action: IAction): Boolean;
  82537. /**
  82538. * Process a specific trigger
  82539. * @param trigger defines the trigger to process
  82540. * @param evt defines the event details to be processed
  82541. */
  82542. processTrigger(trigger: number, evt?: IActionEvent): void;
  82543. /** @hidden */
  82544. _getEffectiveTarget(target: any, propertyPath: string): any;
  82545. /** @hidden */
  82546. _getProperty(propertyPath: string): string;
  82547. /**
  82548. * Serialize this manager to a JSON object
  82549. * @param name defines the property name to store this manager
  82550. * @returns a JSON representation of this manager
  82551. */
  82552. serialize(name: string): any;
  82553. /**
  82554. * Creates a new ActionManager from a JSON data
  82555. * @param parsedActions defines the JSON data to read from
  82556. * @param object defines the hosting mesh
  82557. * @param scene defines the hosting scene
  82558. */
  82559. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  82560. /**
  82561. * Get a trigger name by index
  82562. * @param trigger defines the trigger index
  82563. * @returns a trigger name
  82564. */
  82565. static GetTriggerName(trigger: number): string;
  82566. }
  82567. }
  82568. declare module BABYLON {
  82569. /**
  82570. * Class representing a ray with position and direction
  82571. */
  82572. export class Ray {
  82573. /** origin point */
  82574. origin: Vector3;
  82575. /** direction */
  82576. direction: Vector3;
  82577. /** length of the ray */
  82578. length: number;
  82579. private static readonly TmpVector3;
  82580. private _tmpRay;
  82581. /**
  82582. * Creates a new ray
  82583. * @param origin origin point
  82584. * @param direction direction
  82585. * @param length length of the ray
  82586. */
  82587. constructor(
  82588. /** origin point */
  82589. origin: Vector3,
  82590. /** direction */
  82591. direction: Vector3,
  82592. /** length of the ray */
  82593. length?: number);
  82594. /**
  82595. * Checks if the ray intersects a box
  82596. * @param minimum bound of the box
  82597. * @param maximum bound of the box
  82598. * @param intersectionTreshold extra extend to be added to the box in all direction
  82599. * @returns if the box was hit
  82600. */
  82601. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82602. /**
  82603. * Checks if the ray intersects a box
  82604. * @param box the bounding box to check
  82605. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82606. * @returns if the box was hit
  82607. */
  82608. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82609. /**
  82610. * If the ray hits a sphere
  82611. * @param sphere the bounding sphere to check
  82612. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82613. * @returns true if it hits the sphere
  82614. */
  82615. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82616. /**
  82617. * If the ray hits a triange
  82618. * @param vertex0 triangle vertex
  82619. * @param vertex1 triangle vertex
  82620. * @param vertex2 triangle vertex
  82621. * @returns intersection information if hit
  82622. */
  82623. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82624. /**
  82625. * Checks if ray intersects a plane
  82626. * @param plane the plane to check
  82627. * @returns the distance away it was hit
  82628. */
  82629. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82630. /**
  82631. * Calculate the intercept of a ray on a given axis
  82632. * @param axis to check 'x' | 'y' | 'z'
  82633. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82634. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82635. */
  82636. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82637. /**
  82638. * Checks if ray intersects a mesh
  82639. * @param mesh the mesh to check
  82640. * @param fastCheck if only the bounding box should checked
  82641. * @returns picking info of the intersecton
  82642. */
  82643. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82644. /**
  82645. * Checks if ray intersects a mesh
  82646. * @param meshes the meshes to check
  82647. * @param fastCheck if only the bounding box should checked
  82648. * @param results array to store result in
  82649. * @returns Array of picking infos
  82650. */
  82651. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82652. private _comparePickingInfo;
  82653. private static smallnum;
  82654. private static rayl;
  82655. /**
  82656. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82657. * @param sega the first point of the segment to test the intersection against
  82658. * @param segb the second point of the segment to test the intersection against
  82659. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82660. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82661. */
  82662. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82663. /**
  82664. * Update the ray from viewport position
  82665. * @param x position
  82666. * @param y y position
  82667. * @param viewportWidth viewport width
  82668. * @param viewportHeight viewport height
  82669. * @param world world matrix
  82670. * @param view view matrix
  82671. * @param projection projection matrix
  82672. * @returns this ray updated
  82673. */
  82674. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82675. /**
  82676. * Creates a ray with origin and direction of 0,0,0
  82677. * @returns the new ray
  82678. */
  82679. static Zero(): Ray;
  82680. /**
  82681. * Creates a new ray from screen space and viewport
  82682. * @param x position
  82683. * @param y y position
  82684. * @param viewportWidth viewport width
  82685. * @param viewportHeight viewport height
  82686. * @param world world matrix
  82687. * @param view view matrix
  82688. * @param projection projection matrix
  82689. * @returns new ray
  82690. */
  82691. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82692. /**
  82693. * 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
  82694. * transformed to the given world matrix.
  82695. * @param origin The origin point
  82696. * @param end The end point
  82697. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82698. * @returns the new ray
  82699. */
  82700. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82701. /**
  82702. * Transforms a ray by a matrix
  82703. * @param ray ray to transform
  82704. * @param matrix matrix to apply
  82705. * @returns the resulting new ray
  82706. */
  82707. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82708. /**
  82709. * Transforms a ray by a matrix
  82710. * @param ray ray to transform
  82711. * @param matrix matrix to apply
  82712. * @param result ray to store result in
  82713. */
  82714. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82715. /**
  82716. * Unproject a ray from screen space to object space
  82717. * @param sourceX defines the screen space x coordinate to use
  82718. * @param sourceY defines the screen space y coordinate to use
  82719. * @param viewportWidth defines the current width of the viewport
  82720. * @param viewportHeight defines the current height of the viewport
  82721. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82722. * @param view defines the view matrix to use
  82723. * @param projection defines the projection matrix to use
  82724. */
  82725. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82726. }
  82727. /**
  82728. * Type used to define predicate used to select faces when a mesh intersection is detected
  82729. */
  82730. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82731. interface Scene {
  82732. /** @hidden */
  82733. _tempPickingRay: Nullable<Ray>;
  82734. /** @hidden */
  82735. _cachedRayForTransform: Ray;
  82736. /** @hidden */
  82737. _pickWithRayInverseMatrix: Matrix;
  82738. /** @hidden */
  82739. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82740. /** @hidden */
  82741. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82742. }
  82743. }
  82744. declare module BABYLON {
  82745. /**
  82746. * Groups all the scene component constants in one place to ease maintenance.
  82747. * @hidden
  82748. */
  82749. export class SceneComponentConstants {
  82750. static readonly NAME_EFFECTLAYER: string;
  82751. static readonly NAME_LAYER: string;
  82752. static readonly NAME_LENSFLARESYSTEM: string;
  82753. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82754. static readonly NAME_PARTICLESYSTEM: string;
  82755. static readonly NAME_GAMEPAD: string;
  82756. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82757. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82758. static readonly NAME_DEPTHRENDERER: string;
  82759. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82760. static readonly NAME_SPRITE: string;
  82761. static readonly NAME_OUTLINERENDERER: string;
  82762. static readonly NAME_PROCEDURALTEXTURE: string;
  82763. static readonly NAME_SHADOWGENERATOR: string;
  82764. static readonly NAME_OCTREE: string;
  82765. static readonly NAME_PHYSICSENGINE: string;
  82766. static readonly NAME_AUDIO: string;
  82767. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82768. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82769. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82770. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82771. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82772. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82773. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82774. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82775. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82776. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82777. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82778. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82779. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82780. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82781. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82782. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82783. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82784. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82785. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82786. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82787. static readonly STEP_AFTERRENDER_AUDIO: number;
  82788. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82789. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82790. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82791. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82792. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82793. static readonly STEP_POINTERMOVE_SPRITE: number;
  82794. static readonly STEP_POINTERDOWN_SPRITE: number;
  82795. static readonly STEP_POINTERUP_SPRITE: number;
  82796. }
  82797. /**
  82798. * This represents a scene component.
  82799. *
  82800. * This is used to decouple the dependency the scene is having on the different workloads like
  82801. * layers, post processes...
  82802. */
  82803. export interface ISceneComponent {
  82804. /**
  82805. * The name of the component. Each component must have a unique name.
  82806. */
  82807. name: string;
  82808. /**
  82809. * The scene the component belongs to.
  82810. */
  82811. scene: Scene;
  82812. /**
  82813. * Register the component to one instance of a scene.
  82814. */
  82815. register(): void;
  82816. /**
  82817. * Rebuilds the elements related to this component in case of
  82818. * context lost for instance.
  82819. */
  82820. rebuild(): void;
  82821. /**
  82822. * Disposes the component and the associated ressources.
  82823. */
  82824. dispose(): void;
  82825. }
  82826. /**
  82827. * This represents a SERIALIZABLE scene component.
  82828. *
  82829. * This extends Scene Component to add Serialization methods on top.
  82830. */
  82831. export interface ISceneSerializableComponent extends ISceneComponent {
  82832. /**
  82833. * Adds all the elements from the container to the scene
  82834. * @param container the container holding the elements
  82835. */
  82836. addFromContainer(container: AbstractScene): void;
  82837. /**
  82838. * Removes all the elements in the container from the scene
  82839. * @param container contains the elements to remove
  82840. * @param dispose if the removed element should be disposed (default: false)
  82841. */
  82842. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82843. /**
  82844. * Serializes the component data to the specified json object
  82845. * @param serializationObject The object to serialize to
  82846. */
  82847. serialize(serializationObject: any): void;
  82848. }
  82849. /**
  82850. * Strong typing of a Mesh related stage step action
  82851. */
  82852. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82853. /**
  82854. * Strong typing of a Evaluate Sub Mesh related stage step action
  82855. */
  82856. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82857. /**
  82858. * Strong typing of a Active Mesh related stage step action
  82859. */
  82860. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82861. /**
  82862. * Strong typing of a Camera related stage step action
  82863. */
  82864. export type CameraStageAction = (camera: Camera) => void;
  82865. /**
  82866. * Strong typing of a Camera Frame buffer related stage step action
  82867. */
  82868. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82869. /**
  82870. * Strong typing of a Render Target related stage step action
  82871. */
  82872. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82873. /**
  82874. * Strong typing of a RenderingGroup related stage step action
  82875. */
  82876. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82877. /**
  82878. * Strong typing of a Mesh Render related stage step action
  82879. */
  82880. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82881. /**
  82882. * Strong typing of a simple stage step action
  82883. */
  82884. export type SimpleStageAction = () => void;
  82885. /**
  82886. * Strong typing of a render target action.
  82887. */
  82888. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82889. /**
  82890. * Strong typing of a pointer move action.
  82891. */
  82892. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82893. /**
  82894. * Strong typing of a pointer up/down action.
  82895. */
  82896. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82897. /**
  82898. * Representation of a stage in the scene (Basically a list of ordered steps)
  82899. * @hidden
  82900. */
  82901. export class Stage<T extends Function> extends Array<{
  82902. index: number;
  82903. component: ISceneComponent;
  82904. action: T;
  82905. }> {
  82906. /**
  82907. * Hide ctor from the rest of the world.
  82908. * @param items The items to add.
  82909. */
  82910. private constructor();
  82911. /**
  82912. * Creates a new Stage.
  82913. * @returns A new instance of a Stage
  82914. */
  82915. static Create<T extends Function>(): Stage<T>;
  82916. /**
  82917. * Registers a step in an ordered way in the targeted stage.
  82918. * @param index Defines the position to register the step in
  82919. * @param component Defines the component attached to the step
  82920. * @param action Defines the action to launch during the step
  82921. */
  82922. registerStep(index: number, component: ISceneComponent, action: T): void;
  82923. /**
  82924. * Clears all the steps from the stage.
  82925. */
  82926. clear(): void;
  82927. }
  82928. }
  82929. declare module BABYLON {
  82930. interface Scene {
  82931. /** @hidden */
  82932. _pointerOverSprite: Nullable<Sprite>;
  82933. /** @hidden */
  82934. _pickedDownSprite: Nullable<Sprite>;
  82935. /** @hidden */
  82936. _tempSpritePickingRay: Nullable<Ray>;
  82937. /**
  82938. * All of the sprite managers added to this scene
  82939. * @see http://doc.babylonjs.com/babylon101/sprites
  82940. */
  82941. spriteManagers: Array<ISpriteManager>;
  82942. /**
  82943. * An event triggered when sprites rendering is about to start
  82944. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82945. */
  82946. onBeforeSpritesRenderingObservable: Observable<Scene>;
  82947. /**
  82948. * An event triggered when sprites rendering is done
  82949. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82950. */
  82951. onAfterSpritesRenderingObservable: Observable<Scene>;
  82952. /** @hidden */
  82953. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82954. /** Launch a ray to try to pick a sprite in the scene
  82955. * @param x position on screen
  82956. * @param y position on screen
  82957. * @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
  82958. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82959. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82960. * @returns a PickingInfo
  82961. */
  82962. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82963. /** Use the given ray to pick a sprite in the scene
  82964. * @param ray The ray (in world space) to use to pick meshes
  82965. * @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
  82966. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82967. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82968. * @returns a PickingInfo
  82969. */
  82970. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82971. /** @hidden */
  82972. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82973. /** Launch a ray to try to pick sprites in the scene
  82974. * @param x position on screen
  82975. * @param y position on screen
  82976. * @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
  82977. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82978. * @returns a PickingInfo array
  82979. */
  82980. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82981. /** Use the given ray to pick sprites in the scene
  82982. * @param ray The ray (in world space) to use to pick meshes
  82983. * @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
  82984. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82985. * @returns a PickingInfo array
  82986. */
  82987. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82988. /**
  82989. * Force the sprite under the pointer
  82990. * @param sprite defines the sprite to use
  82991. */
  82992. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  82993. /**
  82994. * Gets the sprite under the pointer
  82995. * @returns a Sprite or null if no sprite is under the pointer
  82996. */
  82997. getPointerOverSprite(): Nullable<Sprite>;
  82998. }
  82999. /**
  83000. * Defines the sprite scene component responsible to manage sprites
  83001. * in a given scene.
  83002. */
  83003. export class SpriteSceneComponent implements ISceneComponent {
  83004. /**
  83005. * The component name helpfull to identify the component in the list of scene components.
  83006. */
  83007. readonly name: string;
  83008. /**
  83009. * The scene the component belongs to.
  83010. */
  83011. scene: Scene;
  83012. /** @hidden */
  83013. private _spritePredicate;
  83014. /**
  83015. * Creates a new instance of the component for the given scene
  83016. * @param scene Defines the scene to register the component in
  83017. */
  83018. constructor(scene: Scene);
  83019. /**
  83020. * Registers the component in a given scene
  83021. */
  83022. register(): void;
  83023. /**
  83024. * Rebuilds the elements related to this component in case of
  83025. * context lost for instance.
  83026. */
  83027. rebuild(): void;
  83028. /**
  83029. * Disposes the component and the associated ressources.
  83030. */
  83031. dispose(): void;
  83032. private _pickSpriteButKeepRay;
  83033. private _pointerMove;
  83034. private _pointerDown;
  83035. private _pointerUp;
  83036. }
  83037. }
  83038. declare module BABYLON {
  83039. /** @hidden */
  83040. export var fogFragmentDeclaration: {
  83041. name: string;
  83042. shader: string;
  83043. };
  83044. }
  83045. declare module BABYLON {
  83046. /** @hidden */
  83047. export var fogFragment: {
  83048. name: string;
  83049. shader: string;
  83050. };
  83051. }
  83052. declare module BABYLON {
  83053. /** @hidden */
  83054. export var spritesPixelShader: {
  83055. name: string;
  83056. shader: string;
  83057. };
  83058. }
  83059. declare module BABYLON {
  83060. /** @hidden */
  83061. export var fogVertexDeclaration: {
  83062. name: string;
  83063. shader: string;
  83064. };
  83065. }
  83066. declare module BABYLON {
  83067. /** @hidden */
  83068. export var spritesVertexShader: {
  83069. name: string;
  83070. shader: string;
  83071. };
  83072. }
  83073. declare module BABYLON {
  83074. /**
  83075. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83076. */
  83077. export interface ISpriteManager extends IDisposable {
  83078. /**
  83079. * Restricts the camera to viewing objects with the same layerMask.
  83080. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83081. */
  83082. layerMask: number;
  83083. /**
  83084. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83085. */
  83086. isPickable: boolean;
  83087. /**
  83088. * Specifies the rendering group id for this mesh (0 by default)
  83089. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83090. */
  83091. renderingGroupId: number;
  83092. /**
  83093. * Defines the list of sprites managed by the manager.
  83094. */
  83095. sprites: Array<Sprite>;
  83096. /**
  83097. * Tests the intersection of a sprite with a specific ray.
  83098. * @param ray The ray we are sending to test the collision
  83099. * @param camera The camera space we are sending rays in
  83100. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83101. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83102. * @returns picking info or null.
  83103. */
  83104. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83105. /**
  83106. * Intersects the sprites with a ray
  83107. * @param ray defines the ray to intersect with
  83108. * @param camera defines the current active camera
  83109. * @param predicate defines a predicate used to select candidate sprites
  83110. * @returns null if no hit or a PickingInfo array
  83111. */
  83112. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83113. /**
  83114. * Renders the list of sprites on screen.
  83115. */
  83116. render(): void;
  83117. }
  83118. /**
  83119. * Class used to manage multiple sprites on the same spritesheet
  83120. * @see http://doc.babylonjs.com/babylon101/sprites
  83121. */
  83122. export class SpriteManager implements ISpriteManager {
  83123. /** defines the manager's name */
  83124. name: string;
  83125. /** Gets the list of sprites */
  83126. sprites: Sprite[];
  83127. /** Gets or sets the rendering group id (0 by default) */
  83128. renderingGroupId: number;
  83129. /** Gets or sets camera layer mask */
  83130. layerMask: number;
  83131. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83132. fogEnabled: boolean;
  83133. /** Gets or sets a boolean indicating if the sprites are pickable */
  83134. isPickable: boolean;
  83135. /** Defines the default width of a cell in the spritesheet */
  83136. cellWidth: number;
  83137. /** Defines the default height of a cell in the spritesheet */
  83138. cellHeight: number;
  83139. /** Associative array from JSON sprite data file */
  83140. private _cellData;
  83141. /** Array of sprite names from JSON sprite data file */
  83142. private _spriteMap;
  83143. /** True when packed cell data from JSON file is ready*/
  83144. private _packedAndReady;
  83145. /**
  83146. * An event triggered when the manager is disposed.
  83147. */
  83148. onDisposeObservable: Observable<SpriteManager>;
  83149. private _onDisposeObserver;
  83150. /**
  83151. * Callback called when the manager is disposed
  83152. */
  83153. set onDispose(callback: () => void);
  83154. private _capacity;
  83155. private _fromPacked;
  83156. private _spriteTexture;
  83157. private _epsilon;
  83158. private _scene;
  83159. private _vertexData;
  83160. private _buffer;
  83161. private _vertexBuffers;
  83162. private _indexBuffer;
  83163. private _effectBase;
  83164. private _effectFog;
  83165. /**
  83166. * Gets or sets the spritesheet texture
  83167. */
  83168. get texture(): Texture;
  83169. set texture(value: Texture);
  83170. /**
  83171. * Creates a new sprite manager
  83172. * @param name defines the manager's name
  83173. * @param imgUrl defines the sprite sheet url
  83174. * @param capacity defines the maximum allowed number of sprites
  83175. * @param cellSize defines the size of a sprite cell
  83176. * @param scene defines the hosting scene
  83177. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83178. * @param samplingMode defines the smapling mode to use with spritesheet
  83179. * @param fromPacked set to false; do not alter
  83180. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83181. */
  83182. constructor(
  83183. /** defines the manager's name */
  83184. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83185. private _makePacked;
  83186. private _appendSpriteVertex;
  83187. /**
  83188. * Intersects the sprites with a ray
  83189. * @param ray defines the ray to intersect with
  83190. * @param camera defines the current active camera
  83191. * @param predicate defines a predicate used to select candidate sprites
  83192. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83193. * @returns null if no hit or a PickingInfo
  83194. */
  83195. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83196. /**
  83197. * Intersects the sprites with a ray
  83198. * @param ray defines the ray to intersect with
  83199. * @param camera defines the current active camera
  83200. * @param predicate defines a predicate used to select candidate sprites
  83201. * @returns null if no hit or a PickingInfo array
  83202. */
  83203. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83204. /**
  83205. * Render all child sprites
  83206. */
  83207. render(): void;
  83208. /**
  83209. * Release associated resources
  83210. */
  83211. dispose(): void;
  83212. }
  83213. }
  83214. declare module BABYLON {
  83215. /**
  83216. * Class used to represent a sprite
  83217. * @see http://doc.babylonjs.com/babylon101/sprites
  83218. */
  83219. export class Sprite {
  83220. /** defines the name */
  83221. name: string;
  83222. /** Gets or sets the current world position */
  83223. position: Vector3;
  83224. /** Gets or sets the main color */
  83225. color: Color4;
  83226. /** Gets or sets the width */
  83227. width: number;
  83228. /** Gets or sets the height */
  83229. height: number;
  83230. /** Gets or sets rotation angle */
  83231. angle: number;
  83232. /** Gets or sets the cell index in the sprite sheet */
  83233. cellIndex: number;
  83234. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  83235. cellRef: string;
  83236. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  83237. invertU: number;
  83238. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  83239. invertV: number;
  83240. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  83241. disposeWhenFinishedAnimating: boolean;
  83242. /** Gets the list of attached animations */
  83243. animations: Animation[];
  83244. /** Gets or sets a boolean indicating if the sprite can be picked */
  83245. isPickable: boolean;
  83246. /**
  83247. * Gets or sets the associated action manager
  83248. */
  83249. actionManager: Nullable<ActionManager>;
  83250. private _animationStarted;
  83251. private _loopAnimation;
  83252. private _fromIndex;
  83253. private _toIndex;
  83254. private _delay;
  83255. private _direction;
  83256. private _manager;
  83257. private _time;
  83258. private _onAnimationEnd;
  83259. /**
  83260. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  83261. */
  83262. isVisible: boolean;
  83263. /**
  83264. * Gets or sets the sprite size
  83265. */
  83266. get size(): number;
  83267. set size(value: number);
  83268. /**
  83269. * Creates a new Sprite
  83270. * @param name defines the name
  83271. * @param manager defines the manager
  83272. */
  83273. constructor(
  83274. /** defines the name */
  83275. name: string, manager: ISpriteManager);
  83276. /**
  83277. * Starts an animation
  83278. * @param from defines the initial key
  83279. * @param to defines the end key
  83280. * @param loop defines if the animation must loop
  83281. * @param delay defines the start delay (in ms)
  83282. * @param onAnimationEnd defines a callback to call when animation ends
  83283. */
  83284. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  83285. /** Stops current animation (if any) */
  83286. stopAnimation(): void;
  83287. /** @hidden */
  83288. _animate(deltaTime: number): void;
  83289. /** Release associated resources */
  83290. dispose(): void;
  83291. }
  83292. }
  83293. declare module BABYLON {
  83294. /**
  83295. * Information about the result of picking within a scene
  83296. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  83297. */
  83298. export class PickingInfo {
  83299. /** @hidden */
  83300. _pickingUnavailable: boolean;
  83301. /**
  83302. * If the pick collided with an object
  83303. */
  83304. hit: boolean;
  83305. /**
  83306. * Distance away where the pick collided
  83307. */
  83308. distance: number;
  83309. /**
  83310. * The location of pick collision
  83311. */
  83312. pickedPoint: Nullable<Vector3>;
  83313. /**
  83314. * The mesh corresponding the the pick collision
  83315. */
  83316. pickedMesh: Nullable<AbstractMesh>;
  83317. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  83318. bu: number;
  83319. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  83320. bv: number;
  83321. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  83322. faceId: number;
  83323. /** Id of the the submesh that was picked */
  83324. subMeshId: number;
  83325. /** If a sprite was picked, this will be the sprite the pick collided with */
  83326. pickedSprite: Nullable<Sprite>;
  83327. /**
  83328. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  83329. */
  83330. originMesh: Nullable<AbstractMesh>;
  83331. /**
  83332. * The ray that was used to perform the picking.
  83333. */
  83334. ray: Nullable<Ray>;
  83335. /**
  83336. * Gets the normal correspodning to the face the pick collided with
  83337. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  83338. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  83339. * @returns The normal correspodning to the face the pick collided with
  83340. */
  83341. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  83342. /**
  83343. * Gets the texture coordinates of where the pick occured
  83344. * @returns the vector containing the coordnates of the texture
  83345. */
  83346. getTextureCoordinates(): Nullable<Vector2>;
  83347. }
  83348. }
  83349. declare module BABYLON {
  83350. /**
  83351. * Gather the list of pointer event types as constants.
  83352. */
  83353. export class PointerEventTypes {
  83354. /**
  83355. * 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.
  83356. */
  83357. static readonly POINTERDOWN: number;
  83358. /**
  83359. * The pointerup event is fired when a pointer is no longer active.
  83360. */
  83361. static readonly POINTERUP: number;
  83362. /**
  83363. * The pointermove event is fired when a pointer changes coordinates.
  83364. */
  83365. static readonly POINTERMOVE: number;
  83366. /**
  83367. * The pointerwheel event is fired when a mouse wheel has been rotated.
  83368. */
  83369. static readonly POINTERWHEEL: number;
  83370. /**
  83371. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  83372. */
  83373. static readonly POINTERPICK: number;
  83374. /**
  83375. * The pointertap event is fired when a the object has been touched and released without drag.
  83376. */
  83377. static readonly POINTERTAP: number;
  83378. /**
  83379. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  83380. */
  83381. static readonly POINTERDOUBLETAP: number;
  83382. }
  83383. /**
  83384. * Base class of pointer info types.
  83385. */
  83386. export class PointerInfoBase {
  83387. /**
  83388. * Defines the type of event (PointerEventTypes)
  83389. */
  83390. type: number;
  83391. /**
  83392. * Defines the related dom event
  83393. */
  83394. event: PointerEvent | MouseWheelEvent;
  83395. /**
  83396. * Instantiates the base class of pointers info.
  83397. * @param type Defines the type of event (PointerEventTypes)
  83398. * @param event Defines the related dom event
  83399. */
  83400. constructor(
  83401. /**
  83402. * Defines the type of event (PointerEventTypes)
  83403. */
  83404. type: number,
  83405. /**
  83406. * Defines the related dom event
  83407. */
  83408. event: PointerEvent | MouseWheelEvent);
  83409. }
  83410. /**
  83411. * This class is used to store pointer related info for the onPrePointerObservable event.
  83412. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  83413. */
  83414. export class PointerInfoPre extends PointerInfoBase {
  83415. /**
  83416. * Ray from a pointer if availible (eg. 6dof controller)
  83417. */
  83418. ray: Nullable<Ray>;
  83419. /**
  83420. * Defines the local position of the pointer on the canvas.
  83421. */
  83422. localPosition: Vector2;
  83423. /**
  83424. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  83425. */
  83426. skipOnPointerObservable: boolean;
  83427. /**
  83428. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  83429. * @param type Defines the type of event (PointerEventTypes)
  83430. * @param event Defines the related dom event
  83431. * @param localX Defines the local x coordinates of the pointer when the event occured
  83432. * @param localY Defines the local y coordinates of the pointer when the event occured
  83433. */
  83434. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  83435. }
  83436. /**
  83437. * This type contains all the data related to a pointer event in Babylon.js.
  83438. * 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.
  83439. */
  83440. export class PointerInfo extends PointerInfoBase {
  83441. /**
  83442. * Defines the picking info associated to the info (if any)\
  83443. */
  83444. pickInfo: Nullable<PickingInfo>;
  83445. /**
  83446. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  83447. * @param type Defines the type of event (PointerEventTypes)
  83448. * @param event Defines the related dom event
  83449. * @param pickInfo Defines the picking info associated to the info (if any)\
  83450. */
  83451. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  83452. /**
  83453. * Defines the picking info associated to the info (if any)\
  83454. */
  83455. pickInfo: Nullable<PickingInfo>);
  83456. }
  83457. /**
  83458. * Data relating to a touch event on the screen.
  83459. */
  83460. export interface PointerTouch {
  83461. /**
  83462. * X coordinate of touch.
  83463. */
  83464. x: number;
  83465. /**
  83466. * Y coordinate of touch.
  83467. */
  83468. y: number;
  83469. /**
  83470. * Id of touch. Unique for each finger.
  83471. */
  83472. pointerId: number;
  83473. /**
  83474. * Event type passed from DOM.
  83475. */
  83476. type: any;
  83477. }
  83478. }
  83479. declare module BABYLON {
  83480. /**
  83481. * Manage the mouse inputs to control the movement of a free camera.
  83482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83483. */
  83484. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  83485. /**
  83486. * Define if touch is enabled in the mouse input
  83487. */
  83488. touchEnabled: boolean;
  83489. /**
  83490. * Defines the camera the input is attached to.
  83491. */
  83492. camera: FreeCamera;
  83493. /**
  83494. * Defines the buttons associated with the input to handle camera move.
  83495. */
  83496. buttons: number[];
  83497. /**
  83498. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  83499. */
  83500. angularSensibility: number;
  83501. private _pointerInput;
  83502. private _onMouseMove;
  83503. private _observer;
  83504. private previousPosition;
  83505. /**
  83506. * Observable for when a pointer move event occurs containing the move offset
  83507. */
  83508. onPointerMovedObservable: Observable<{
  83509. offsetX: number;
  83510. offsetY: number;
  83511. }>;
  83512. /**
  83513. * @hidden
  83514. * If the camera should be rotated automatically based on pointer movement
  83515. */
  83516. _allowCameraRotation: boolean;
  83517. /**
  83518. * Manage the mouse inputs to control the movement of a free camera.
  83519. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83520. * @param touchEnabled Defines if touch is enabled or not
  83521. */
  83522. constructor(
  83523. /**
  83524. * Define if touch is enabled in the mouse input
  83525. */
  83526. touchEnabled?: boolean);
  83527. /**
  83528. * Attach the input controls to a specific dom element to get the input from.
  83529. * @param element Defines the element the controls should be listened from
  83530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83531. */
  83532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83533. /**
  83534. * Called on JS contextmenu event.
  83535. * Override this method to provide functionality.
  83536. */
  83537. protected onContextMenu(evt: PointerEvent): void;
  83538. /**
  83539. * Detach the current controls from the specified dom element.
  83540. * @param element Defines the element to stop listening the inputs from
  83541. */
  83542. detachControl(element: Nullable<HTMLElement>): void;
  83543. /**
  83544. * Gets the class name of the current intput.
  83545. * @returns the class name
  83546. */
  83547. getClassName(): string;
  83548. /**
  83549. * Get the friendly name associated with the input class.
  83550. * @returns the input friendly name
  83551. */
  83552. getSimpleName(): string;
  83553. }
  83554. }
  83555. declare module BABYLON {
  83556. /**
  83557. * Manage the touch inputs to control the movement of a free camera.
  83558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83559. */
  83560. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  83561. /**
  83562. * Defines the camera the input is attached to.
  83563. */
  83564. camera: FreeCamera;
  83565. /**
  83566. * Defines the touch sensibility for rotation.
  83567. * The higher the faster.
  83568. */
  83569. touchAngularSensibility: number;
  83570. /**
  83571. * Defines the touch sensibility for move.
  83572. * The higher the faster.
  83573. */
  83574. touchMoveSensibility: number;
  83575. private _offsetX;
  83576. private _offsetY;
  83577. private _pointerPressed;
  83578. private _pointerInput;
  83579. private _observer;
  83580. private _onLostFocus;
  83581. /**
  83582. * Attach the input controls to a specific dom element to get the input from.
  83583. * @param element Defines the element the controls should be listened from
  83584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83585. */
  83586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83587. /**
  83588. * Detach the current controls from the specified dom element.
  83589. * @param element Defines the element to stop listening the inputs from
  83590. */
  83591. detachControl(element: Nullable<HTMLElement>): void;
  83592. /**
  83593. * Update the current camera state depending on the inputs that have been used this frame.
  83594. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83595. */
  83596. checkInputs(): void;
  83597. /**
  83598. * Gets the class name of the current intput.
  83599. * @returns the class name
  83600. */
  83601. getClassName(): string;
  83602. /**
  83603. * Get the friendly name associated with the input class.
  83604. * @returns the input friendly name
  83605. */
  83606. getSimpleName(): string;
  83607. }
  83608. }
  83609. declare module BABYLON {
  83610. /**
  83611. * Default Inputs manager for the FreeCamera.
  83612. * It groups all the default supported inputs for ease of use.
  83613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83614. */
  83615. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  83616. /**
  83617. * @hidden
  83618. */
  83619. _mouseInput: Nullable<FreeCameraMouseInput>;
  83620. /**
  83621. * Instantiates a new FreeCameraInputsManager.
  83622. * @param camera Defines the camera the inputs belong to
  83623. */
  83624. constructor(camera: FreeCamera);
  83625. /**
  83626. * Add keyboard input support to the input manager.
  83627. * @returns the current input manager
  83628. */
  83629. addKeyboard(): FreeCameraInputsManager;
  83630. /**
  83631. * Add mouse input support to the input manager.
  83632. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  83633. * @returns the current input manager
  83634. */
  83635. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  83636. /**
  83637. * Removes the mouse input support from the manager
  83638. * @returns the current input manager
  83639. */
  83640. removeMouse(): FreeCameraInputsManager;
  83641. /**
  83642. * Add touch input support to the input manager.
  83643. * @returns the current input manager
  83644. */
  83645. addTouch(): FreeCameraInputsManager;
  83646. /**
  83647. * Remove all attached input methods from a camera
  83648. */
  83649. clear(): void;
  83650. }
  83651. }
  83652. declare module BABYLON {
  83653. /**
  83654. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  83655. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  83656. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  83657. */
  83658. export class FreeCamera extends TargetCamera {
  83659. /**
  83660. * Define the collision ellipsoid of the camera.
  83661. * This is helpful to simulate a camera body like the player body around the camera
  83662. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  83663. */
  83664. ellipsoid: Vector3;
  83665. /**
  83666. * Define an offset for the position of the ellipsoid around the camera.
  83667. * This can be helpful to determine the center of the body near the gravity center of the body
  83668. * instead of its head.
  83669. */
  83670. ellipsoidOffset: Vector3;
  83671. /**
  83672. * Enable or disable collisions of the camera with the rest of the scene objects.
  83673. */
  83674. checkCollisions: boolean;
  83675. /**
  83676. * Enable or disable gravity on the camera.
  83677. */
  83678. applyGravity: boolean;
  83679. /**
  83680. * Define the input manager associated to the camera.
  83681. */
  83682. inputs: FreeCameraInputsManager;
  83683. /**
  83684. * Gets the input sensibility for a mouse input. (default is 2000.0)
  83685. * Higher values reduce sensitivity.
  83686. */
  83687. get angularSensibility(): number;
  83688. /**
  83689. * Sets the input sensibility for a mouse input. (default is 2000.0)
  83690. * Higher values reduce sensitivity.
  83691. */
  83692. set angularSensibility(value: number);
  83693. /**
  83694. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  83695. */
  83696. get keysUp(): number[];
  83697. set keysUp(value: number[]);
  83698. /**
  83699. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  83700. */
  83701. get keysDown(): number[];
  83702. set keysDown(value: number[]);
  83703. /**
  83704. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  83705. */
  83706. get keysLeft(): number[];
  83707. set keysLeft(value: number[]);
  83708. /**
  83709. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  83710. */
  83711. get keysRight(): number[];
  83712. set keysRight(value: number[]);
  83713. /**
  83714. * Event raised when the camera collide with a mesh in the scene.
  83715. */
  83716. onCollide: (collidedMesh: AbstractMesh) => void;
  83717. private _collider;
  83718. private _needMoveForGravity;
  83719. private _oldPosition;
  83720. private _diffPosition;
  83721. private _newPosition;
  83722. /** @hidden */
  83723. _localDirection: Vector3;
  83724. /** @hidden */
  83725. _transformedDirection: Vector3;
  83726. /**
  83727. * Instantiates a Free Camera.
  83728. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  83729. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  83730. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  83731. * @param name Define the name of the camera in the scene
  83732. * @param position Define the start position of the camera in the scene
  83733. * @param scene Define the scene the camera belongs to
  83734. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  83735. */
  83736. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  83737. /**
  83738. * Attached controls to the current camera.
  83739. * @param element Defines the element the controls should be listened from
  83740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83741. */
  83742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83743. /**
  83744. * Detach the current controls from the camera.
  83745. * The camera will stop reacting to inputs.
  83746. * @param element Defines the element to stop listening the inputs from
  83747. */
  83748. detachControl(element: HTMLElement): void;
  83749. private _collisionMask;
  83750. /**
  83751. * Define a collision mask to limit the list of object the camera can collide with
  83752. */
  83753. get collisionMask(): number;
  83754. set collisionMask(mask: number);
  83755. /** @hidden */
  83756. _collideWithWorld(displacement: Vector3): void;
  83757. private _onCollisionPositionChange;
  83758. /** @hidden */
  83759. _checkInputs(): void;
  83760. /** @hidden */
  83761. _decideIfNeedsToMove(): boolean;
  83762. /** @hidden */
  83763. _updatePosition(): void;
  83764. /**
  83765. * Destroy the camera and release the current resources hold by it.
  83766. */
  83767. dispose(): void;
  83768. /**
  83769. * Gets the current object class name.
  83770. * @return the class name
  83771. */
  83772. getClassName(): string;
  83773. }
  83774. }
  83775. declare module BABYLON {
  83776. /**
  83777. * Represents a gamepad control stick position
  83778. */
  83779. export class StickValues {
  83780. /**
  83781. * The x component of the control stick
  83782. */
  83783. x: number;
  83784. /**
  83785. * The y component of the control stick
  83786. */
  83787. y: number;
  83788. /**
  83789. * Initializes the gamepad x and y control stick values
  83790. * @param x The x component of the gamepad control stick value
  83791. * @param y The y component of the gamepad control stick value
  83792. */
  83793. constructor(
  83794. /**
  83795. * The x component of the control stick
  83796. */
  83797. x: number,
  83798. /**
  83799. * The y component of the control stick
  83800. */
  83801. y: number);
  83802. }
  83803. /**
  83804. * An interface which manages callbacks for gamepad button changes
  83805. */
  83806. export interface GamepadButtonChanges {
  83807. /**
  83808. * Called when a gamepad has been changed
  83809. */
  83810. changed: boolean;
  83811. /**
  83812. * Called when a gamepad press event has been triggered
  83813. */
  83814. pressChanged: boolean;
  83815. /**
  83816. * Called when a touch event has been triggered
  83817. */
  83818. touchChanged: boolean;
  83819. /**
  83820. * Called when a value has changed
  83821. */
  83822. valueChanged: boolean;
  83823. }
  83824. /**
  83825. * Represents a gamepad
  83826. */
  83827. export class Gamepad {
  83828. /**
  83829. * The id of the gamepad
  83830. */
  83831. id: string;
  83832. /**
  83833. * The index of the gamepad
  83834. */
  83835. index: number;
  83836. /**
  83837. * The browser gamepad
  83838. */
  83839. browserGamepad: any;
  83840. /**
  83841. * Specifies what type of gamepad this represents
  83842. */
  83843. type: number;
  83844. private _leftStick;
  83845. private _rightStick;
  83846. /** @hidden */
  83847. _isConnected: boolean;
  83848. private _leftStickAxisX;
  83849. private _leftStickAxisY;
  83850. private _rightStickAxisX;
  83851. private _rightStickAxisY;
  83852. /**
  83853. * Triggered when the left control stick has been changed
  83854. */
  83855. private _onleftstickchanged;
  83856. /**
  83857. * Triggered when the right control stick has been changed
  83858. */
  83859. private _onrightstickchanged;
  83860. /**
  83861. * Represents a gamepad controller
  83862. */
  83863. static GAMEPAD: number;
  83864. /**
  83865. * Represents a generic controller
  83866. */
  83867. static GENERIC: number;
  83868. /**
  83869. * Represents an XBox controller
  83870. */
  83871. static XBOX: number;
  83872. /**
  83873. * Represents a pose-enabled controller
  83874. */
  83875. static POSE_ENABLED: number;
  83876. /**
  83877. * Represents an Dual Shock controller
  83878. */
  83879. static DUALSHOCK: number;
  83880. /**
  83881. * Specifies whether the left control stick should be Y-inverted
  83882. */
  83883. protected _invertLeftStickY: boolean;
  83884. /**
  83885. * Specifies if the gamepad has been connected
  83886. */
  83887. get isConnected(): boolean;
  83888. /**
  83889. * Initializes the gamepad
  83890. * @param id The id of the gamepad
  83891. * @param index The index of the gamepad
  83892. * @param browserGamepad The browser gamepad
  83893. * @param leftStickX The x component of the left joystick
  83894. * @param leftStickY The y component of the left joystick
  83895. * @param rightStickX The x component of the right joystick
  83896. * @param rightStickY The y component of the right joystick
  83897. */
  83898. constructor(
  83899. /**
  83900. * The id of the gamepad
  83901. */
  83902. id: string,
  83903. /**
  83904. * The index of the gamepad
  83905. */
  83906. index: number,
  83907. /**
  83908. * The browser gamepad
  83909. */
  83910. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  83911. /**
  83912. * Callback triggered when the left joystick has changed
  83913. * @param callback
  83914. */
  83915. onleftstickchanged(callback: (values: StickValues) => void): void;
  83916. /**
  83917. * Callback triggered when the right joystick has changed
  83918. * @param callback
  83919. */
  83920. onrightstickchanged(callback: (values: StickValues) => void): void;
  83921. /**
  83922. * Gets the left joystick
  83923. */
  83924. get leftStick(): StickValues;
  83925. /**
  83926. * Sets the left joystick values
  83927. */
  83928. set leftStick(newValues: StickValues);
  83929. /**
  83930. * Gets the right joystick
  83931. */
  83932. get rightStick(): StickValues;
  83933. /**
  83934. * Sets the right joystick value
  83935. */
  83936. set rightStick(newValues: StickValues);
  83937. /**
  83938. * Updates the gamepad joystick positions
  83939. */
  83940. update(): void;
  83941. /**
  83942. * Disposes the gamepad
  83943. */
  83944. dispose(): void;
  83945. }
  83946. /**
  83947. * Represents a generic gamepad
  83948. */
  83949. export class GenericPad extends Gamepad {
  83950. private _buttons;
  83951. private _onbuttondown;
  83952. private _onbuttonup;
  83953. /**
  83954. * Observable triggered when a button has been pressed
  83955. */
  83956. onButtonDownObservable: Observable<number>;
  83957. /**
  83958. * Observable triggered when a button has been released
  83959. */
  83960. onButtonUpObservable: Observable<number>;
  83961. /**
  83962. * Callback triggered when a button has been pressed
  83963. * @param callback Called when a button has been pressed
  83964. */
  83965. onbuttondown(callback: (buttonPressed: number) => void): void;
  83966. /**
  83967. * Callback triggered when a button has been released
  83968. * @param callback Called when a button has been released
  83969. */
  83970. onbuttonup(callback: (buttonReleased: number) => void): void;
  83971. /**
  83972. * Initializes the generic gamepad
  83973. * @param id The id of the generic gamepad
  83974. * @param index The index of the generic gamepad
  83975. * @param browserGamepad The browser gamepad
  83976. */
  83977. constructor(id: string, index: number, browserGamepad: any);
  83978. private _setButtonValue;
  83979. /**
  83980. * Updates the generic gamepad
  83981. */
  83982. update(): void;
  83983. /**
  83984. * Disposes the generic gamepad
  83985. */
  83986. dispose(): void;
  83987. }
  83988. }
  83989. declare module BABYLON {
  83990. interface Engine {
  83991. /**
  83992. * Creates a raw texture
  83993. * @param data defines the data to store in the texture
  83994. * @param width defines the width of the texture
  83995. * @param height defines the height of the texture
  83996. * @param format defines the format of the data
  83997. * @param generateMipMaps defines if the engine should generate the mip levels
  83998. * @param invertY defines if data must be stored with Y axis inverted
  83999. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84000. * @param compression defines the compression used (null by default)
  84001. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84002. * @returns the raw texture inside an InternalTexture
  84003. */
  84004. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  84005. /**
  84006. * Update a raw texture
  84007. * @param texture defines the texture to update
  84008. * @param data defines the data to store in the texture
  84009. * @param format defines the format of the data
  84010. * @param invertY defines if data must be stored with Y axis inverted
  84011. */
  84012. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84013. /**
  84014. * Update a raw texture
  84015. * @param texture defines the texture to update
  84016. * @param data defines the data to store in the texture
  84017. * @param format defines the format of the data
  84018. * @param invertY defines if data must be stored with Y axis inverted
  84019. * @param compression defines the compression used (null by default)
  84020. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84021. */
  84022. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  84023. /**
  84024. * Creates a new raw cube texture
  84025. * @param data defines the array of data to use to create each face
  84026. * @param size defines the size of the textures
  84027. * @param format defines the format of the data
  84028. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84029. * @param generateMipMaps defines if the engine should generate the mip levels
  84030. * @param invertY defines if data must be stored with Y axis inverted
  84031. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84032. * @param compression defines the compression used (null by default)
  84033. * @returns the cube texture as an InternalTexture
  84034. */
  84035. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  84036. /**
  84037. * Update a raw cube texture
  84038. * @param texture defines the texture to udpdate
  84039. * @param data defines the data to store
  84040. * @param format defines the data format
  84041. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84042. * @param invertY defines if data must be stored with Y axis inverted
  84043. */
  84044. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  84045. /**
  84046. * Update a raw cube texture
  84047. * @param texture defines the texture to udpdate
  84048. * @param data defines the data to store
  84049. * @param format defines the data format
  84050. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84051. * @param invertY defines if data must be stored with Y axis inverted
  84052. * @param compression defines the compression used (null by default)
  84053. */
  84054. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84055. /**
  84056. * Update a raw cube texture
  84057. * @param texture defines the texture to udpdate
  84058. * @param data defines the data to store
  84059. * @param format defines the data format
  84060. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84061. * @param invertY defines if data must be stored with Y axis inverted
  84062. * @param compression defines the compression used (null by default)
  84063. * @param level defines which level of the texture to update
  84064. */
  84065. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84066. /**
  84067. * Creates a new raw cube texture from a specified url
  84068. * @param url defines the url where the data is located
  84069. * @param scene defines the current scene
  84070. * @param size defines the size of the textures
  84071. * @param format defines the format of the data
  84072. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84073. * @param noMipmap defines if the engine should avoid generating the mip levels
  84074. * @param callback defines a callback used to extract texture data from loaded data
  84075. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84076. * @param onLoad defines a callback called when texture is loaded
  84077. * @param onError defines a callback called if there is an error
  84078. * @returns the cube texture as an InternalTexture
  84079. */
  84080. 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;
  84081. /**
  84082. * Creates a new raw cube texture from a specified url
  84083. * @param url defines the url where the data is located
  84084. * @param scene defines the current scene
  84085. * @param size defines the size of the textures
  84086. * @param format defines the format of the data
  84087. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84088. * @param noMipmap defines if the engine should avoid generating the mip levels
  84089. * @param callback defines a callback used to extract texture data from loaded data
  84090. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84091. * @param onLoad defines a callback called when texture is loaded
  84092. * @param onError defines a callback called if there is an error
  84093. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84094. * @param invertY defines if data must be stored with Y axis inverted
  84095. * @returns the cube texture as an InternalTexture
  84096. */
  84097. 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;
  84098. /**
  84099. * Creates a new raw 3D texture
  84100. * @param data defines the data used to create the texture
  84101. * @param width defines the width of the texture
  84102. * @param height defines the height of the texture
  84103. * @param depth defines the depth of the texture
  84104. * @param format defines the format of the texture
  84105. * @param generateMipMaps defines if the engine must generate mip levels
  84106. * @param invertY defines if data must be stored with Y axis inverted
  84107. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84108. * @param compression defines the compressed used (can be null)
  84109. * @param textureType defines the compressed used (can be null)
  84110. * @returns a new raw 3D texture (stored in an InternalTexture)
  84111. */
  84112. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84113. /**
  84114. * Update a raw 3D texture
  84115. * @param texture defines the texture to update
  84116. * @param data defines the data to store
  84117. * @param format defines the data format
  84118. * @param invertY defines if data must be stored with Y axis inverted
  84119. */
  84120. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84121. /**
  84122. * Update a raw 3D 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. * @param compression defines the used compression (can be null)
  84128. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84129. */
  84130. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84131. /**
  84132. * Creates a new raw 2D array texture
  84133. * @param data defines the data used to create the texture
  84134. * @param width defines the width of the texture
  84135. * @param height defines the height of the texture
  84136. * @param depth defines the number of layers of the texture
  84137. * @param format defines the format of the texture
  84138. * @param generateMipMaps defines if the engine must generate mip levels
  84139. * @param invertY defines if data must be stored with Y axis inverted
  84140. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84141. * @param compression defines the compressed used (can be null)
  84142. * @param textureType defines the compressed used (can be null)
  84143. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84144. */
  84145. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84146. /**
  84147. * Update a raw 2D array texture
  84148. * @param texture defines the texture to update
  84149. * @param data defines the data to store
  84150. * @param format defines the data format
  84151. * @param invertY defines if data must be stored with Y axis inverted
  84152. */
  84153. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84154. /**
  84155. * Update a raw 2D array texture
  84156. * @param texture defines the texture to update
  84157. * @param data defines the data to store
  84158. * @param format defines the data format
  84159. * @param invertY defines if data must be stored with Y axis inverted
  84160. * @param compression defines the used compression (can be null)
  84161. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84162. */
  84163. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84164. }
  84165. }
  84166. declare module BABYLON {
  84167. /**
  84168. * Raw texture can help creating a texture directly from an array of data.
  84169. * This can be super useful if you either get the data from an uncompressed source or
  84170. * if you wish to create your texture pixel by pixel.
  84171. */
  84172. export class RawTexture extends Texture {
  84173. /**
  84174. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84175. */
  84176. format: number;
  84177. private _engine;
  84178. /**
  84179. * Instantiates a new RawTexture.
  84180. * Raw texture can help creating a texture directly from an array of data.
  84181. * This can be super useful if you either get the data from an uncompressed source or
  84182. * if you wish to create your texture pixel by pixel.
  84183. * @param data define the array of data to use to create the texture
  84184. * @param width define the width of the texture
  84185. * @param height define the height of the texture
  84186. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84187. * @param scene define the scene the texture belongs to
  84188. * @param generateMipMaps define whether mip maps should be generated or not
  84189. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84190. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84191. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84192. */
  84193. constructor(data: ArrayBufferView, width: number, height: number,
  84194. /**
  84195. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84196. */
  84197. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84198. /**
  84199. * Updates the texture underlying data.
  84200. * @param data Define the new data of the texture
  84201. */
  84202. update(data: ArrayBufferView): void;
  84203. /**
  84204. * Creates a luminance texture from some data.
  84205. * @param data Define the texture data
  84206. * @param width Define the width of the texture
  84207. * @param height Define the height of the texture
  84208. * @param scene Define the scene the texture belongs to
  84209. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84210. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84211. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84212. * @returns the luminance texture
  84213. */
  84214. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84215. /**
  84216. * Creates a luminance alpha texture from some data.
  84217. * @param data Define the texture data
  84218. * @param width Define the width of the texture
  84219. * @param height Define the height of the texture
  84220. * @param scene Define the scene the texture belongs to
  84221. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84222. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84223. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84224. * @returns the luminance alpha texture
  84225. */
  84226. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84227. /**
  84228. * Creates an alpha 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. * @returns the alpha texture
  84237. */
  84238. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84239. /**
  84240. * Creates a RGB texture from some data.
  84241. * @param data Define the texture data
  84242. * @param width Define the width of the texture
  84243. * @param height Define the height of the texture
  84244. * @param scene Define the scene the texture belongs to
  84245. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84246. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84247. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84248. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84249. * @returns the RGB alpha texture
  84250. */
  84251. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84252. /**
  84253. * Creates a RGBA texture from some data.
  84254. * @param data Define the texture data
  84255. * @param width Define the width of the texture
  84256. * @param height Define the height of the texture
  84257. * @param scene Define the scene the texture belongs to
  84258. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84259. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84260. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84261. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84262. * @returns the RGBA texture
  84263. */
  84264. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84265. /**
  84266. * Creates a R texture from some data.
  84267. * @param data Define the texture data
  84268. * @param width Define the width of the texture
  84269. * @param height Define the height of the texture
  84270. * @param scene Define the scene the texture belongs to
  84271. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84272. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84273. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84274. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84275. * @returns the R texture
  84276. */
  84277. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84278. }
  84279. }
  84280. declare module BABYLON {
  84281. /**
  84282. * Interface for the size containing width and height
  84283. */
  84284. export interface ISize {
  84285. /**
  84286. * Width
  84287. */
  84288. width: number;
  84289. /**
  84290. * Heighht
  84291. */
  84292. height: number;
  84293. }
  84294. /**
  84295. * Size containing widht and height
  84296. */
  84297. export class Size implements ISize {
  84298. /**
  84299. * Width
  84300. */
  84301. width: number;
  84302. /**
  84303. * Height
  84304. */
  84305. height: number;
  84306. /**
  84307. * Creates a Size object from the given width and height (floats).
  84308. * @param width width of the new size
  84309. * @param height height of the new size
  84310. */
  84311. constructor(width: number, height: number);
  84312. /**
  84313. * Returns a string with the Size width and height
  84314. * @returns a string with the Size width and height
  84315. */
  84316. toString(): string;
  84317. /**
  84318. * "Size"
  84319. * @returns the string "Size"
  84320. */
  84321. getClassName(): string;
  84322. /**
  84323. * Returns the Size hash code.
  84324. * @returns a hash code for a unique width and height
  84325. */
  84326. getHashCode(): number;
  84327. /**
  84328. * Updates the current size from the given one.
  84329. * @param src the given size
  84330. */
  84331. copyFrom(src: Size): void;
  84332. /**
  84333. * Updates in place the current Size from the given floats.
  84334. * @param width width of the new size
  84335. * @param height height of the new size
  84336. * @returns the updated Size.
  84337. */
  84338. copyFromFloats(width: number, height: number): Size;
  84339. /**
  84340. * Updates in place the current Size from the given floats.
  84341. * @param width width to set
  84342. * @param height height to set
  84343. * @returns the updated Size.
  84344. */
  84345. set(width: number, height: number): Size;
  84346. /**
  84347. * Multiplies the width and height by numbers
  84348. * @param w factor to multiple the width by
  84349. * @param h factor to multiple the height by
  84350. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  84351. */
  84352. multiplyByFloats(w: number, h: number): Size;
  84353. /**
  84354. * Clones the size
  84355. * @returns a new Size copied from the given one.
  84356. */
  84357. clone(): Size;
  84358. /**
  84359. * True if the current Size and the given one width and height are strictly equal.
  84360. * @param other the other size to compare against
  84361. * @returns True if the current Size and the given one width and height are strictly equal.
  84362. */
  84363. equals(other: Size): boolean;
  84364. /**
  84365. * The surface of the Size : width * height (float).
  84366. */
  84367. get surface(): number;
  84368. /**
  84369. * Create a new size of zero
  84370. * @returns a new Size set to (0.0, 0.0)
  84371. */
  84372. static Zero(): Size;
  84373. /**
  84374. * Sums the width and height of two sizes
  84375. * @param otherSize size to add to this size
  84376. * @returns a new Size set as the addition result of the current Size and the given one.
  84377. */
  84378. add(otherSize: Size): Size;
  84379. /**
  84380. * Subtracts the width and height of two
  84381. * @param otherSize size to subtract to this size
  84382. * @returns a new Size set as the subtraction result of the given one from the current Size.
  84383. */
  84384. subtract(otherSize: Size): Size;
  84385. /**
  84386. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  84387. * @param start starting size to lerp between
  84388. * @param end end size to lerp between
  84389. * @param amount amount to lerp between the start and end values
  84390. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  84391. */
  84392. static Lerp(start: Size, end: Size, amount: number): Size;
  84393. }
  84394. }
  84395. declare module BABYLON {
  84396. /**
  84397. * Defines a runtime animation
  84398. */
  84399. export class RuntimeAnimation {
  84400. private _events;
  84401. /**
  84402. * The current frame of the runtime animation
  84403. */
  84404. private _currentFrame;
  84405. /**
  84406. * The animation used by the runtime animation
  84407. */
  84408. private _animation;
  84409. /**
  84410. * The target of the runtime animation
  84411. */
  84412. private _target;
  84413. /**
  84414. * The initiating animatable
  84415. */
  84416. private _host;
  84417. /**
  84418. * The original value of the runtime animation
  84419. */
  84420. private _originalValue;
  84421. /**
  84422. * The original blend value of the runtime animation
  84423. */
  84424. private _originalBlendValue;
  84425. /**
  84426. * The offsets cache of the runtime animation
  84427. */
  84428. private _offsetsCache;
  84429. /**
  84430. * The high limits cache of the runtime animation
  84431. */
  84432. private _highLimitsCache;
  84433. /**
  84434. * Specifies if the runtime animation has been stopped
  84435. */
  84436. private _stopped;
  84437. /**
  84438. * The blending factor of the runtime animation
  84439. */
  84440. private _blendingFactor;
  84441. /**
  84442. * The BabylonJS scene
  84443. */
  84444. private _scene;
  84445. /**
  84446. * The current value of the runtime animation
  84447. */
  84448. private _currentValue;
  84449. /** @hidden */
  84450. _animationState: _IAnimationState;
  84451. /**
  84452. * The active target of the runtime animation
  84453. */
  84454. private _activeTargets;
  84455. private _currentActiveTarget;
  84456. private _directTarget;
  84457. /**
  84458. * The target path of the runtime animation
  84459. */
  84460. private _targetPath;
  84461. /**
  84462. * The weight of the runtime animation
  84463. */
  84464. private _weight;
  84465. /**
  84466. * The ratio offset of the runtime animation
  84467. */
  84468. private _ratioOffset;
  84469. /**
  84470. * The previous delay of the runtime animation
  84471. */
  84472. private _previousDelay;
  84473. /**
  84474. * The previous ratio of the runtime animation
  84475. */
  84476. private _previousRatio;
  84477. private _enableBlending;
  84478. private _keys;
  84479. private _minFrame;
  84480. private _maxFrame;
  84481. private _minValue;
  84482. private _maxValue;
  84483. private _targetIsArray;
  84484. /**
  84485. * Gets the current frame of the runtime animation
  84486. */
  84487. get currentFrame(): number;
  84488. /**
  84489. * Gets the weight of the runtime animation
  84490. */
  84491. get weight(): number;
  84492. /**
  84493. * Gets the current value of the runtime animation
  84494. */
  84495. get currentValue(): any;
  84496. /**
  84497. * Gets the target path of the runtime animation
  84498. */
  84499. get targetPath(): string;
  84500. /**
  84501. * Gets the actual target of the runtime animation
  84502. */
  84503. get target(): any;
  84504. /** @hidden */
  84505. _onLoop: () => void;
  84506. /**
  84507. * Create a new RuntimeAnimation object
  84508. * @param target defines the target of the animation
  84509. * @param animation defines the source animation object
  84510. * @param scene defines the hosting scene
  84511. * @param host defines the initiating Animatable
  84512. */
  84513. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  84514. private _preparePath;
  84515. /**
  84516. * Gets the animation from the runtime animation
  84517. */
  84518. get animation(): Animation;
  84519. /**
  84520. * Resets the runtime animation to the beginning
  84521. * @param restoreOriginal defines whether to restore the target property to the original value
  84522. */
  84523. reset(restoreOriginal?: boolean): void;
  84524. /**
  84525. * Specifies if the runtime animation is stopped
  84526. * @returns Boolean specifying if the runtime animation is stopped
  84527. */
  84528. isStopped(): boolean;
  84529. /**
  84530. * Disposes of the runtime animation
  84531. */
  84532. dispose(): void;
  84533. /**
  84534. * Apply the interpolated value to the target
  84535. * @param currentValue defines the value computed by the animation
  84536. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  84537. */
  84538. setValue(currentValue: any, weight: number): void;
  84539. private _getOriginalValues;
  84540. private _setValue;
  84541. /**
  84542. * Gets the loop pmode of the runtime animation
  84543. * @returns Loop Mode
  84544. */
  84545. private _getCorrectLoopMode;
  84546. /**
  84547. * Move the current animation to a given frame
  84548. * @param frame defines the frame to move to
  84549. */
  84550. goToFrame(frame: number): void;
  84551. /**
  84552. * @hidden Internal use only
  84553. */
  84554. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  84555. /**
  84556. * Execute the current animation
  84557. * @param delay defines the delay to add to the current frame
  84558. * @param from defines the lower bound of the animation range
  84559. * @param to defines the upper bound of the animation range
  84560. * @param loop defines if the current animation must loop
  84561. * @param speedRatio defines the current speed ratio
  84562. * @param weight defines the weight of the animation (default is -1 so no weight)
  84563. * @param onLoop optional callback called when animation loops
  84564. * @returns a boolean indicating if the animation is running
  84565. */
  84566. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  84567. }
  84568. }
  84569. declare module BABYLON {
  84570. /**
  84571. * Class used to store an actual running animation
  84572. */
  84573. export class Animatable {
  84574. /** defines the target object */
  84575. target: any;
  84576. /** defines the starting frame number (default is 0) */
  84577. fromFrame: number;
  84578. /** defines the ending frame number (default is 100) */
  84579. toFrame: number;
  84580. /** defines if the animation must loop (default is false) */
  84581. loopAnimation: boolean;
  84582. /** defines a callback to call when animation ends if it is not looping */
  84583. onAnimationEnd?: (() => void) | null | undefined;
  84584. /** defines a callback to call when animation loops */
  84585. onAnimationLoop?: (() => void) | null | undefined;
  84586. private _localDelayOffset;
  84587. private _pausedDelay;
  84588. private _runtimeAnimations;
  84589. private _paused;
  84590. private _scene;
  84591. private _speedRatio;
  84592. private _weight;
  84593. private _syncRoot;
  84594. /**
  84595. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  84596. * This will only apply for non looping animation (default is true)
  84597. */
  84598. disposeOnEnd: boolean;
  84599. /**
  84600. * Gets a boolean indicating if the animation has started
  84601. */
  84602. animationStarted: boolean;
  84603. /**
  84604. * Observer raised when the animation ends
  84605. */
  84606. onAnimationEndObservable: Observable<Animatable>;
  84607. /**
  84608. * Observer raised when the animation loops
  84609. */
  84610. onAnimationLoopObservable: Observable<Animatable>;
  84611. /**
  84612. * Gets the root Animatable used to synchronize and normalize animations
  84613. */
  84614. get syncRoot(): Nullable<Animatable>;
  84615. /**
  84616. * Gets the current frame of the first RuntimeAnimation
  84617. * Used to synchronize Animatables
  84618. */
  84619. get masterFrame(): number;
  84620. /**
  84621. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  84622. */
  84623. get weight(): number;
  84624. set weight(value: number);
  84625. /**
  84626. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  84627. */
  84628. get speedRatio(): number;
  84629. set speedRatio(value: number);
  84630. /**
  84631. * Creates a new Animatable
  84632. * @param scene defines the hosting scene
  84633. * @param target defines the target object
  84634. * @param fromFrame defines the starting frame number (default is 0)
  84635. * @param toFrame defines the ending frame number (default is 100)
  84636. * @param loopAnimation defines if the animation must loop (default is false)
  84637. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  84638. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  84639. * @param animations defines a group of animation to add to the new Animatable
  84640. * @param onAnimationLoop defines a callback to call when animation loops
  84641. */
  84642. constructor(scene: Scene,
  84643. /** defines the target object */
  84644. target: any,
  84645. /** defines the starting frame number (default is 0) */
  84646. fromFrame?: number,
  84647. /** defines the ending frame number (default is 100) */
  84648. toFrame?: number,
  84649. /** defines if the animation must loop (default is false) */
  84650. loopAnimation?: boolean, speedRatio?: number,
  84651. /** defines a callback to call when animation ends if it is not looping */
  84652. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  84653. /** defines a callback to call when animation loops */
  84654. onAnimationLoop?: (() => void) | null | undefined);
  84655. /**
  84656. * Synchronize and normalize current Animatable with a source Animatable
  84657. * This is useful when using animation weights and when animations are not of the same length
  84658. * @param root defines the root Animatable to synchronize with
  84659. * @returns the current Animatable
  84660. */
  84661. syncWith(root: Animatable): Animatable;
  84662. /**
  84663. * Gets the list of runtime animations
  84664. * @returns an array of RuntimeAnimation
  84665. */
  84666. getAnimations(): RuntimeAnimation[];
  84667. /**
  84668. * Adds more animations to the current animatable
  84669. * @param target defines the target of the animations
  84670. * @param animations defines the new animations to add
  84671. */
  84672. appendAnimations(target: any, animations: Animation[]): void;
  84673. /**
  84674. * Gets the source animation for a specific property
  84675. * @param property defines the propertyu to look for
  84676. * @returns null or the source animation for the given property
  84677. */
  84678. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  84679. /**
  84680. * Gets the runtime animation for a specific property
  84681. * @param property defines the propertyu to look for
  84682. * @returns null or the runtime animation for the given property
  84683. */
  84684. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  84685. /**
  84686. * Resets the animatable to its original state
  84687. */
  84688. reset(): void;
  84689. /**
  84690. * Allows the animatable to blend with current running animations
  84691. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84692. * @param blendingSpeed defines the blending speed to use
  84693. */
  84694. enableBlending(blendingSpeed: number): void;
  84695. /**
  84696. * Disable animation blending
  84697. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84698. */
  84699. disableBlending(): void;
  84700. /**
  84701. * Jump directly to a given frame
  84702. * @param frame defines the frame to jump to
  84703. */
  84704. goToFrame(frame: number): void;
  84705. /**
  84706. * Pause the animation
  84707. */
  84708. pause(): void;
  84709. /**
  84710. * Restart the animation
  84711. */
  84712. restart(): void;
  84713. private _raiseOnAnimationEnd;
  84714. /**
  84715. * Stop and delete the current animation
  84716. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  84717. * @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)
  84718. */
  84719. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  84720. /**
  84721. * Wait asynchronously for the animation to end
  84722. * @returns a promise which will be fullfilled when the animation ends
  84723. */
  84724. waitAsync(): Promise<Animatable>;
  84725. /** @hidden */
  84726. _animate(delay: number): boolean;
  84727. }
  84728. interface Scene {
  84729. /** @hidden */
  84730. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  84731. /** @hidden */
  84732. _processLateAnimationBindingsForMatrices(holder: {
  84733. totalWeight: number;
  84734. animations: RuntimeAnimation[];
  84735. originalValue: Matrix;
  84736. }): any;
  84737. /** @hidden */
  84738. _processLateAnimationBindingsForQuaternions(holder: {
  84739. totalWeight: number;
  84740. animations: RuntimeAnimation[];
  84741. originalValue: Quaternion;
  84742. }, refQuaternion: Quaternion): Quaternion;
  84743. /** @hidden */
  84744. _processLateAnimationBindings(): void;
  84745. /**
  84746. * Will start the animation sequence of a given target
  84747. * @param target defines the target
  84748. * @param from defines from which frame should animation start
  84749. * @param to defines until which frame should animation run.
  84750. * @param weight defines the weight to apply to the animation (1.0 by default)
  84751. * @param loop defines if the animation loops
  84752. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84753. * @param onAnimationEnd defines the function to be executed when the animation ends
  84754. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84755. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  84756. * @param onAnimationLoop defines the callback to call when an animation loops
  84757. * @returns the animatable object created for this animation
  84758. */
  84759. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  84760. /**
  84761. * Will start the animation sequence of a given target
  84762. * @param target defines the target
  84763. * @param from defines from which frame should animation start
  84764. * @param to defines until which frame should animation run.
  84765. * @param loop defines if the animation loops
  84766. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84767. * @param onAnimationEnd defines the function to be executed when the animation ends
  84768. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84769. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  84770. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  84771. * @param onAnimationLoop defines the callback to call when an animation loops
  84772. * @returns the animatable object created for this animation
  84773. */
  84774. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  84775. /**
  84776. * Will start the animation sequence of a given target and its hierarchy
  84777. * @param target defines the target
  84778. * @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.
  84779. * @param from defines from which frame should animation start
  84780. * @param to defines until which frame should animation run.
  84781. * @param loop defines if the animation loops
  84782. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84783. * @param onAnimationEnd defines the function to be executed when the animation ends
  84784. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84785. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  84786. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  84787. * @param onAnimationLoop defines the callback to call when an animation loops
  84788. * @returns the list of created animatables
  84789. */
  84790. 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[];
  84791. /**
  84792. * Begin a new animation on a given node
  84793. * @param target defines the target where the animation will take place
  84794. * @param animations defines the list of animations to start
  84795. * @param from defines the initial value
  84796. * @param to defines the final value
  84797. * @param loop defines if you want animation to loop (off by default)
  84798. * @param speedRatio defines the speed ratio to apply to all animations
  84799. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84800. * @param onAnimationLoop defines the callback to call when an animation loops
  84801. * @returns the list of created animatables
  84802. */
  84803. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  84804. /**
  84805. * Begin a new animation on a given node and its hierarchy
  84806. * @param target defines the root node where the animation will take place
  84807. * @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.
  84808. * @param animations defines the list of animations to start
  84809. * @param from defines the initial value
  84810. * @param to defines the final value
  84811. * @param loop defines if you want animation to loop (off by default)
  84812. * @param speedRatio defines the speed ratio to apply to all animations
  84813. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84814. * @param onAnimationLoop defines the callback to call when an animation loops
  84815. * @returns the list of animatables created for all nodes
  84816. */
  84817. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  84818. /**
  84819. * Gets the animatable associated with a specific target
  84820. * @param target defines the target of the animatable
  84821. * @returns the required animatable if found
  84822. */
  84823. getAnimatableByTarget(target: any): Nullable<Animatable>;
  84824. /**
  84825. * Gets all animatables associated with a given target
  84826. * @param target defines the target to look animatables for
  84827. * @returns an array of Animatables
  84828. */
  84829. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  84830. /**
  84831. * Stops and removes all animations that have been applied to the scene
  84832. */
  84833. stopAllAnimations(): void;
  84834. /**
  84835. * Gets the current delta time used by animation engine
  84836. */
  84837. deltaTime: number;
  84838. }
  84839. interface Bone {
  84840. /**
  84841. * Copy an animation range from another bone
  84842. * @param source defines the source bone
  84843. * @param rangeName defines the range name to copy
  84844. * @param frameOffset defines the frame offset
  84845. * @param rescaleAsRequired defines if rescaling must be applied if required
  84846. * @param skelDimensionsRatio defines the scaling ratio
  84847. * @returns true if operation was successful
  84848. */
  84849. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  84850. }
  84851. }
  84852. declare module BABYLON {
  84853. /**
  84854. * Class used to override all child animations of a given target
  84855. */
  84856. export class AnimationPropertiesOverride {
  84857. /**
  84858. * Gets or sets a value indicating if animation blending must be used
  84859. */
  84860. enableBlending: boolean;
  84861. /**
  84862. * Gets or sets the blending speed to use when enableBlending is true
  84863. */
  84864. blendingSpeed: number;
  84865. /**
  84866. * Gets or sets the default loop mode to use
  84867. */
  84868. loopMode: number;
  84869. }
  84870. }
  84871. declare module BABYLON {
  84872. /**
  84873. * Class used to handle skinning animations
  84874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84875. */
  84876. export class Skeleton implements IAnimatable {
  84877. /** defines the skeleton name */
  84878. name: string;
  84879. /** defines the skeleton Id */
  84880. id: string;
  84881. /**
  84882. * Defines the list of child bones
  84883. */
  84884. bones: Bone[];
  84885. /**
  84886. * Defines an estimate of the dimension of the skeleton at rest
  84887. */
  84888. dimensionsAtRest: Vector3;
  84889. /**
  84890. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  84891. */
  84892. needInitialSkinMatrix: boolean;
  84893. /**
  84894. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  84895. */
  84896. overrideMesh: Nullable<AbstractMesh>;
  84897. /**
  84898. * Gets the list of animations attached to this skeleton
  84899. */
  84900. animations: Array<Animation>;
  84901. private _scene;
  84902. private _isDirty;
  84903. private _transformMatrices;
  84904. private _transformMatrixTexture;
  84905. private _meshesWithPoseMatrix;
  84906. private _animatables;
  84907. private _identity;
  84908. private _synchronizedWithMesh;
  84909. private _ranges;
  84910. private _lastAbsoluteTransformsUpdateId;
  84911. private _canUseTextureForBones;
  84912. private _uniqueId;
  84913. /** @hidden */
  84914. _numBonesWithLinkedTransformNode: number;
  84915. /** @hidden */
  84916. _hasWaitingData: Nullable<boolean>;
  84917. /**
  84918. * Specifies if the skeleton should be serialized
  84919. */
  84920. doNotSerialize: boolean;
  84921. private _useTextureToStoreBoneMatrices;
  84922. /**
  84923. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  84924. * Please note that this option is not available if the hardware does not support it
  84925. */
  84926. get useTextureToStoreBoneMatrices(): boolean;
  84927. set useTextureToStoreBoneMatrices(value: boolean);
  84928. private _animationPropertiesOverride;
  84929. /**
  84930. * Gets or sets the animation properties override
  84931. */
  84932. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84933. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  84934. /**
  84935. * List of inspectable custom properties (used by the Inspector)
  84936. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84937. */
  84938. inspectableCustomProperties: IInspectable[];
  84939. /**
  84940. * An observable triggered before computing the skeleton's matrices
  84941. */
  84942. onBeforeComputeObservable: Observable<Skeleton>;
  84943. /**
  84944. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  84945. */
  84946. get isUsingTextureForMatrices(): boolean;
  84947. /**
  84948. * Gets the unique ID of this skeleton
  84949. */
  84950. get uniqueId(): number;
  84951. /**
  84952. * Creates a new skeleton
  84953. * @param name defines the skeleton name
  84954. * @param id defines the skeleton Id
  84955. * @param scene defines the hosting scene
  84956. */
  84957. constructor(
  84958. /** defines the skeleton name */
  84959. name: string,
  84960. /** defines the skeleton Id */
  84961. id: string, scene: Scene);
  84962. /**
  84963. * Gets the current object class name.
  84964. * @return the class name
  84965. */
  84966. getClassName(): string;
  84967. /**
  84968. * Returns an array containing the root bones
  84969. * @returns an array containing the root bones
  84970. */
  84971. getChildren(): Array<Bone>;
  84972. /**
  84973. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  84974. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84975. * @returns a Float32Array containing matrices data
  84976. */
  84977. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  84978. /**
  84979. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  84980. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84981. * @returns a raw texture containing the data
  84982. */
  84983. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  84984. /**
  84985. * Gets the current hosting scene
  84986. * @returns a scene object
  84987. */
  84988. getScene(): Scene;
  84989. /**
  84990. * Gets a string representing the current skeleton data
  84991. * @param fullDetails defines a boolean indicating if we want a verbose version
  84992. * @returns a string representing the current skeleton data
  84993. */
  84994. toString(fullDetails?: boolean): string;
  84995. /**
  84996. * Get bone's index searching by name
  84997. * @param name defines bone's name to search for
  84998. * @return the indice of the bone. Returns -1 if not found
  84999. */
  85000. getBoneIndexByName(name: string): number;
  85001. /**
  85002. * Creater a new animation range
  85003. * @param name defines the name of the range
  85004. * @param from defines the start key
  85005. * @param to defines the end key
  85006. */
  85007. createAnimationRange(name: string, from: number, to: number): void;
  85008. /**
  85009. * Delete a specific animation range
  85010. * @param name defines the name of the range
  85011. * @param deleteFrames defines if frames must be removed as well
  85012. */
  85013. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85014. /**
  85015. * Gets a specific animation range
  85016. * @param name defines the name of the range to look for
  85017. * @returns the requested animation range or null if not found
  85018. */
  85019. getAnimationRange(name: string): Nullable<AnimationRange>;
  85020. /**
  85021. * Gets the list of all animation ranges defined on this skeleton
  85022. * @returns an array
  85023. */
  85024. getAnimationRanges(): Nullable<AnimationRange>[];
  85025. /**
  85026. * Copy animation range from a source skeleton.
  85027. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  85028. * @param source defines the source skeleton
  85029. * @param name defines the name of the range to copy
  85030. * @param rescaleAsRequired defines if rescaling must be applied if required
  85031. * @returns true if operation was successful
  85032. */
  85033. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  85034. /**
  85035. * Forces the skeleton to go to rest pose
  85036. */
  85037. returnToRest(): void;
  85038. private _getHighestAnimationFrame;
  85039. /**
  85040. * Begin a specific animation range
  85041. * @param name defines the name of the range to start
  85042. * @param loop defines if looping must be turned on (false by default)
  85043. * @param speedRatio defines the speed ratio to apply (1 by default)
  85044. * @param onAnimationEnd defines a callback which will be called when animation will end
  85045. * @returns a new animatable
  85046. */
  85047. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85048. /** @hidden */
  85049. _markAsDirty(): void;
  85050. /** @hidden */
  85051. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  85052. /** @hidden */
  85053. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  85054. private _computeTransformMatrices;
  85055. /**
  85056. * Build all resources required to render a skeleton
  85057. */
  85058. prepare(): void;
  85059. /**
  85060. * Gets the list of animatables currently running for this skeleton
  85061. * @returns an array of animatables
  85062. */
  85063. getAnimatables(): IAnimatable[];
  85064. /**
  85065. * Clone the current skeleton
  85066. * @param name defines the name of the new skeleton
  85067. * @param id defines the id of the new skeleton
  85068. * @returns the new skeleton
  85069. */
  85070. clone(name: string, id?: string): Skeleton;
  85071. /**
  85072. * Enable animation blending for this skeleton
  85073. * @param blendingSpeed defines the blending speed to apply
  85074. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  85075. */
  85076. enableBlending(blendingSpeed?: number): void;
  85077. /**
  85078. * Releases all resources associated with the current skeleton
  85079. */
  85080. dispose(): void;
  85081. /**
  85082. * Serialize the skeleton in a JSON object
  85083. * @returns a JSON object
  85084. */
  85085. serialize(): any;
  85086. /**
  85087. * Creates a new skeleton from serialized data
  85088. * @param parsedSkeleton defines the serialized data
  85089. * @param scene defines the hosting scene
  85090. * @returns a new skeleton
  85091. */
  85092. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  85093. /**
  85094. * Compute all node absolute transforms
  85095. * @param forceUpdate defines if computation must be done even if cache is up to date
  85096. */
  85097. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  85098. /**
  85099. * Gets the root pose matrix
  85100. * @returns a matrix
  85101. */
  85102. getPoseMatrix(): Nullable<Matrix>;
  85103. /**
  85104. * Sorts bones per internal index
  85105. */
  85106. sortBones(): void;
  85107. private _sortBones;
  85108. }
  85109. }
  85110. declare module BABYLON {
  85111. /**
  85112. * Class used to store bone information
  85113. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  85114. */
  85115. export class Bone extends Node {
  85116. /**
  85117. * defines the bone name
  85118. */
  85119. name: string;
  85120. private static _tmpVecs;
  85121. private static _tmpQuat;
  85122. private static _tmpMats;
  85123. /**
  85124. * Gets the list of child bones
  85125. */
  85126. children: Bone[];
  85127. /** Gets the animations associated with this bone */
  85128. animations: Animation[];
  85129. /**
  85130. * Gets or sets bone length
  85131. */
  85132. length: number;
  85133. /**
  85134. * @hidden Internal only
  85135. * Set this value to map this bone to a different index in the transform matrices
  85136. * Set this value to -1 to exclude the bone from the transform matrices
  85137. */
  85138. _index: Nullable<number>;
  85139. private _skeleton;
  85140. private _localMatrix;
  85141. private _restPose;
  85142. private _baseMatrix;
  85143. private _absoluteTransform;
  85144. private _invertedAbsoluteTransform;
  85145. private _parent;
  85146. private _scalingDeterminant;
  85147. private _worldTransform;
  85148. private _localScaling;
  85149. private _localRotation;
  85150. private _localPosition;
  85151. private _needToDecompose;
  85152. private _needToCompose;
  85153. /** @hidden */
  85154. _linkedTransformNode: Nullable<TransformNode>;
  85155. /** @hidden */
  85156. _waitingTransformNodeId: Nullable<string>;
  85157. /** @hidden */
  85158. get _matrix(): Matrix;
  85159. /** @hidden */
  85160. set _matrix(value: Matrix);
  85161. /**
  85162. * Create a new bone
  85163. * @param name defines the bone name
  85164. * @param skeleton defines the parent skeleton
  85165. * @param parentBone defines the parent (can be null if the bone is the root)
  85166. * @param localMatrix defines the local matrix
  85167. * @param restPose defines the rest pose matrix
  85168. * @param baseMatrix defines the base matrix
  85169. * @param index defines index of the bone in the hiearchy
  85170. */
  85171. constructor(
  85172. /**
  85173. * defines the bone name
  85174. */
  85175. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  85176. /**
  85177. * Gets the current object class name.
  85178. * @return the class name
  85179. */
  85180. getClassName(): string;
  85181. /**
  85182. * Gets the parent skeleton
  85183. * @returns a skeleton
  85184. */
  85185. getSkeleton(): Skeleton;
  85186. /**
  85187. * Gets parent bone
  85188. * @returns a bone or null if the bone is the root of the bone hierarchy
  85189. */
  85190. getParent(): Nullable<Bone>;
  85191. /**
  85192. * Returns an array containing the root bones
  85193. * @returns an array containing the root bones
  85194. */
  85195. getChildren(): Array<Bone>;
  85196. /**
  85197. * Gets the node index in matrix array generated for rendering
  85198. * @returns the node index
  85199. */
  85200. getIndex(): number;
  85201. /**
  85202. * Sets the parent bone
  85203. * @param parent defines the parent (can be null if the bone is the root)
  85204. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  85205. */
  85206. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  85207. /**
  85208. * Gets the local matrix
  85209. * @returns a matrix
  85210. */
  85211. getLocalMatrix(): Matrix;
  85212. /**
  85213. * Gets the base matrix (initial matrix which remains unchanged)
  85214. * @returns a matrix
  85215. */
  85216. getBaseMatrix(): Matrix;
  85217. /**
  85218. * Gets the rest pose matrix
  85219. * @returns a matrix
  85220. */
  85221. getRestPose(): Matrix;
  85222. /**
  85223. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  85224. */
  85225. getWorldMatrix(): Matrix;
  85226. /**
  85227. * Sets the local matrix to rest pose matrix
  85228. */
  85229. returnToRest(): void;
  85230. /**
  85231. * Gets the inverse of the absolute transform matrix.
  85232. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  85233. * @returns a matrix
  85234. */
  85235. getInvertedAbsoluteTransform(): Matrix;
  85236. /**
  85237. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  85238. * @returns a matrix
  85239. */
  85240. getAbsoluteTransform(): Matrix;
  85241. /**
  85242. * Links with the given transform node.
  85243. * The local matrix of this bone is copied from the transform node every frame.
  85244. * @param transformNode defines the transform node to link to
  85245. */
  85246. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  85247. /**
  85248. * Gets the node used to drive the bone's transformation
  85249. * @returns a transform node or null
  85250. */
  85251. getTransformNode(): Nullable<TransformNode>;
  85252. /** Gets or sets current position (in local space) */
  85253. get position(): Vector3;
  85254. set position(newPosition: Vector3);
  85255. /** Gets or sets current rotation (in local space) */
  85256. get rotation(): Vector3;
  85257. set rotation(newRotation: Vector3);
  85258. /** Gets or sets current rotation quaternion (in local space) */
  85259. get rotationQuaternion(): Quaternion;
  85260. set rotationQuaternion(newRotation: Quaternion);
  85261. /** Gets or sets current scaling (in local space) */
  85262. get scaling(): Vector3;
  85263. set scaling(newScaling: Vector3);
  85264. /**
  85265. * Gets the animation properties override
  85266. */
  85267. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  85268. private _decompose;
  85269. private _compose;
  85270. /**
  85271. * Update the base and local matrices
  85272. * @param matrix defines the new base or local matrix
  85273. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  85274. * @param updateLocalMatrix defines if the local matrix should be updated
  85275. */
  85276. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  85277. /** @hidden */
  85278. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  85279. /**
  85280. * Flag the bone as dirty (Forcing it to update everything)
  85281. */
  85282. markAsDirty(): void;
  85283. /** @hidden */
  85284. _markAsDirtyAndCompose(): void;
  85285. private _markAsDirtyAndDecompose;
  85286. /**
  85287. * Translate the bone in local or world space
  85288. * @param vec The amount to translate the bone
  85289. * @param space The space that the translation is in
  85290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85291. */
  85292. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  85293. /**
  85294. * Set the postion of the bone in local or world space
  85295. * @param position The position to set the bone
  85296. * @param space The space that the position is in
  85297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85298. */
  85299. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  85300. /**
  85301. * Set the absolute position of the bone (world space)
  85302. * @param position The position to set the bone
  85303. * @param mesh The mesh that this bone is attached to
  85304. */
  85305. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  85306. /**
  85307. * Scale the bone on the x, y and z axes (in local space)
  85308. * @param x The amount to scale the bone on the x axis
  85309. * @param y The amount to scale the bone on the y axis
  85310. * @param z The amount to scale the bone on the z axis
  85311. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  85312. */
  85313. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  85314. /**
  85315. * Set the bone scaling in local space
  85316. * @param scale defines the scaling vector
  85317. */
  85318. setScale(scale: Vector3): void;
  85319. /**
  85320. * Gets the current scaling in local space
  85321. * @returns the current scaling vector
  85322. */
  85323. getScale(): Vector3;
  85324. /**
  85325. * Gets the current scaling in local space and stores it in a target vector
  85326. * @param result defines the target vector
  85327. */
  85328. getScaleToRef(result: Vector3): void;
  85329. /**
  85330. * Set the yaw, pitch, and roll of the bone in local or world space
  85331. * @param yaw The rotation of the bone on the y axis
  85332. * @param pitch The rotation of the bone on the x axis
  85333. * @param roll The rotation of the bone on the z axis
  85334. * @param space The space that the axes of rotation are in
  85335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85336. */
  85337. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  85338. /**
  85339. * Add a rotation to the bone on an axis in local or world space
  85340. * @param axis The axis to rotate the bone on
  85341. * @param amount The amount to rotate the bone
  85342. * @param space The space that the axis is in
  85343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85344. */
  85345. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  85346. /**
  85347. * Set the rotation of the bone to a particular axis angle in local or world space
  85348. * @param axis The axis to rotate the bone on
  85349. * @param angle The angle that the bone should be rotated to
  85350. * @param space The space that the axis is in
  85351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85352. */
  85353. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  85354. /**
  85355. * Set the euler rotation of the bone in local of world space
  85356. * @param rotation The euler rotation that the bone should be set to
  85357. * @param space The space that the rotation is in
  85358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85359. */
  85360. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  85361. /**
  85362. * Set the quaternion rotation of the bone in local of world space
  85363. * @param quat The quaternion rotation that the bone should be set to
  85364. * @param space The space that the rotation is in
  85365. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85366. */
  85367. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  85368. /**
  85369. * Set the rotation matrix of the bone in local of world space
  85370. * @param rotMat The rotation matrix that the bone should be set to
  85371. * @param space The space that the rotation is in
  85372. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85373. */
  85374. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  85375. private _rotateWithMatrix;
  85376. private _getNegativeRotationToRef;
  85377. /**
  85378. * Get the position of the bone in local or world space
  85379. * @param space The space that the returned position is in
  85380. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85381. * @returns The position of the bone
  85382. */
  85383. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  85384. /**
  85385. * Copy the position of the bone to a vector3 in local or world space
  85386. * @param space The space that the returned position is in
  85387. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85388. * @param result The vector3 to copy the position to
  85389. */
  85390. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  85391. /**
  85392. * Get the absolute position of the bone (world space)
  85393. * @param mesh The mesh that this bone is attached to
  85394. * @returns The absolute position of the bone
  85395. */
  85396. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  85397. /**
  85398. * Copy the absolute position of the bone (world space) to the result param
  85399. * @param mesh The mesh that this bone is attached to
  85400. * @param result The vector3 to copy the absolute position to
  85401. */
  85402. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  85403. /**
  85404. * Compute the absolute transforms of this bone and its children
  85405. */
  85406. computeAbsoluteTransforms(): void;
  85407. /**
  85408. * Get the world direction from an axis that is in the local space of the bone
  85409. * @param localAxis The local direction that is used to compute the world direction
  85410. * @param mesh The mesh that this bone is attached to
  85411. * @returns The world direction
  85412. */
  85413. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  85414. /**
  85415. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  85416. * @param localAxis The local direction that is used to compute the world direction
  85417. * @param mesh The mesh that this bone is attached to
  85418. * @param result The vector3 that the world direction will be copied to
  85419. */
  85420. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  85421. /**
  85422. * Get the euler rotation of the bone in local or world space
  85423. * @param space The space that the rotation should be in
  85424. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85425. * @returns The euler rotation
  85426. */
  85427. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  85428. /**
  85429. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  85430. * @param space The space that the rotation should be in
  85431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85432. * @param result The vector3 that the rotation should be copied to
  85433. */
  85434. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  85435. /**
  85436. * Get the quaternion rotation of the bone in either local or world space
  85437. * @param space The space that the rotation should be in
  85438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85439. * @returns The quaternion rotation
  85440. */
  85441. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  85442. /**
  85443. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  85444. * @param space The space that the rotation should be in
  85445. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85446. * @param result The quaternion that the rotation should be copied to
  85447. */
  85448. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  85449. /**
  85450. * Get the rotation matrix of the bone in local or world space
  85451. * @param space The space that the rotation should be in
  85452. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85453. * @returns The rotation matrix
  85454. */
  85455. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  85456. /**
  85457. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  85458. * @param space The space that the rotation should be in
  85459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85460. * @param result The quaternion that the rotation should be copied to
  85461. */
  85462. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  85463. /**
  85464. * Get the world position of a point that is in the local space of the bone
  85465. * @param position The local position
  85466. * @param mesh The mesh that this bone is attached to
  85467. * @returns The world position
  85468. */
  85469. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  85470. /**
  85471. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  85472. * @param position The local position
  85473. * @param mesh The mesh that this bone is attached to
  85474. * @param result The vector3 that the world position should be copied to
  85475. */
  85476. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  85477. /**
  85478. * Get the local position of a point that is in world space
  85479. * @param position The world position
  85480. * @param mesh The mesh that this bone is attached to
  85481. * @returns The local position
  85482. */
  85483. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  85484. /**
  85485. * Get the local position of a point that is in world space and copy it to the result param
  85486. * @param position The world position
  85487. * @param mesh The mesh that this bone is attached to
  85488. * @param result The vector3 that the local position should be copied to
  85489. */
  85490. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  85491. }
  85492. }
  85493. declare module BABYLON {
  85494. /**
  85495. * 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.
  85496. * @see https://doc.babylonjs.com/how_to/transformnode
  85497. */
  85498. export class TransformNode extends Node {
  85499. /**
  85500. * Object will not rotate to face the camera
  85501. */
  85502. static BILLBOARDMODE_NONE: number;
  85503. /**
  85504. * Object will rotate to face the camera but only on the x axis
  85505. */
  85506. static BILLBOARDMODE_X: number;
  85507. /**
  85508. * Object will rotate to face the camera but only on the y axis
  85509. */
  85510. static BILLBOARDMODE_Y: number;
  85511. /**
  85512. * Object will rotate to face the camera but only on the z axis
  85513. */
  85514. static BILLBOARDMODE_Z: number;
  85515. /**
  85516. * Object will rotate to face the camera
  85517. */
  85518. static BILLBOARDMODE_ALL: number;
  85519. /**
  85520. * Object will rotate to face the camera's position instead of orientation
  85521. */
  85522. static BILLBOARDMODE_USE_POSITION: number;
  85523. private _forward;
  85524. private _forwardInverted;
  85525. private _up;
  85526. private _right;
  85527. private _rightInverted;
  85528. private _position;
  85529. private _rotation;
  85530. private _rotationQuaternion;
  85531. protected _scaling: Vector3;
  85532. protected _isDirty: boolean;
  85533. private _transformToBoneReferal;
  85534. private _isAbsoluteSynced;
  85535. private _billboardMode;
  85536. /**
  85537. * Gets or sets the billboard mode. Default is 0.
  85538. *
  85539. * | Value | Type | Description |
  85540. * | --- | --- | --- |
  85541. * | 0 | BILLBOARDMODE_NONE | |
  85542. * | 1 | BILLBOARDMODE_X | |
  85543. * | 2 | BILLBOARDMODE_Y | |
  85544. * | 4 | BILLBOARDMODE_Z | |
  85545. * | 7 | BILLBOARDMODE_ALL | |
  85546. *
  85547. */
  85548. get billboardMode(): number;
  85549. set billboardMode(value: number);
  85550. private _preserveParentRotationForBillboard;
  85551. /**
  85552. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  85553. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  85554. */
  85555. get preserveParentRotationForBillboard(): boolean;
  85556. set preserveParentRotationForBillboard(value: boolean);
  85557. /**
  85558. * 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
  85559. */
  85560. scalingDeterminant: number;
  85561. private _infiniteDistance;
  85562. /**
  85563. * Gets or sets the distance of the object to max, often used by skybox
  85564. */
  85565. get infiniteDistance(): boolean;
  85566. set infiniteDistance(value: boolean);
  85567. /**
  85568. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  85569. * By default the system will update normals to compensate
  85570. */
  85571. ignoreNonUniformScaling: boolean;
  85572. /**
  85573. * 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
  85574. */
  85575. reIntegrateRotationIntoRotationQuaternion: boolean;
  85576. /** @hidden */
  85577. _poseMatrix: Nullable<Matrix>;
  85578. /** @hidden */
  85579. _localMatrix: Matrix;
  85580. private _usePivotMatrix;
  85581. private _absolutePosition;
  85582. private _absoluteScaling;
  85583. private _absoluteRotationQuaternion;
  85584. private _pivotMatrix;
  85585. private _pivotMatrixInverse;
  85586. protected _postMultiplyPivotMatrix: boolean;
  85587. protected _isWorldMatrixFrozen: boolean;
  85588. /** @hidden */
  85589. _indexInSceneTransformNodesArray: number;
  85590. /**
  85591. * An event triggered after the world matrix is updated
  85592. */
  85593. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  85594. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  85595. /**
  85596. * Gets a string identifying the name of the class
  85597. * @returns "TransformNode" string
  85598. */
  85599. getClassName(): string;
  85600. /**
  85601. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  85602. */
  85603. get position(): Vector3;
  85604. set position(newPosition: Vector3);
  85605. /**
  85606. * 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)).
  85607. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  85608. */
  85609. get rotation(): Vector3;
  85610. set rotation(newRotation: Vector3);
  85611. /**
  85612. * 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)).
  85613. */
  85614. get scaling(): Vector3;
  85615. set scaling(newScaling: Vector3);
  85616. /**
  85617. * 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).
  85618. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  85619. */
  85620. get rotationQuaternion(): Nullable<Quaternion>;
  85621. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  85622. /**
  85623. * The forward direction of that transform in world space.
  85624. */
  85625. get forward(): Vector3;
  85626. /**
  85627. * The up direction of that transform in world space.
  85628. */
  85629. get up(): Vector3;
  85630. /**
  85631. * The right direction of that transform in world space.
  85632. */
  85633. get right(): Vector3;
  85634. /**
  85635. * Copies the parameter passed Matrix into the mesh Pose matrix.
  85636. * @param matrix the matrix to copy the pose from
  85637. * @returns this TransformNode.
  85638. */
  85639. updatePoseMatrix(matrix: Matrix): TransformNode;
  85640. /**
  85641. * Returns the mesh Pose matrix.
  85642. * @returns the pose matrix
  85643. */
  85644. getPoseMatrix(): Matrix;
  85645. /** @hidden */
  85646. _isSynchronized(): boolean;
  85647. /** @hidden */
  85648. _initCache(): void;
  85649. /**
  85650. * Flag the transform node as dirty (Forcing it to update everything)
  85651. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  85652. * @returns this transform node
  85653. */
  85654. markAsDirty(property: string): TransformNode;
  85655. /**
  85656. * Returns the current mesh absolute position.
  85657. * Returns a Vector3.
  85658. */
  85659. get absolutePosition(): Vector3;
  85660. /**
  85661. * Returns the current mesh absolute scaling.
  85662. * Returns a Vector3.
  85663. */
  85664. get absoluteScaling(): Vector3;
  85665. /**
  85666. * Returns the current mesh absolute rotation.
  85667. * Returns a Quaternion.
  85668. */
  85669. get absoluteRotationQuaternion(): Quaternion;
  85670. /**
  85671. * Sets a new matrix to apply before all other transformation
  85672. * @param matrix defines the transform matrix
  85673. * @returns the current TransformNode
  85674. */
  85675. setPreTransformMatrix(matrix: Matrix): TransformNode;
  85676. /**
  85677. * Sets a new pivot matrix to the current node
  85678. * @param matrix defines the new pivot matrix to use
  85679. * @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
  85680. * @returns the current TransformNode
  85681. */
  85682. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  85683. /**
  85684. * Returns the mesh pivot matrix.
  85685. * Default : Identity.
  85686. * @returns the matrix
  85687. */
  85688. getPivotMatrix(): Matrix;
  85689. /**
  85690. * Instantiate (when possible) or clone that node with its hierarchy
  85691. * @param newParent defines the new parent to use for the instance (or clone)
  85692. * @param options defines options to configure how copy is done
  85693. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  85694. * @returns an instance (or a clone) of the current node with its hiearchy
  85695. */
  85696. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  85697. doNotInstantiate: boolean;
  85698. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  85699. /**
  85700. * Prevents the World matrix to be computed any longer
  85701. * @param newWorldMatrix defines an optional matrix to use as world matrix
  85702. * @returns the TransformNode.
  85703. */
  85704. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  85705. /**
  85706. * Allows back the World matrix computation.
  85707. * @returns the TransformNode.
  85708. */
  85709. unfreezeWorldMatrix(): this;
  85710. /**
  85711. * True if the World matrix has been frozen.
  85712. */
  85713. get isWorldMatrixFrozen(): boolean;
  85714. /**
  85715. * Retuns the mesh absolute position in the World.
  85716. * @returns a Vector3.
  85717. */
  85718. getAbsolutePosition(): Vector3;
  85719. /**
  85720. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  85721. * @param absolutePosition the absolute position to set
  85722. * @returns the TransformNode.
  85723. */
  85724. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  85725. /**
  85726. * Sets the mesh position in its local space.
  85727. * @param vector3 the position to set in localspace
  85728. * @returns the TransformNode.
  85729. */
  85730. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  85731. /**
  85732. * Returns the mesh position in the local space from the current World matrix values.
  85733. * @returns a new Vector3.
  85734. */
  85735. getPositionExpressedInLocalSpace(): Vector3;
  85736. /**
  85737. * Translates the mesh along the passed Vector3 in its local space.
  85738. * @param vector3 the distance to translate in localspace
  85739. * @returns the TransformNode.
  85740. */
  85741. locallyTranslate(vector3: Vector3): TransformNode;
  85742. private static _lookAtVectorCache;
  85743. /**
  85744. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  85745. * @param targetPoint the position (must be in same space as current mesh) to look at
  85746. * @param yawCor optional yaw (y-axis) correction in radians
  85747. * @param pitchCor optional pitch (x-axis) correction in radians
  85748. * @param rollCor optional roll (z-axis) correction in radians
  85749. * @param space the choosen space of the target
  85750. * @returns the TransformNode.
  85751. */
  85752. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  85753. /**
  85754. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  85755. * This Vector3 is expressed in the World space.
  85756. * @param localAxis axis to rotate
  85757. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  85758. */
  85759. getDirection(localAxis: Vector3): Vector3;
  85760. /**
  85761. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  85762. * localAxis is expressed in the mesh local space.
  85763. * result is computed in the Wordl space from the mesh World matrix.
  85764. * @param localAxis axis to rotate
  85765. * @param result the resulting transformnode
  85766. * @returns this TransformNode.
  85767. */
  85768. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  85769. /**
  85770. * Sets this transform node rotation to the given local axis.
  85771. * @param localAxis the axis in local space
  85772. * @param yawCor optional yaw (y-axis) correction in radians
  85773. * @param pitchCor optional pitch (x-axis) correction in radians
  85774. * @param rollCor optional roll (z-axis) correction in radians
  85775. * @returns this TransformNode
  85776. */
  85777. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  85778. /**
  85779. * Sets a new pivot point to the current node
  85780. * @param point defines the new pivot point to use
  85781. * @param space defines if the point is in world or local space (local by default)
  85782. * @returns the current TransformNode
  85783. */
  85784. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  85785. /**
  85786. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  85787. * @returns the pivot point
  85788. */
  85789. getPivotPoint(): Vector3;
  85790. /**
  85791. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  85792. * @param result the vector3 to store the result
  85793. * @returns this TransformNode.
  85794. */
  85795. getPivotPointToRef(result: Vector3): TransformNode;
  85796. /**
  85797. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  85798. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  85799. */
  85800. getAbsolutePivotPoint(): Vector3;
  85801. /**
  85802. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  85803. * @param result vector3 to store the result
  85804. * @returns this TransformNode.
  85805. */
  85806. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  85807. /**
  85808. * Defines the passed node as the parent of the current node.
  85809. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  85810. * @see https://doc.babylonjs.com/how_to/parenting
  85811. * @param node the node ot set as the parent
  85812. * @returns this TransformNode.
  85813. */
  85814. setParent(node: Nullable<Node>): TransformNode;
  85815. private _nonUniformScaling;
  85816. /**
  85817. * True if the scaling property of this object is non uniform eg. (1,2,1)
  85818. */
  85819. get nonUniformScaling(): boolean;
  85820. /** @hidden */
  85821. _updateNonUniformScalingState(value: boolean): boolean;
  85822. /**
  85823. * Attach the current TransformNode to another TransformNode associated with a bone
  85824. * @param bone Bone affecting the TransformNode
  85825. * @param affectedTransformNode TransformNode associated with the bone
  85826. * @returns this object
  85827. */
  85828. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  85829. /**
  85830. * Detach the transform node if its associated with a bone
  85831. * @returns this object
  85832. */
  85833. detachFromBone(): TransformNode;
  85834. private static _rotationAxisCache;
  85835. /**
  85836. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  85837. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85838. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85839. * The passed axis is also normalized.
  85840. * @param axis the axis to rotate around
  85841. * @param amount the amount to rotate in radians
  85842. * @param space Space to rotate in (Default: local)
  85843. * @returns the TransformNode.
  85844. */
  85845. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  85846. /**
  85847. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  85848. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85849. * The passed axis is also normalized. .
  85850. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  85851. * @param point the point to rotate around
  85852. * @param axis the axis to rotate around
  85853. * @param amount the amount to rotate in radians
  85854. * @returns the TransformNode
  85855. */
  85856. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  85857. /**
  85858. * Translates the mesh along the axis vector for the passed distance in the given space.
  85859. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85860. * @param axis the axis to translate in
  85861. * @param distance the distance to translate
  85862. * @param space Space to rotate in (Default: local)
  85863. * @returns the TransformNode.
  85864. */
  85865. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  85866. /**
  85867. * Adds a rotation step to the mesh current rotation.
  85868. * x, y, z are Euler angles expressed in radians.
  85869. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  85870. * This means this rotation is made in the mesh local space only.
  85871. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  85872. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  85873. * ```javascript
  85874. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  85875. * ```
  85876. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  85877. * 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.
  85878. * @param x Rotation to add
  85879. * @param y Rotation to add
  85880. * @param z Rotation to add
  85881. * @returns the TransformNode.
  85882. */
  85883. addRotation(x: number, y: number, z: number): TransformNode;
  85884. /**
  85885. * @hidden
  85886. */
  85887. protected _getEffectiveParent(): Nullable<Node>;
  85888. /**
  85889. * Computes the world matrix of the node
  85890. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85891. * @returns the world matrix
  85892. */
  85893. computeWorldMatrix(force?: boolean): Matrix;
  85894. protected _afterComputeWorldMatrix(): void;
  85895. /**
  85896. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  85897. * @param func callback function to add
  85898. *
  85899. * @returns the TransformNode.
  85900. */
  85901. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85902. /**
  85903. * Removes a registered callback function.
  85904. * @param func callback function to remove
  85905. * @returns the TransformNode.
  85906. */
  85907. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85908. /**
  85909. * Gets the position of the current mesh in camera space
  85910. * @param camera defines the camera to use
  85911. * @returns a position
  85912. */
  85913. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  85914. /**
  85915. * Returns the distance from the mesh to the active camera
  85916. * @param camera defines the camera to use
  85917. * @returns the distance
  85918. */
  85919. getDistanceToCamera(camera?: Nullable<Camera>): number;
  85920. /**
  85921. * Clone the current transform node
  85922. * @param name Name of the new clone
  85923. * @param newParent New parent for the clone
  85924. * @param doNotCloneChildren Do not clone children hierarchy
  85925. * @returns the new transform node
  85926. */
  85927. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  85928. /**
  85929. * Serializes the objects information.
  85930. * @param currentSerializationObject defines the object to serialize in
  85931. * @returns the serialized object
  85932. */
  85933. serialize(currentSerializationObject?: any): any;
  85934. /**
  85935. * Returns a new TransformNode object parsed from the source provided.
  85936. * @param parsedTransformNode is the source.
  85937. * @param scene the scne the object belongs to
  85938. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  85939. * @returns a new TransformNode object parsed from the source provided.
  85940. */
  85941. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  85942. /**
  85943. * Get all child-transformNodes of this node
  85944. * @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
  85945. * @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
  85946. * @returns an array of TransformNode
  85947. */
  85948. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  85949. /**
  85950. * Releases resources associated with this transform node.
  85951. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85952. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85953. */
  85954. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85955. /**
  85956. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  85957. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  85958. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  85959. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  85960. * @returns the current mesh
  85961. */
  85962. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  85963. private _syncAbsoluteScalingAndRotation;
  85964. }
  85965. }
  85966. declare module BABYLON {
  85967. /**
  85968. * Defines the types of pose enabled controllers that are supported
  85969. */
  85970. export enum PoseEnabledControllerType {
  85971. /**
  85972. * HTC Vive
  85973. */
  85974. VIVE = 0,
  85975. /**
  85976. * Oculus Rift
  85977. */
  85978. OCULUS = 1,
  85979. /**
  85980. * Windows mixed reality
  85981. */
  85982. WINDOWS = 2,
  85983. /**
  85984. * Samsung gear VR
  85985. */
  85986. GEAR_VR = 3,
  85987. /**
  85988. * Google Daydream
  85989. */
  85990. DAYDREAM = 4,
  85991. /**
  85992. * Generic
  85993. */
  85994. GENERIC = 5
  85995. }
  85996. /**
  85997. * Defines the MutableGamepadButton interface for the state of a gamepad button
  85998. */
  85999. export interface MutableGamepadButton {
  86000. /**
  86001. * Value of the button/trigger
  86002. */
  86003. value: number;
  86004. /**
  86005. * If the button/trigger is currently touched
  86006. */
  86007. touched: boolean;
  86008. /**
  86009. * If the button/trigger is currently pressed
  86010. */
  86011. pressed: boolean;
  86012. }
  86013. /**
  86014. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  86015. * @hidden
  86016. */
  86017. export interface ExtendedGamepadButton extends GamepadButton {
  86018. /**
  86019. * If the button/trigger is currently pressed
  86020. */
  86021. readonly pressed: boolean;
  86022. /**
  86023. * If the button/trigger is currently touched
  86024. */
  86025. readonly touched: boolean;
  86026. /**
  86027. * Value of the button/trigger
  86028. */
  86029. readonly value: number;
  86030. }
  86031. /** @hidden */
  86032. export interface _GamePadFactory {
  86033. /**
  86034. * Returns wether or not the current gamepad can be created for this type of controller.
  86035. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  86036. * @returns true if it can be created, otherwise false
  86037. */
  86038. canCreate(gamepadInfo: any): boolean;
  86039. /**
  86040. * Creates a new instance of the Gamepad.
  86041. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  86042. * @returns the new gamepad instance
  86043. */
  86044. create(gamepadInfo: any): Gamepad;
  86045. }
  86046. /**
  86047. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  86048. */
  86049. export class PoseEnabledControllerHelper {
  86050. /** @hidden */
  86051. static _ControllerFactories: _GamePadFactory[];
  86052. /** @hidden */
  86053. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  86054. /**
  86055. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  86056. * @param vrGamepad the gamepad to initialized
  86057. * @returns a vr controller of the type the gamepad identified as
  86058. */
  86059. static InitiateController(vrGamepad: any): Gamepad;
  86060. }
  86061. /**
  86062. * Defines the PoseEnabledController object that contains state of a vr capable controller
  86063. */
  86064. export class PoseEnabledController extends Gamepad implements PoseControlled {
  86065. /**
  86066. * If the controller is used in a webXR session
  86067. */
  86068. isXR: boolean;
  86069. private _deviceRoomPosition;
  86070. private _deviceRoomRotationQuaternion;
  86071. /**
  86072. * The device position in babylon space
  86073. */
  86074. devicePosition: Vector3;
  86075. /**
  86076. * The device rotation in babylon space
  86077. */
  86078. deviceRotationQuaternion: Quaternion;
  86079. /**
  86080. * The scale factor of the device in babylon space
  86081. */
  86082. deviceScaleFactor: number;
  86083. /**
  86084. * (Likely devicePosition should be used instead) The device position in its room space
  86085. */
  86086. position: Vector3;
  86087. /**
  86088. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  86089. */
  86090. rotationQuaternion: Quaternion;
  86091. /**
  86092. * The type of controller (Eg. Windows mixed reality)
  86093. */
  86094. controllerType: PoseEnabledControllerType;
  86095. protected _calculatedPosition: Vector3;
  86096. private _calculatedRotation;
  86097. /**
  86098. * The raw pose from the device
  86099. */
  86100. rawPose: DevicePose;
  86101. private _trackPosition;
  86102. private _maxRotationDistFromHeadset;
  86103. private _draggedRoomRotation;
  86104. /**
  86105. * @hidden
  86106. */
  86107. _disableTrackPosition(fixedPosition: Vector3): void;
  86108. /**
  86109. * Internal, the mesh attached to the controller
  86110. * @hidden
  86111. */
  86112. _mesh: Nullable<AbstractMesh>;
  86113. private _poseControlledCamera;
  86114. private _leftHandSystemQuaternion;
  86115. /**
  86116. * Internal, matrix used to convert room space to babylon space
  86117. * @hidden
  86118. */
  86119. _deviceToWorld: Matrix;
  86120. /**
  86121. * Node to be used when casting a ray from the controller
  86122. * @hidden
  86123. */
  86124. _pointingPoseNode: Nullable<TransformNode>;
  86125. /**
  86126. * Name of the child mesh that can be used to cast a ray from the controller
  86127. */
  86128. static readonly POINTING_POSE: string;
  86129. /**
  86130. * Creates a new PoseEnabledController from a gamepad
  86131. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  86132. */
  86133. constructor(browserGamepad: any);
  86134. private _workingMatrix;
  86135. /**
  86136. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  86137. */
  86138. update(): void;
  86139. /**
  86140. * Updates only the pose device and mesh without doing any button event checking
  86141. */
  86142. protected _updatePoseAndMesh(): void;
  86143. /**
  86144. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  86145. * @param poseData raw pose fromthe device
  86146. */
  86147. updateFromDevice(poseData: DevicePose): void;
  86148. /**
  86149. * @hidden
  86150. */
  86151. _meshAttachedObservable: Observable<AbstractMesh>;
  86152. /**
  86153. * Attaches a mesh to the controller
  86154. * @param mesh the mesh to be attached
  86155. */
  86156. attachToMesh(mesh: AbstractMesh): void;
  86157. /**
  86158. * Attaches the controllers mesh to a camera
  86159. * @param camera the camera the mesh should be attached to
  86160. */
  86161. attachToPoseControlledCamera(camera: TargetCamera): void;
  86162. /**
  86163. * Disposes of the controller
  86164. */
  86165. dispose(): void;
  86166. /**
  86167. * The mesh that is attached to the controller
  86168. */
  86169. get mesh(): Nullable<AbstractMesh>;
  86170. /**
  86171. * Gets the ray of the controller in the direction the controller is pointing
  86172. * @param length the length the resulting ray should be
  86173. * @returns a ray in the direction the controller is pointing
  86174. */
  86175. getForwardRay(length?: number): Ray;
  86176. }
  86177. }
  86178. declare module BABYLON {
  86179. /**
  86180. * Defines the WebVRController object that represents controllers tracked in 3D space
  86181. */
  86182. export abstract class WebVRController extends PoseEnabledController {
  86183. /**
  86184. * Internal, the default controller model for the controller
  86185. */
  86186. protected _defaultModel: Nullable<AbstractMesh>;
  86187. /**
  86188. * Fired when the trigger state has changed
  86189. */
  86190. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  86191. /**
  86192. * Fired when the main button state has changed
  86193. */
  86194. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  86195. /**
  86196. * Fired when the secondary button state has changed
  86197. */
  86198. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  86199. /**
  86200. * Fired when the pad state has changed
  86201. */
  86202. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  86203. /**
  86204. * Fired when controllers stick values have changed
  86205. */
  86206. onPadValuesChangedObservable: Observable<StickValues>;
  86207. /**
  86208. * Array of button availible on the controller
  86209. */
  86210. protected _buttons: Array<MutableGamepadButton>;
  86211. private _onButtonStateChange;
  86212. /**
  86213. * Fired when a controller button's state has changed
  86214. * @param callback the callback containing the button that was modified
  86215. */
  86216. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  86217. /**
  86218. * X and Y axis corresponding to the controllers joystick
  86219. */
  86220. pad: StickValues;
  86221. /**
  86222. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  86223. */
  86224. hand: string;
  86225. /**
  86226. * The default controller model for the controller
  86227. */
  86228. get defaultModel(): Nullable<AbstractMesh>;
  86229. /**
  86230. * Creates a new WebVRController from a gamepad
  86231. * @param vrGamepad the gamepad that the WebVRController should be created from
  86232. */
  86233. constructor(vrGamepad: any);
  86234. /**
  86235. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  86236. */
  86237. update(): void;
  86238. /**
  86239. * Function to be called when a button is modified
  86240. */
  86241. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  86242. /**
  86243. * Loads a mesh and attaches it to the controller
  86244. * @param scene the scene the mesh should be added to
  86245. * @param meshLoaded callback for when the mesh has been loaded
  86246. */
  86247. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  86248. private _setButtonValue;
  86249. private _changes;
  86250. private _checkChanges;
  86251. /**
  86252. * Disposes of th webVRCOntroller
  86253. */
  86254. dispose(): void;
  86255. }
  86256. }
  86257. declare module BABYLON {
  86258. /**
  86259. * The HemisphericLight simulates the ambient environment light,
  86260. * so the passed direction is the light reflection direction, not the incoming direction.
  86261. */
  86262. export class HemisphericLight extends Light {
  86263. /**
  86264. * The groundColor is the light in the opposite direction to the one specified during creation.
  86265. * 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.
  86266. */
  86267. groundColor: Color3;
  86268. /**
  86269. * The light reflection direction, not the incoming direction.
  86270. */
  86271. direction: Vector3;
  86272. /**
  86273. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  86274. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  86275. * The HemisphericLight can't cast shadows.
  86276. * Documentation : https://doc.babylonjs.com/babylon101/lights
  86277. * @param name The friendly name of the light
  86278. * @param direction The direction of the light reflection
  86279. * @param scene The scene the light belongs to
  86280. */
  86281. constructor(name: string, direction: Vector3, scene: Scene);
  86282. protected _buildUniformLayout(): void;
  86283. /**
  86284. * Returns the string "HemisphericLight".
  86285. * @return The class name
  86286. */
  86287. getClassName(): string;
  86288. /**
  86289. * Sets the HemisphericLight direction towards the passed target (Vector3).
  86290. * Returns the updated direction.
  86291. * @param target The target the direction should point to
  86292. * @return The computed direction
  86293. */
  86294. setDirectionToTarget(target: Vector3): Vector3;
  86295. /**
  86296. * Returns the shadow generator associated to the light.
  86297. * @returns Always null for hemispheric lights because it does not support shadows.
  86298. */
  86299. getShadowGenerator(): Nullable<IShadowGenerator>;
  86300. /**
  86301. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  86302. * @param effect The effect to update
  86303. * @param lightIndex The index of the light in the effect to update
  86304. * @returns The hemispheric light
  86305. */
  86306. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  86307. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  86308. /**
  86309. * Computes the world matrix of the node
  86310. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86311. * @param useWasUpdatedFlag defines a reserved property
  86312. * @returns the world matrix
  86313. */
  86314. computeWorldMatrix(): Matrix;
  86315. /**
  86316. * Returns the integer 3.
  86317. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  86318. */
  86319. getTypeID(): number;
  86320. /**
  86321. * Prepares the list of defines specific to the light type.
  86322. * @param defines the list of defines
  86323. * @param lightIndex defines the index of the light for the effect
  86324. */
  86325. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  86326. }
  86327. }
  86328. declare module BABYLON {
  86329. /** @hidden */
  86330. export var vrMultiviewToSingleviewPixelShader: {
  86331. name: string;
  86332. shader: string;
  86333. };
  86334. }
  86335. declare module BABYLON {
  86336. /**
  86337. * Renders to multiple views with a single draw call
  86338. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  86339. */
  86340. export class MultiviewRenderTarget extends RenderTargetTexture {
  86341. /**
  86342. * Creates a multiview render target
  86343. * @param scene scene used with the render target
  86344. * @param size the size of the render target (used for each view)
  86345. */
  86346. constructor(scene: Scene, size?: number | {
  86347. width: number;
  86348. height: number;
  86349. } | {
  86350. ratio: number;
  86351. });
  86352. /**
  86353. * @hidden
  86354. * @param faceIndex the face index, if its a cube texture
  86355. */
  86356. _bindFrameBuffer(faceIndex?: number): void;
  86357. /**
  86358. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86359. * @returns the view count
  86360. */
  86361. getViewCount(): number;
  86362. }
  86363. }
  86364. declare module BABYLON {
  86365. /**
  86366. * Represents a camera frustum
  86367. */
  86368. export class Frustum {
  86369. /**
  86370. * Gets the planes representing the frustum
  86371. * @param transform matrix to be applied to the returned planes
  86372. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86373. */
  86374. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86375. /**
  86376. * Gets the near frustum plane transformed by the transform matrix
  86377. * @param transform transformation matrix to be applied to the resulting frustum plane
  86378. * @param frustumPlane the resuling frustum plane
  86379. */
  86380. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86381. /**
  86382. * Gets the far frustum plane transformed by the transform matrix
  86383. * @param transform transformation matrix to be applied to the resulting frustum plane
  86384. * @param frustumPlane the resuling frustum plane
  86385. */
  86386. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86387. /**
  86388. * Gets the left frustum plane transformed by the transform matrix
  86389. * @param transform transformation matrix to be applied to the resulting frustum plane
  86390. * @param frustumPlane the resuling frustum plane
  86391. */
  86392. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86393. /**
  86394. * Gets the right frustum plane transformed by the transform matrix
  86395. * @param transform transformation matrix to be applied to the resulting frustum plane
  86396. * @param frustumPlane the resuling frustum plane
  86397. */
  86398. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86399. /**
  86400. * Gets the top frustum plane transformed by the transform matrix
  86401. * @param transform transformation matrix to be applied to the resulting frustum plane
  86402. * @param frustumPlane the resuling frustum plane
  86403. */
  86404. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86405. /**
  86406. * Gets the bottom frustum plane transformed by the transform matrix
  86407. * @param transform transformation matrix to be applied to the resulting frustum plane
  86408. * @param frustumPlane the resuling frustum plane
  86409. */
  86410. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86411. /**
  86412. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86413. * @param transform transformation matrix to be applied to the resulting frustum planes
  86414. * @param frustumPlanes the resuling frustum planes
  86415. */
  86416. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86417. }
  86418. }
  86419. declare module BABYLON {
  86420. interface Engine {
  86421. /**
  86422. * Creates a new multiview render target
  86423. * @param width defines the width of the texture
  86424. * @param height defines the height of the texture
  86425. * @returns the created multiview texture
  86426. */
  86427. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  86428. /**
  86429. * Binds a multiview framebuffer to be drawn to
  86430. * @param multiviewTexture texture to bind
  86431. */
  86432. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  86433. }
  86434. interface Camera {
  86435. /**
  86436. * @hidden
  86437. * 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)
  86438. */
  86439. _useMultiviewToSingleView: boolean;
  86440. /**
  86441. * @hidden
  86442. * 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)
  86443. */
  86444. _multiviewTexture: Nullable<RenderTargetTexture>;
  86445. /**
  86446. * @hidden
  86447. * ensures the multiview texture of the camera exists and has the specified width/height
  86448. * @param width height to set on the multiview texture
  86449. * @param height width to set on the multiview texture
  86450. */
  86451. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  86452. }
  86453. interface Scene {
  86454. /** @hidden */
  86455. _transformMatrixR: Matrix;
  86456. /** @hidden */
  86457. _multiviewSceneUbo: Nullable<UniformBuffer>;
  86458. /** @hidden */
  86459. _createMultiviewUbo(): void;
  86460. /** @hidden */
  86461. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  86462. /** @hidden */
  86463. _renderMultiviewToSingleView(camera: Camera): void;
  86464. }
  86465. }
  86466. declare module BABYLON {
  86467. /**
  86468. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  86469. * This will not be used for webXR as it supports displaying texture arrays directly
  86470. */
  86471. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  86472. /**
  86473. * Initializes a VRMultiviewToSingleview
  86474. * @param name name of the post process
  86475. * @param camera camera to be applied to
  86476. * @param scaleFactor scaling factor to the size of the output texture
  86477. */
  86478. constructor(name: string, camera: Camera, scaleFactor: number);
  86479. }
  86480. }
  86481. declare module BABYLON {
  86482. /**
  86483. * Interface used to define additional presentation attributes
  86484. */
  86485. export interface IVRPresentationAttributes {
  86486. /**
  86487. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  86488. */
  86489. highRefreshRate: boolean;
  86490. /**
  86491. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  86492. */
  86493. foveationLevel: number;
  86494. }
  86495. interface Engine {
  86496. /** @hidden */
  86497. _vrDisplay: any;
  86498. /** @hidden */
  86499. _vrSupported: boolean;
  86500. /** @hidden */
  86501. _oldSize: Size;
  86502. /** @hidden */
  86503. _oldHardwareScaleFactor: number;
  86504. /** @hidden */
  86505. _vrExclusivePointerMode: boolean;
  86506. /** @hidden */
  86507. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  86508. /** @hidden */
  86509. _onVRDisplayPointerRestricted: () => void;
  86510. /** @hidden */
  86511. _onVRDisplayPointerUnrestricted: () => void;
  86512. /** @hidden */
  86513. _onVrDisplayConnect: Nullable<(display: any) => void>;
  86514. /** @hidden */
  86515. _onVrDisplayDisconnect: Nullable<() => void>;
  86516. /** @hidden */
  86517. _onVrDisplayPresentChange: Nullable<() => void>;
  86518. /**
  86519. * Observable signaled when VR display mode changes
  86520. */
  86521. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86522. /**
  86523. * Observable signaled when VR request present is complete
  86524. */
  86525. onVRRequestPresentComplete: Observable<boolean>;
  86526. /**
  86527. * Observable signaled when VR request present starts
  86528. */
  86529. onVRRequestPresentStart: Observable<Engine>;
  86530. /**
  86531. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86532. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86533. */
  86534. isInVRExclusivePointerMode: boolean;
  86535. /**
  86536. * Gets a boolean indicating if a webVR device was detected
  86537. * @returns true if a webVR device was detected
  86538. */
  86539. isVRDevicePresent(): boolean;
  86540. /**
  86541. * Gets the current webVR device
  86542. * @returns the current webVR device (or null)
  86543. */
  86544. getVRDevice(): any;
  86545. /**
  86546. * Initializes a webVR display and starts listening to display change events
  86547. * The onVRDisplayChangedObservable will be notified upon these changes
  86548. * @returns A promise containing a VRDisplay and if vr is supported
  86549. */
  86550. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  86551. /** @hidden */
  86552. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  86553. /**
  86554. * Gets or sets the presentation attributes used to configure VR rendering
  86555. */
  86556. vrPresentationAttributes?: IVRPresentationAttributes;
  86557. /**
  86558. * Call this function to switch to webVR mode
  86559. * Will do nothing if webVR is not supported or if there is no webVR device
  86560. * @param options the webvr options provided to the camera. mainly used for multiview
  86561. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86562. */
  86563. enableVR(options: WebVROptions): void;
  86564. /** @hidden */
  86565. _onVRFullScreenTriggered(): void;
  86566. }
  86567. }
  86568. declare module BABYLON {
  86569. /**
  86570. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  86571. * IMPORTANT!! The data is right-hand data.
  86572. * @export
  86573. * @interface DevicePose
  86574. */
  86575. export interface DevicePose {
  86576. /**
  86577. * The position of the device, values in array are [x,y,z].
  86578. */
  86579. readonly position: Nullable<Float32Array>;
  86580. /**
  86581. * The linearVelocity of the device, values in array are [x,y,z].
  86582. */
  86583. readonly linearVelocity: Nullable<Float32Array>;
  86584. /**
  86585. * The linearAcceleration of the device, values in array are [x,y,z].
  86586. */
  86587. readonly linearAcceleration: Nullable<Float32Array>;
  86588. /**
  86589. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  86590. */
  86591. readonly orientation: Nullable<Float32Array>;
  86592. /**
  86593. * The angularVelocity of the device, values in array are [x,y,z].
  86594. */
  86595. readonly angularVelocity: Nullable<Float32Array>;
  86596. /**
  86597. * The angularAcceleration of the device, values in array are [x,y,z].
  86598. */
  86599. readonly angularAcceleration: Nullable<Float32Array>;
  86600. }
  86601. /**
  86602. * Interface representing a pose controlled object in Babylon.
  86603. * A pose controlled object has both regular pose values as well as pose values
  86604. * from an external device such as a VR head mounted display
  86605. */
  86606. export interface PoseControlled {
  86607. /**
  86608. * The position of the object in babylon space.
  86609. */
  86610. position: Vector3;
  86611. /**
  86612. * The rotation quaternion of the object in babylon space.
  86613. */
  86614. rotationQuaternion: Quaternion;
  86615. /**
  86616. * The position of the device in babylon space.
  86617. */
  86618. devicePosition?: Vector3;
  86619. /**
  86620. * The rotation quaternion of the device in babylon space.
  86621. */
  86622. deviceRotationQuaternion: Quaternion;
  86623. /**
  86624. * The raw pose coming from the device.
  86625. */
  86626. rawPose: Nullable<DevicePose>;
  86627. /**
  86628. * The scale of the device to be used when translating from device space to babylon space.
  86629. */
  86630. deviceScaleFactor: number;
  86631. /**
  86632. * Updates the poseControlled values based on the input device pose.
  86633. * @param poseData the pose data to update the object with
  86634. */
  86635. updateFromDevice(poseData: DevicePose): void;
  86636. }
  86637. /**
  86638. * Set of options to customize the webVRCamera
  86639. */
  86640. export interface WebVROptions {
  86641. /**
  86642. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  86643. */
  86644. trackPosition?: boolean;
  86645. /**
  86646. * Sets the scale of the vrDevice in babylon space. (default: 1)
  86647. */
  86648. positionScale?: number;
  86649. /**
  86650. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  86651. */
  86652. displayName?: string;
  86653. /**
  86654. * Should the native controller meshes be initialized. (default: true)
  86655. */
  86656. controllerMeshes?: boolean;
  86657. /**
  86658. * Creating a default HemiLight only on controllers. (default: true)
  86659. */
  86660. defaultLightingOnControllers?: boolean;
  86661. /**
  86662. * If you don't want to use the default VR button of the helper. (default: false)
  86663. */
  86664. useCustomVRButton?: boolean;
  86665. /**
  86666. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  86667. */
  86668. customVRButton?: HTMLButtonElement;
  86669. /**
  86670. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  86671. */
  86672. rayLength?: number;
  86673. /**
  86674. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  86675. */
  86676. defaultHeight?: number;
  86677. /**
  86678. * If multiview should be used if availible (default: false)
  86679. */
  86680. useMultiview?: boolean;
  86681. }
  86682. /**
  86683. * This represents a WebVR camera.
  86684. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  86685. * @example http://doc.babylonjs.com/how_to/webvr_camera
  86686. */
  86687. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  86688. private webVROptions;
  86689. /**
  86690. * @hidden
  86691. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  86692. */
  86693. _vrDevice: any;
  86694. /**
  86695. * The rawPose of the vrDevice.
  86696. */
  86697. rawPose: Nullable<DevicePose>;
  86698. private _onVREnabled;
  86699. private _specsVersion;
  86700. private _attached;
  86701. private _frameData;
  86702. protected _descendants: Array<Node>;
  86703. private _deviceRoomPosition;
  86704. /** @hidden */
  86705. _deviceRoomRotationQuaternion: Quaternion;
  86706. private _standingMatrix;
  86707. /**
  86708. * Represents device position in babylon space.
  86709. */
  86710. devicePosition: Vector3;
  86711. /**
  86712. * Represents device rotation in babylon space.
  86713. */
  86714. deviceRotationQuaternion: Quaternion;
  86715. /**
  86716. * The scale of the device to be used when translating from device space to babylon space.
  86717. */
  86718. deviceScaleFactor: number;
  86719. private _deviceToWorld;
  86720. private _worldToDevice;
  86721. /**
  86722. * References to the webVR controllers for the vrDevice.
  86723. */
  86724. controllers: Array<WebVRController>;
  86725. /**
  86726. * Emits an event when a controller is attached.
  86727. */
  86728. onControllersAttachedObservable: Observable<WebVRController[]>;
  86729. /**
  86730. * Emits an event when a controller's mesh has been loaded;
  86731. */
  86732. onControllerMeshLoadedObservable: Observable<WebVRController>;
  86733. /**
  86734. * Emits an event when the HMD's pose has been updated.
  86735. */
  86736. onPoseUpdatedFromDeviceObservable: Observable<any>;
  86737. private _poseSet;
  86738. /**
  86739. * If the rig cameras be used as parent instead of this camera.
  86740. */
  86741. rigParenting: boolean;
  86742. private _lightOnControllers;
  86743. private _defaultHeight?;
  86744. /**
  86745. * Instantiates a WebVRFreeCamera.
  86746. * @param name The name of the WebVRFreeCamera
  86747. * @param position The starting anchor position for the camera
  86748. * @param scene The scene the camera belongs to
  86749. * @param webVROptions a set of customizable options for the webVRCamera
  86750. */
  86751. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  86752. /**
  86753. * Gets the device distance from the ground in meters.
  86754. * @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.
  86755. */
  86756. deviceDistanceToRoomGround(): number;
  86757. /**
  86758. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  86759. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  86760. */
  86761. useStandingMatrix(callback?: (bool: boolean) => void): void;
  86762. /**
  86763. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  86764. * @returns A promise with a boolean set to if the standing matrix is supported.
  86765. */
  86766. useStandingMatrixAsync(): Promise<boolean>;
  86767. /**
  86768. * Disposes the camera
  86769. */
  86770. dispose(): void;
  86771. /**
  86772. * Gets a vrController by name.
  86773. * @param name The name of the controller to retreive
  86774. * @returns the controller matching the name specified or null if not found
  86775. */
  86776. getControllerByName(name: string): Nullable<WebVRController>;
  86777. private _leftController;
  86778. /**
  86779. * The controller corresponding to the users left hand.
  86780. */
  86781. get leftController(): Nullable<WebVRController>;
  86782. private _rightController;
  86783. /**
  86784. * The controller corresponding to the users right hand.
  86785. */
  86786. get rightController(): Nullable<WebVRController>;
  86787. /**
  86788. * Casts a ray forward from the vrCamera's gaze.
  86789. * @param length Length of the ray (default: 100)
  86790. * @returns the ray corresponding to the gaze
  86791. */
  86792. getForwardRay(length?: number): Ray;
  86793. /**
  86794. * @hidden
  86795. * Updates the camera based on device's frame data
  86796. */
  86797. _checkInputs(): void;
  86798. /**
  86799. * Updates the poseControlled values based on the input device pose.
  86800. * @param poseData Pose coming from the device
  86801. */
  86802. updateFromDevice(poseData: DevicePose): void;
  86803. private _htmlElementAttached;
  86804. private _detachIfAttached;
  86805. /**
  86806. * WebVR's attach control will start broadcasting frames to the device.
  86807. * Note that in certain browsers (chrome for example) this function must be called
  86808. * within a user-interaction callback. Example:
  86809. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  86810. *
  86811. * @param element html element to attach the vrDevice to
  86812. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  86813. */
  86814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86815. /**
  86816. * Detaches the camera from the html element and disables VR
  86817. *
  86818. * @param element html element to detach from
  86819. */
  86820. detachControl(element: HTMLElement): void;
  86821. /**
  86822. * @returns the name of this class
  86823. */
  86824. getClassName(): string;
  86825. /**
  86826. * Calls resetPose on the vrDisplay
  86827. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  86828. */
  86829. resetToCurrentRotation(): void;
  86830. /**
  86831. * @hidden
  86832. * Updates the rig cameras (left and right eye)
  86833. */
  86834. _updateRigCameras(): void;
  86835. private _workingVector;
  86836. private _oneVector;
  86837. private _workingMatrix;
  86838. private updateCacheCalled;
  86839. private _correctPositionIfNotTrackPosition;
  86840. /**
  86841. * @hidden
  86842. * Updates the cached values of the camera
  86843. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  86844. */
  86845. _updateCache(ignoreParentClass?: boolean): void;
  86846. /**
  86847. * @hidden
  86848. * Get current device position in babylon world
  86849. */
  86850. _computeDevicePosition(): void;
  86851. /**
  86852. * Updates the current device position and rotation in the babylon world
  86853. */
  86854. update(): void;
  86855. /**
  86856. * @hidden
  86857. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  86858. * @returns an identity matrix
  86859. */
  86860. _getViewMatrix(): Matrix;
  86861. private _tmpMatrix;
  86862. /**
  86863. * This function is called by the two RIG cameras.
  86864. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  86865. * @hidden
  86866. */
  86867. _getWebVRViewMatrix(): Matrix;
  86868. /** @hidden */
  86869. _getWebVRProjectionMatrix(): Matrix;
  86870. private _onGamepadConnectedObserver;
  86871. private _onGamepadDisconnectedObserver;
  86872. private _updateCacheWhenTrackingDisabledObserver;
  86873. /**
  86874. * Initializes the controllers and their meshes
  86875. */
  86876. initControllers(): void;
  86877. }
  86878. }
  86879. declare module BABYLON {
  86880. /**
  86881. * Size options for a post process
  86882. */
  86883. export type PostProcessOptions = {
  86884. width: number;
  86885. height: number;
  86886. };
  86887. /**
  86888. * PostProcess can be used to apply a shader to a texture after it has been rendered
  86889. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86890. */
  86891. export class PostProcess {
  86892. /** Name of the PostProcess. */
  86893. name: string;
  86894. /**
  86895. * Gets or sets the unique id of the post process
  86896. */
  86897. uniqueId: number;
  86898. /**
  86899. * Width of the texture to apply the post process on
  86900. */
  86901. width: number;
  86902. /**
  86903. * Height of the texture to apply the post process on
  86904. */
  86905. height: number;
  86906. /**
  86907. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  86908. * @hidden
  86909. */
  86910. _outputTexture: Nullable<InternalTexture>;
  86911. /**
  86912. * Sampling mode used by the shader
  86913. * See https://doc.babylonjs.com/classes/3.1/texture
  86914. */
  86915. renderTargetSamplingMode: number;
  86916. /**
  86917. * Clear color to use when screen clearing
  86918. */
  86919. clearColor: Color4;
  86920. /**
  86921. * If the buffer needs to be cleared before applying the post process. (default: true)
  86922. * Should be set to false if shader will overwrite all previous pixels.
  86923. */
  86924. autoClear: boolean;
  86925. /**
  86926. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  86927. */
  86928. alphaMode: number;
  86929. /**
  86930. * Sets the setAlphaBlendConstants of the babylon engine
  86931. */
  86932. alphaConstants: Color4;
  86933. /**
  86934. * Animations to be used for the post processing
  86935. */
  86936. animations: Animation[];
  86937. /**
  86938. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  86939. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  86940. */
  86941. enablePixelPerfectMode: boolean;
  86942. /**
  86943. * Force the postprocess to be applied without taking in account viewport
  86944. */
  86945. forceFullscreenViewport: boolean;
  86946. /**
  86947. * List of inspectable custom properties (used by the Inspector)
  86948. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86949. */
  86950. inspectableCustomProperties: IInspectable[];
  86951. /**
  86952. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  86953. *
  86954. * | Value | Type | Description |
  86955. * | ----- | ----------------------------------- | ----------- |
  86956. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  86957. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  86958. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  86959. *
  86960. */
  86961. scaleMode: number;
  86962. /**
  86963. * Force textures to be a power of two (default: false)
  86964. */
  86965. alwaysForcePOT: boolean;
  86966. private _samples;
  86967. /**
  86968. * Number of sample textures (default: 1)
  86969. */
  86970. get samples(): number;
  86971. set samples(n: number);
  86972. /**
  86973. * Modify the scale of the post process to be the same as the viewport (default: false)
  86974. */
  86975. adaptScaleToCurrentViewport: boolean;
  86976. private _camera;
  86977. private _scene;
  86978. private _engine;
  86979. private _options;
  86980. private _reusable;
  86981. private _textureType;
  86982. /**
  86983. * Smart array of input and output textures for the post process.
  86984. * @hidden
  86985. */
  86986. _textures: SmartArray<InternalTexture>;
  86987. /**
  86988. * The index in _textures that corresponds to the output texture.
  86989. * @hidden
  86990. */
  86991. _currentRenderTextureInd: number;
  86992. private _effect;
  86993. private _samplers;
  86994. private _fragmentUrl;
  86995. private _vertexUrl;
  86996. private _parameters;
  86997. private _scaleRatio;
  86998. protected _indexParameters: any;
  86999. private _shareOutputWithPostProcess;
  87000. private _texelSize;
  87001. private _forcedOutputTexture;
  87002. /**
  87003. * Returns the fragment url or shader name used in the post process.
  87004. * @returns the fragment url or name in the shader store.
  87005. */
  87006. getEffectName(): string;
  87007. /**
  87008. * An event triggered when the postprocess is activated.
  87009. */
  87010. onActivateObservable: Observable<Camera>;
  87011. private _onActivateObserver;
  87012. /**
  87013. * A function that is added to the onActivateObservable
  87014. */
  87015. set onActivate(callback: Nullable<(camera: Camera) => void>);
  87016. /**
  87017. * An event triggered when the postprocess changes its size.
  87018. */
  87019. onSizeChangedObservable: Observable<PostProcess>;
  87020. private _onSizeChangedObserver;
  87021. /**
  87022. * A function that is added to the onSizeChangedObservable
  87023. */
  87024. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  87025. /**
  87026. * An event triggered when the postprocess applies its effect.
  87027. */
  87028. onApplyObservable: Observable<Effect>;
  87029. private _onApplyObserver;
  87030. /**
  87031. * A function that is added to the onApplyObservable
  87032. */
  87033. set onApply(callback: (effect: Effect) => void);
  87034. /**
  87035. * An event triggered before rendering the postprocess
  87036. */
  87037. onBeforeRenderObservable: Observable<Effect>;
  87038. private _onBeforeRenderObserver;
  87039. /**
  87040. * A function that is added to the onBeforeRenderObservable
  87041. */
  87042. set onBeforeRender(callback: (effect: Effect) => void);
  87043. /**
  87044. * An event triggered after rendering the postprocess
  87045. */
  87046. onAfterRenderObservable: Observable<Effect>;
  87047. private _onAfterRenderObserver;
  87048. /**
  87049. * A function that is added to the onAfterRenderObservable
  87050. */
  87051. set onAfterRender(callback: (efect: Effect) => void);
  87052. /**
  87053. * 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
  87054. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  87055. */
  87056. get inputTexture(): InternalTexture;
  87057. set inputTexture(value: InternalTexture);
  87058. /**
  87059. * Gets the camera which post process is applied to.
  87060. * @returns The camera the post process is applied to.
  87061. */
  87062. getCamera(): Camera;
  87063. /**
  87064. * Gets the texel size of the postprocess.
  87065. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  87066. */
  87067. get texelSize(): Vector2;
  87068. /**
  87069. * Creates a new instance PostProcess
  87070. * @param name The name of the PostProcess.
  87071. * @param fragmentUrl The url of the fragment shader to be used.
  87072. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  87073. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  87074. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  87075. * @param camera The camera to apply the render pass to.
  87076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  87077. * @param engine The engine which the post process will be applied. (default: current engine)
  87078. * @param reusable If the post process can be reused on the same frame. (default: false)
  87079. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  87080. * @param textureType Type of textures used when performing the post process. (default: 0)
  87081. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  87082. * @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
  87083. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  87084. */
  87085. constructor(
  87086. /** Name of the PostProcess. */
  87087. 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);
  87088. /**
  87089. * Gets a string idenfifying the name of the class
  87090. * @returns "PostProcess" string
  87091. */
  87092. getClassName(): string;
  87093. /**
  87094. * Gets the engine which this post process belongs to.
  87095. * @returns The engine the post process was enabled with.
  87096. */
  87097. getEngine(): Engine;
  87098. /**
  87099. * The effect that is created when initializing the post process.
  87100. * @returns The created effect corresponding the the postprocess.
  87101. */
  87102. getEffect(): Effect;
  87103. /**
  87104. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  87105. * @param postProcess The post process to share the output with.
  87106. * @returns This post process.
  87107. */
  87108. shareOutputWith(postProcess: PostProcess): PostProcess;
  87109. /**
  87110. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  87111. * This should be called if the post process that shares output with this post process is disabled/disposed.
  87112. */
  87113. useOwnOutput(): void;
  87114. /**
  87115. * Updates the effect with the current post process compile time values and recompiles the shader.
  87116. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  87117. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  87118. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  87119. * @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
  87120. * @param onCompiled Called when the shader has been compiled.
  87121. * @param onError Called if there is an error when compiling a shader.
  87122. */
  87123. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  87124. /**
  87125. * The post process is reusable if it can be used multiple times within one frame.
  87126. * @returns If the post process is reusable
  87127. */
  87128. isReusable(): boolean;
  87129. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  87130. markTextureDirty(): void;
  87131. /**
  87132. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  87133. * 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.
  87134. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  87135. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  87136. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  87137. * @returns The target texture that was bound to be written to.
  87138. */
  87139. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  87140. /**
  87141. * If the post process is supported.
  87142. */
  87143. get isSupported(): boolean;
  87144. /**
  87145. * The aspect ratio of the output texture.
  87146. */
  87147. get aspectRatio(): number;
  87148. /**
  87149. * Get a value indicating if the post-process is ready to be used
  87150. * @returns true if the post-process is ready (shader is compiled)
  87151. */
  87152. isReady(): boolean;
  87153. /**
  87154. * Binds all textures and uniforms to the shader, this will be run on every pass.
  87155. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  87156. */
  87157. apply(): Nullable<Effect>;
  87158. private _disposeTextures;
  87159. /**
  87160. * Disposes the post process.
  87161. * @param camera The camera to dispose the post process on.
  87162. */
  87163. dispose(camera?: Camera): void;
  87164. }
  87165. }
  87166. declare module BABYLON {
  87167. /** @hidden */
  87168. export var kernelBlurVaryingDeclaration: {
  87169. name: string;
  87170. shader: string;
  87171. };
  87172. }
  87173. declare module BABYLON {
  87174. /** @hidden */
  87175. export var kernelBlurFragment: {
  87176. name: string;
  87177. shader: string;
  87178. };
  87179. }
  87180. declare module BABYLON {
  87181. /** @hidden */
  87182. export var kernelBlurFragment2: {
  87183. name: string;
  87184. shader: string;
  87185. };
  87186. }
  87187. declare module BABYLON {
  87188. /** @hidden */
  87189. export var kernelBlurPixelShader: {
  87190. name: string;
  87191. shader: string;
  87192. };
  87193. }
  87194. declare module BABYLON {
  87195. /** @hidden */
  87196. export var kernelBlurVertex: {
  87197. name: string;
  87198. shader: string;
  87199. };
  87200. }
  87201. declare module BABYLON {
  87202. /** @hidden */
  87203. export var kernelBlurVertexShader: {
  87204. name: string;
  87205. shader: string;
  87206. };
  87207. }
  87208. declare module BABYLON {
  87209. /**
  87210. * The Blur Post Process which blurs an image based on a kernel and direction.
  87211. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  87212. */
  87213. export class BlurPostProcess extends PostProcess {
  87214. /** The direction in which to blur the image. */
  87215. direction: Vector2;
  87216. private blockCompilation;
  87217. protected _kernel: number;
  87218. protected _idealKernel: number;
  87219. protected _packedFloat: boolean;
  87220. private _staticDefines;
  87221. /**
  87222. * Sets the length in pixels of the blur sample region
  87223. */
  87224. set kernel(v: number);
  87225. /**
  87226. * Gets the length in pixels of the blur sample region
  87227. */
  87228. get kernel(): number;
  87229. /**
  87230. * Sets wether or not the blur needs to unpack/repack floats
  87231. */
  87232. set packedFloat(v: boolean);
  87233. /**
  87234. * Gets wether or not the blur is unpacking/repacking floats
  87235. */
  87236. get packedFloat(): boolean;
  87237. /**
  87238. * Creates a new instance BlurPostProcess
  87239. * @param name The name of the effect.
  87240. * @param direction The direction in which to blur the image.
  87241. * @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.
  87242. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  87243. * @param camera The camera to apply the render pass to.
  87244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  87245. * @param engine The engine which the post process will be applied. (default: current engine)
  87246. * @param reusable If the post process can be reused on the same frame. (default: false)
  87247. * @param textureType Type of textures used when performing the post process. (default: 0)
  87248. * @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)
  87249. */
  87250. constructor(name: string,
  87251. /** The direction in which to blur the image. */
  87252. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  87253. /**
  87254. * Updates the effect with the current post process compile time values and recompiles the shader.
  87255. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  87256. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  87257. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  87258. * @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
  87259. * @param onCompiled Called when the shader has been compiled.
  87260. * @param onError Called if there is an error when compiling a shader.
  87261. */
  87262. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  87263. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  87264. /**
  87265. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  87266. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  87267. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  87268. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  87269. * The gaps between physical kernels are compensated for in the weighting of the samples
  87270. * @param idealKernel Ideal blur kernel.
  87271. * @return Nearest best kernel.
  87272. */
  87273. protected _nearestBestKernel(idealKernel: number): number;
  87274. /**
  87275. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  87276. * @param x The point on the Gaussian distribution to sample.
  87277. * @return the value of the Gaussian function at x.
  87278. */
  87279. protected _gaussianWeight(x: number): number;
  87280. /**
  87281. * Generates a string that can be used as a floating point number in GLSL.
  87282. * @param x Value to print.
  87283. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  87284. * @return GLSL float string.
  87285. */
  87286. protected _glslFloat(x: number, decimalFigures?: number): string;
  87287. }
  87288. }
  87289. declare module BABYLON {
  87290. /**
  87291. * Mirror texture can be used to simulate the view from a mirror in a scene.
  87292. * It will dynamically be rendered every frame to adapt to the camera point of view.
  87293. * You can then easily use it as a reflectionTexture on a flat surface.
  87294. * In case the surface is not a plane, please consider relying on reflection probes.
  87295. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  87296. */
  87297. export class MirrorTexture extends RenderTargetTexture {
  87298. private scene;
  87299. /**
  87300. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  87301. * 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.
  87302. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  87303. */
  87304. mirrorPlane: Plane;
  87305. /**
  87306. * Define the blur ratio used to blur the reflection if needed.
  87307. */
  87308. set blurRatio(value: number);
  87309. get blurRatio(): number;
  87310. /**
  87311. * Define the adaptive blur kernel used to blur the reflection if needed.
  87312. * This will autocompute the closest best match for the `blurKernel`
  87313. */
  87314. set adaptiveBlurKernel(value: number);
  87315. /**
  87316. * Define the blur kernel used to blur the reflection if needed.
  87317. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  87318. */
  87319. set blurKernel(value: number);
  87320. /**
  87321. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  87322. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  87323. */
  87324. set blurKernelX(value: number);
  87325. get blurKernelX(): number;
  87326. /**
  87327. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  87328. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  87329. */
  87330. set blurKernelY(value: number);
  87331. get blurKernelY(): number;
  87332. private _autoComputeBlurKernel;
  87333. protected _onRatioRescale(): void;
  87334. private _updateGammaSpace;
  87335. private _imageProcessingConfigChangeObserver;
  87336. private _transformMatrix;
  87337. private _mirrorMatrix;
  87338. private _savedViewMatrix;
  87339. private _blurX;
  87340. private _blurY;
  87341. private _adaptiveBlurKernel;
  87342. private _blurKernelX;
  87343. private _blurKernelY;
  87344. private _blurRatio;
  87345. /**
  87346. * Instantiates a Mirror Texture.
  87347. * Mirror texture can be used to simulate the view from a mirror in a scene.
  87348. * It will dynamically be rendered every frame to adapt to the camera point of view.
  87349. * You can then easily use it as a reflectionTexture on a flat surface.
  87350. * In case the surface is not a plane, please consider relying on reflection probes.
  87351. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  87352. * @param name
  87353. * @param size
  87354. * @param scene
  87355. * @param generateMipMaps
  87356. * @param type
  87357. * @param samplingMode
  87358. * @param generateDepthBuffer
  87359. */
  87360. constructor(name: string, size: number | {
  87361. width: number;
  87362. height: number;
  87363. } | {
  87364. ratio: number;
  87365. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  87366. private _preparePostProcesses;
  87367. /**
  87368. * Clone the mirror texture.
  87369. * @returns the cloned texture
  87370. */
  87371. clone(): MirrorTexture;
  87372. /**
  87373. * Serialize the texture to a JSON representation you could use in Parse later on
  87374. * @returns the serialized JSON representation
  87375. */
  87376. serialize(): any;
  87377. /**
  87378. * Dispose the texture and release its associated resources.
  87379. */
  87380. dispose(): void;
  87381. }
  87382. }
  87383. declare module BABYLON {
  87384. /**
  87385. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  87386. * @see http://doc.babylonjs.com/babylon101/materials#texture
  87387. */
  87388. export class Texture extends BaseTexture {
  87389. /**
  87390. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  87391. */
  87392. static SerializeBuffers: boolean;
  87393. /** @hidden */
  87394. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  87395. /** @hidden */
  87396. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  87397. /** @hidden */
  87398. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  87399. /** nearest is mag = nearest and min = nearest and mip = linear */
  87400. static readonly NEAREST_SAMPLINGMODE: number;
  87401. /** nearest is mag = nearest and min = nearest and mip = linear */
  87402. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  87403. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87404. static readonly BILINEAR_SAMPLINGMODE: number;
  87405. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87406. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  87407. /** Trilinear is mag = linear and min = linear and mip = linear */
  87408. static readonly TRILINEAR_SAMPLINGMODE: number;
  87409. /** Trilinear is mag = linear and min = linear and mip = linear */
  87410. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  87411. /** mag = nearest and min = nearest and mip = nearest */
  87412. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  87413. /** mag = nearest and min = linear and mip = nearest */
  87414. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  87415. /** mag = nearest and min = linear and mip = linear */
  87416. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  87417. /** mag = nearest and min = linear and mip = none */
  87418. static readonly NEAREST_LINEAR: number;
  87419. /** mag = nearest and min = nearest and mip = none */
  87420. static readonly NEAREST_NEAREST: number;
  87421. /** mag = linear and min = nearest and mip = nearest */
  87422. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  87423. /** mag = linear and min = nearest and mip = linear */
  87424. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  87425. /** mag = linear and min = linear and mip = none */
  87426. static readonly LINEAR_LINEAR: number;
  87427. /** mag = linear and min = nearest and mip = none */
  87428. static readonly LINEAR_NEAREST: number;
  87429. /** Explicit coordinates mode */
  87430. static readonly EXPLICIT_MODE: number;
  87431. /** Spherical coordinates mode */
  87432. static readonly SPHERICAL_MODE: number;
  87433. /** Planar coordinates mode */
  87434. static readonly PLANAR_MODE: number;
  87435. /** Cubic coordinates mode */
  87436. static readonly CUBIC_MODE: number;
  87437. /** Projection coordinates mode */
  87438. static readonly PROJECTION_MODE: number;
  87439. /** Inverse Cubic coordinates mode */
  87440. static readonly SKYBOX_MODE: number;
  87441. /** Inverse Cubic coordinates mode */
  87442. static readonly INVCUBIC_MODE: number;
  87443. /** Equirectangular coordinates mode */
  87444. static readonly EQUIRECTANGULAR_MODE: number;
  87445. /** Equirectangular Fixed coordinates mode */
  87446. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  87447. /** Equirectangular Fixed Mirrored coordinates mode */
  87448. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87449. /** Texture is not repeating outside of 0..1 UVs */
  87450. static readonly CLAMP_ADDRESSMODE: number;
  87451. /** Texture is repeating outside of 0..1 UVs */
  87452. static readonly WRAP_ADDRESSMODE: number;
  87453. /** Texture is repeating and mirrored */
  87454. static readonly MIRROR_ADDRESSMODE: number;
  87455. /**
  87456. * 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
  87457. */
  87458. static UseSerializedUrlIfAny: boolean;
  87459. /**
  87460. * Define the url of the texture.
  87461. */
  87462. url: Nullable<string>;
  87463. /**
  87464. * Define an offset on the texture to offset the u coordinates of the UVs
  87465. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  87466. */
  87467. uOffset: number;
  87468. /**
  87469. * Define an offset on the texture to offset the v coordinates of the UVs
  87470. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  87471. */
  87472. vOffset: number;
  87473. /**
  87474. * Define an offset on the texture to scale the u coordinates of the UVs
  87475. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  87476. */
  87477. uScale: number;
  87478. /**
  87479. * Define an offset on the texture to scale the v coordinates of the UVs
  87480. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  87481. */
  87482. vScale: number;
  87483. /**
  87484. * Define an offset on the texture to rotate around the u coordinates of the UVs
  87485. * @see http://doc.babylonjs.com/how_to/more_materials
  87486. */
  87487. uAng: number;
  87488. /**
  87489. * Define an offset on the texture to rotate around the v coordinates of the UVs
  87490. * @see http://doc.babylonjs.com/how_to/more_materials
  87491. */
  87492. vAng: number;
  87493. /**
  87494. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  87495. * @see http://doc.babylonjs.com/how_to/more_materials
  87496. */
  87497. wAng: number;
  87498. /**
  87499. * Defines the center of rotation (U)
  87500. */
  87501. uRotationCenter: number;
  87502. /**
  87503. * Defines the center of rotation (V)
  87504. */
  87505. vRotationCenter: number;
  87506. /**
  87507. * Defines the center of rotation (W)
  87508. */
  87509. wRotationCenter: number;
  87510. /**
  87511. * Are mip maps generated for this texture or not.
  87512. */
  87513. get noMipmap(): boolean;
  87514. /**
  87515. * List of inspectable custom properties (used by the Inspector)
  87516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87517. */
  87518. inspectableCustomProperties: Nullable<IInspectable[]>;
  87519. private _noMipmap;
  87520. /** @hidden */
  87521. _invertY: boolean;
  87522. private _rowGenerationMatrix;
  87523. private _cachedTextureMatrix;
  87524. private _projectionModeMatrix;
  87525. private _t0;
  87526. private _t1;
  87527. private _t2;
  87528. private _cachedUOffset;
  87529. private _cachedVOffset;
  87530. private _cachedUScale;
  87531. private _cachedVScale;
  87532. private _cachedUAng;
  87533. private _cachedVAng;
  87534. private _cachedWAng;
  87535. private _cachedProjectionMatrixId;
  87536. private _cachedCoordinatesMode;
  87537. /** @hidden */
  87538. protected _initialSamplingMode: number;
  87539. /** @hidden */
  87540. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  87541. private _deleteBuffer;
  87542. protected _format: Nullable<number>;
  87543. private _delayedOnLoad;
  87544. private _delayedOnError;
  87545. private _mimeType?;
  87546. /**
  87547. * Observable triggered once the texture has been loaded.
  87548. */
  87549. onLoadObservable: Observable<Texture>;
  87550. protected _isBlocking: boolean;
  87551. /**
  87552. * Is the texture preventing material to render while loading.
  87553. * If false, a default texture will be used instead of the loading one during the preparation step.
  87554. */
  87555. set isBlocking(value: boolean);
  87556. get isBlocking(): boolean;
  87557. /**
  87558. * Get the current sampling mode associated with the texture.
  87559. */
  87560. get samplingMode(): number;
  87561. /**
  87562. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  87563. */
  87564. get invertY(): boolean;
  87565. /**
  87566. * Instantiates a new texture.
  87567. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  87568. * @see http://doc.babylonjs.com/babylon101/materials#texture
  87569. * @param url defines the url of the picture to load as a texture
  87570. * @param scene defines the scene or engine the texture will belong to
  87571. * @param noMipmap defines if the texture will require mip maps or not
  87572. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  87573. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  87574. * @param onLoad defines a callback triggered when the texture has been loaded
  87575. * @param onError defines a callback triggered when an error occurred during the loading session
  87576. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  87577. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  87578. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  87579. * @param mimeType defines an optional mime type information
  87580. */
  87581. 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);
  87582. /**
  87583. * Update the url (and optional buffer) of this texture if url was null during construction.
  87584. * @param url the url of the texture
  87585. * @param buffer the buffer of the texture (defaults to null)
  87586. * @param onLoad callback called when the texture is loaded (defaults to null)
  87587. */
  87588. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  87589. /**
  87590. * Finish the loading sequence of a texture flagged as delayed load.
  87591. * @hidden
  87592. */
  87593. delayLoad(): void;
  87594. private _prepareRowForTextureGeneration;
  87595. /**
  87596. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  87597. * @returns the transform matrix of the texture.
  87598. */
  87599. getTextureMatrix(uBase?: number): Matrix;
  87600. /**
  87601. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  87602. * @returns The reflection texture transform
  87603. */
  87604. getReflectionTextureMatrix(): Matrix;
  87605. /**
  87606. * Clones the texture.
  87607. * @returns the cloned texture
  87608. */
  87609. clone(): Texture;
  87610. /**
  87611. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  87612. * @returns The JSON representation of the texture
  87613. */
  87614. serialize(): any;
  87615. /**
  87616. * Get the current class name of the texture useful for serialization or dynamic coding.
  87617. * @returns "Texture"
  87618. */
  87619. getClassName(): string;
  87620. /**
  87621. * Dispose the texture and release its associated resources.
  87622. */
  87623. dispose(): void;
  87624. /**
  87625. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  87626. * @param parsedTexture Define the JSON representation of the texture
  87627. * @param scene Define the scene the parsed texture should be instantiated in
  87628. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  87629. * @returns The parsed texture if successful
  87630. */
  87631. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  87632. /**
  87633. * Creates a texture from its base 64 representation.
  87634. * @param data Define the base64 payload without the data: prefix
  87635. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  87636. * @param scene Define the scene the texture should belong to
  87637. * @param noMipmap Forces the texture to not create mip map information if true
  87638. * @param invertY define if the texture needs to be inverted on the y axis during loading
  87639. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  87640. * @param onLoad define a callback triggered when the texture has been loaded
  87641. * @param onError define a callback triggered when an error occurred during the loading session
  87642. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  87643. * @returns the created texture
  87644. */
  87645. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  87646. /**
  87647. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  87648. * @param data Define the base64 payload without the data: prefix
  87649. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  87650. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  87651. * @param scene Define the scene the texture should belong to
  87652. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  87653. * @param noMipmap Forces the texture to not create mip map information if true
  87654. * @param invertY define if the texture needs to be inverted on the y axis during loading
  87655. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  87656. * @param onLoad define a callback triggered when the texture has been loaded
  87657. * @param onError define a callback triggered when an error occurred during the loading session
  87658. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  87659. * @returns the created texture
  87660. */
  87661. 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;
  87662. }
  87663. }
  87664. declare module BABYLON {
  87665. /**
  87666. * PostProcessManager is used to manage one or more post processes or post process pipelines
  87667. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  87668. */
  87669. export class PostProcessManager {
  87670. private _scene;
  87671. private _indexBuffer;
  87672. private _vertexBuffers;
  87673. /**
  87674. * Creates a new instance PostProcess
  87675. * @param scene The scene that the post process is associated with.
  87676. */
  87677. constructor(scene: Scene);
  87678. private _prepareBuffers;
  87679. private _buildIndexBuffer;
  87680. /**
  87681. * Rebuilds the vertex buffers of the manager.
  87682. * @hidden
  87683. */
  87684. _rebuild(): void;
  87685. /**
  87686. * Prepares a frame to be run through a post process.
  87687. * @param sourceTexture The input texture to the post procesess. (default: null)
  87688. * @param postProcesses An array of post processes to be run. (default: null)
  87689. * @returns True if the post processes were able to be run.
  87690. * @hidden
  87691. */
  87692. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  87693. /**
  87694. * Manually render a set of post processes to a texture.
  87695. * @param postProcesses An array of post processes to be run.
  87696. * @param targetTexture The target texture to render to.
  87697. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  87698. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  87699. * @param lodLevel defines which lod of the texture to render to
  87700. */
  87701. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  87702. /**
  87703. * Finalize the result of the output of the postprocesses.
  87704. * @param doNotPresent If true the result will not be displayed to the screen.
  87705. * @param targetTexture The target texture to render to.
  87706. * @param faceIndex The index of the face to bind the target texture to.
  87707. * @param postProcesses The array of post processes to render.
  87708. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  87709. * @hidden
  87710. */
  87711. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  87712. /**
  87713. * Disposes of the post process manager.
  87714. */
  87715. dispose(): void;
  87716. }
  87717. }
  87718. declare module BABYLON {
  87719. /** Interface used by value gradients (color, factor, ...) */
  87720. export interface IValueGradient {
  87721. /**
  87722. * Gets or sets the gradient value (between 0 and 1)
  87723. */
  87724. gradient: number;
  87725. }
  87726. /** Class used to store color4 gradient */
  87727. export class ColorGradient implements IValueGradient {
  87728. /**
  87729. * Gets or sets the gradient value (between 0 and 1)
  87730. */
  87731. gradient: number;
  87732. /**
  87733. * Gets or sets first associated color
  87734. */
  87735. color1: Color4;
  87736. /**
  87737. * Gets or sets second associated color
  87738. */
  87739. color2?: Color4;
  87740. /**
  87741. * Will get a color picked randomly between color1 and color2.
  87742. * If color2 is undefined then color1 will be used
  87743. * @param result defines the target Color4 to store the result in
  87744. */
  87745. getColorToRef(result: Color4): void;
  87746. }
  87747. /** Class used to store color 3 gradient */
  87748. export class Color3Gradient implements IValueGradient {
  87749. /**
  87750. * Gets or sets the gradient value (between 0 and 1)
  87751. */
  87752. gradient: number;
  87753. /**
  87754. * Gets or sets the associated color
  87755. */
  87756. color: Color3;
  87757. }
  87758. /** Class used to store factor gradient */
  87759. export class FactorGradient implements IValueGradient {
  87760. /**
  87761. * Gets or sets the gradient value (between 0 and 1)
  87762. */
  87763. gradient: number;
  87764. /**
  87765. * Gets or sets first associated factor
  87766. */
  87767. factor1: number;
  87768. /**
  87769. * Gets or sets second associated factor
  87770. */
  87771. factor2?: number;
  87772. /**
  87773. * Will get a number picked randomly between factor1 and factor2.
  87774. * If factor2 is undefined then factor1 will be used
  87775. * @returns the picked number
  87776. */
  87777. getFactor(): number;
  87778. }
  87779. /**
  87780. * Helper used to simplify some generic gradient tasks
  87781. */
  87782. export class GradientHelper {
  87783. /**
  87784. * Gets the current gradient from an array of IValueGradient
  87785. * @param ratio defines the current ratio to get
  87786. * @param gradients defines the array of IValueGradient
  87787. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87788. */
  87789. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87790. }
  87791. }
  87792. declare module BABYLON {
  87793. interface ThinEngine {
  87794. /**
  87795. * Creates a dynamic texture
  87796. * @param width defines the width of the texture
  87797. * @param height defines the height of the texture
  87798. * @param generateMipMaps defines if the engine should generate the mip levels
  87799. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87800. * @returns the dynamic texture inside an InternalTexture
  87801. */
  87802. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87803. /**
  87804. * Update the content of a dynamic texture
  87805. * @param texture defines the texture to update
  87806. * @param canvas defines the canvas containing the source
  87807. * @param invertY defines if data must be stored with Y axis inverted
  87808. * @param premulAlpha defines if alpha is stored as premultiplied
  87809. * @param format defines the format of the data
  87810. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87811. */
  87812. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87813. }
  87814. }
  87815. declare module BABYLON {
  87816. /**
  87817. * Helper class used to generate a canvas to manipulate images
  87818. */
  87819. export class CanvasGenerator {
  87820. /**
  87821. * Create a new canvas (or offscreen canvas depending on the context)
  87822. * @param width defines the expected width
  87823. * @param height defines the expected height
  87824. * @return a new canvas or offscreen canvas
  87825. */
  87826. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  87827. }
  87828. }
  87829. declare module BABYLON {
  87830. /**
  87831. * A class extending Texture allowing drawing on a texture
  87832. * @see http://doc.babylonjs.com/how_to/dynamictexture
  87833. */
  87834. export class DynamicTexture extends Texture {
  87835. private _generateMipMaps;
  87836. private _canvas;
  87837. private _context;
  87838. private _engine;
  87839. /**
  87840. * Creates a DynamicTexture
  87841. * @param name defines the name of the texture
  87842. * @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
  87843. * @param scene defines the scene where you want the texture
  87844. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  87845. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  87846. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  87847. */
  87848. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  87849. /**
  87850. * Get the current class name of the texture useful for serialization or dynamic coding.
  87851. * @returns "DynamicTexture"
  87852. */
  87853. getClassName(): string;
  87854. /**
  87855. * Gets the current state of canRescale
  87856. */
  87857. get canRescale(): boolean;
  87858. private _recreate;
  87859. /**
  87860. * Scales the texture
  87861. * @param ratio the scale factor to apply to both width and height
  87862. */
  87863. scale(ratio: number): void;
  87864. /**
  87865. * Resizes the texture
  87866. * @param width the new width
  87867. * @param height the new height
  87868. */
  87869. scaleTo(width: number, height: number): void;
  87870. /**
  87871. * Gets the context of the canvas used by the texture
  87872. * @returns the canvas context of the dynamic texture
  87873. */
  87874. getContext(): CanvasRenderingContext2D;
  87875. /**
  87876. * Clears the texture
  87877. */
  87878. clear(): void;
  87879. /**
  87880. * Updates the texture
  87881. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87882. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  87883. */
  87884. update(invertY?: boolean, premulAlpha?: boolean): void;
  87885. /**
  87886. * Draws text onto the texture
  87887. * @param text defines the text to be drawn
  87888. * @param x defines the placement of the text from the left
  87889. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  87890. * @param font defines the font to be used with font-style, font-size, font-name
  87891. * @param color defines the color used for the text
  87892. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  87893. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87894. * @param update defines whether texture is immediately update (default is true)
  87895. */
  87896. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  87897. /**
  87898. * Clones the texture
  87899. * @returns the clone of the texture.
  87900. */
  87901. clone(): DynamicTexture;
  87902. /**
  87903. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  87904. * @returns a serialized dynamic texture object
  87905. */
  87906. serialize(): any;
  87907. /** @hidden */
  87908. _rebuild(): void;
  87909. }
  87910. }
  87911. declare module BABYLON {
  87912. interface AbstractScene {
  87913. /**
  87914. * The list of procedural textures added to the scene
  87915. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87916. */
  87917. proceduralTextures: Array<ProceduralTexture>;
  87918. }
  87919. /**
  87920. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  87921. * in a given scene.
  87922. */
  87923. export class ProceduralTextureSceneComponent implements ISceneComponent {
  87924. /**
  87925. * The component name helpfull to identify the component in the list of scene components.
  87926. */
  87927. readonly name: string;
  87928. /**
  87929. * The scene the component belongs to.
  87930. */
  87931. scene: Scene;
  87932. /**
  87933. * Creates a new instance of the component for the given scene
  87934. * @param scene Defines the scene to register the component in
  87935. */
  87936. constructor(scene: Scene);
  87937. /**
  87938. * Registers the component in a given scene
  87939. */
  87940. register(): void;
  87941. /**
  87942. * Rebuilds the elements related to this component in case of
  87943. * context lost for instance.
  87944. */
  87945. rebuild(): void;
  87946. /**
  87947. * Disposes the component and the associated ressources.
  87948. */
  87949. dispose(): void;
  87950. private _beforeClear;
  87951. }
  87952. }
  87953. declare module BABYLON {
  87954. interface ThinEngine {
  87955. /**
  87956. * Creates a new render target cube texture
  87957. * @param size defines the size of the texture
  87958. * @param options defines the options used to create the texture
  87959. * @returns a new render target cube texture stored in an InternalTexture
  87960. */
  87961. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87962. }
  87963. }
  87964. declare module BABYLON {
  87965. /** @hidden */
  87966. export var proceduralVertexShader: {
  87967. name: string;
  87968. shader: string;
  87969. };
  87970. }
  87971. declare module BABYLON {
  87972. /**
  87973. * 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.
  87974. * This is the base class of any Procedural texture and contains most of the shareable code.
  87975. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87976. */
  87977. export class ProceduralTexture extends Texture {
  87978. isCube: boolean;
  87979. /**
  87980. * Define if the texture is enabled or not (disabled texture will not render)
  87981. */
  87982. isEnabled: boolean;
  87983. /**
  87984. * Define if the texture must be cleared before rendering (default is true)
  87985. */
  87986. autoClear: boolean;
  87987. /**
  87988. * Callback called when the texture is generated
  87989. */
  87990. onGenerated: () => void;
  87991. /**
  87992. * Event raised when the texture is generated
  87993. */
  87994. onGeneratedObservable: Observable<ProceduralTexture>;
  87995. /** @hidden */
  87996. _generateMipMaps: boolean;
  87997. /** @hidden **/
  87998. _effect: Effect;
  87999. /** @hidden */
  88000. _textures: {
  88001. [key: string]: Texture;
  88002. };
  88003. private _size;
  88004. private _currentRefreshId;
  88005. private _frameId;
  88006. private _refreshRate;
  88007. private _vertexBuffers;
  88008. private _indexBuffer;
  88009. private _uniforms;
  88010. private _samplers;
  88011. private _fragment;
  88012. private _floats;
  88013. private _ints;
  88014. private _floatsArrays;
  88015. private _colors3;
  88016. private _colors4;
  88017. private _vectors2;
  88018. private _vectors3;
  88019. private _matrices;
  88020. private _fallbackTexture;
  88021. private _fallbackTextureUsed;
  88022. private _engine;
  88023. private _cachedDefines;
  88024. private _contentUpdateId;
  88025. private _contentData;
  88026. /**
  88027. * Instantiates a new procedural texture.
  88028. * 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.
  88029. * This is the base class of any Procedural texture and contains most of the shareable code.
  88030. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88031. * @param name Define the name of the texture
  88032. * @param size Define the size of the texture to create
  88033. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  88034. * @param scene Define the scene the texture belongs to
  88035. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  88036. * @param generateMipMaps Define if the texture should creates mip maps or not
  88037. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  88038. */
  88039. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  88040. /**
  88041. * The effect that is created when initializing the post process.
  88042. * @returns The created effect corresponding the the postprocess.
  88043. */
  88044. getEffect(): Effect;
  88045. /**
  88046. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  88047. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  88048. */
  88049. getContent(): Nullable<ArrayBufferView>;
  88050. private _createIndexBuffer;
  88051. /** @hidden */
  88052. _rebuild(): void;
  88053. /**
  88054. * Resets the texture in order to recreate its associated resources.
  88055. * This can be called in case of context loss
  88056. */
  88057. reset(): void;
  88058. protected _getDefines(): string;
  88059. /**
  88060. * Is the texture ready to be used ? (rendered at least once)
  88061. * @returns true if ready, otherwise, false.
  88062. */
  88063. isReady(): boolean;
  88064. /**
  88065. * Resets the refresh counter of the texture and start bak from scratch.
  88066. * Could be useful to regenerate the texture if it is setup to render only once.
  88067. */
  88068. resetRefreshCounter(): void;
  88069. /**
  88070. * Set the fragment shader to use in order to render the texture.
  88071. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  88072. */
  88073. setFragment(fragment: any): void;
  88074. /**
  88075. * Define the refresh rate of the texture or the rendering frequency.
  88076. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88077. */
  88078. get refreshRate(): number;
  88079. set refreshRate(value: number);
  88080. /** @hidden */
  88081. _shouldRender(): boolean;
  88082. /**
  88083. * Get the size the texture is rendering at.
  88084. * @returns the size (texture is always squared)
  88085. */
  88086. getRenderSize(): number;
  88087. /**
  88088. * Resize the texture to new value.
  88089. * @param size Define the new size the texture should have
  88090. * @param generateMipMaps Define whether the new texture should create mip maps
  88091. */
  88092. resize(size: number, generateMipMaps: boolean): void;
  88093. private _checkUniform;
  88094. /**
  88095. * Set a texture in the shader program used to render.
  88096. * @param name Define the name of the uniform samplers as defined in the shader
  88097. * @param texture Define the texture to bind to this sampler
  88098. * @return the texture itself allowing "fluent" like uniform updates
  88099. */
  88100. setTexture(name: string, texture: Texture): ProceduralTexture;
  88101. /**
  88102. * Set a float in the shader.
  88103. * @param name Define the name of the uniform as defined in the shader
  88104. * @param value Define the value to give to the uniform
  88105. * @return the texture itself allowing "fluent" like uniform updates
  88106. */
  88107. setFloat(name: string, value: number): ProceduralTexture;
  88108. /**
  88109. * Set a int in the shader.
  88110. * @param name Define the name of the uniform as defined in the shader
  88111. * @param value Define the value to give to the uniform
  88112. * @return the texture itself allowing "fluent" like uniform updates
  88113. */
  88114. setInt(name: string, value: number): ProceduralTexture;
  88115. /**
  88116. * Set an array of floats in the shader.
  88117. * @param name Define the name of the uniform as defined in the shader
  88118. * @param value Define the value to give to the uniform
  88119. * @return the texture itself allowing "fluent" like uniform updates
  88120. */
  88121. setFloats(name: string, value: number[]): ProceduralTexture;
  88122. /**
  88123. * Set a vec3 in the shader from a Color3.
  88124. * @param name Define the name of the uniform as defined in the shader
  88125. * @param value Define the value to give to the uniform
  88126. * @return the texture itself allowing "fluent" like uniform updates
  88127. */
  88128. setColor3(name: string, value: Color3): ProceduralTexture;
  88129. /**
  88130. * Set a vec4 in the shader from a Color4.
  88131. * @param name Define the name of the uniform as defined in the shader
  88132. * @param value Define the value to give to the uniform
  88133. * @return the texture itself allowing "fluent" like uniform updates
  88134. */
  88135. setColor4(name: string, value: Color4): ProceduralTexture;
  88136. /**
  88137. * Set a vec2 in the shader from a Vector2.
  88138. * @param name Define the name of the uniform as defined in the shader
  88139. * @param value Define the value to give to the uniform
  88140. * @return the texture itself allowing "fluent" like uniform updates
  88141. */
  88142. setVector2(name: string, value: Vector2): ProceduralTexture;
  88143. /**
  88144. * Set a vec3 in the shader from a Vector3.
  88145. * @param name Define the name of the uniform as defined in the shader
  88146. * @param value Define the value to give to the uniform
  88147. * @return the texture itself allowing "fluent" like uniform updates
  88148. */
  88149. setVector3(name: string, value: Vector3): ProceduralTexture;
  88150. /**
  88151. * Set a mat4 in the shader from a MAtrix.
  88152. * @param name Define the name of the uniform as defined in the shader
  88153. * @param value Define the value to give to the uniform
  88154. * @return the texture itself allowing "fluent" like uniform updates
  88155. */
  88156. setMatrix(name: string, value: Matrix): ProceduralTexture;
  88157. /**
  88158. * Render the texture to its associated render target.
  88159. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  88160. */
  88161. render(useCameraPostProcess?: boolean): void;
  88162. /**
  88163. * Clone the texture.
  88164. * @returns the cloned texture
  88165. */
  88166. clone(): ProceduralTexture;
  88167. /**
  88168. * Dispose the texture and release its asoociated resources.
  88169. */
  88170. dispose(): void;
  88171. }
  88172. }
  88173. declare module BABYLON {
  88174. /**
  88175. * This represents the base class for particle system in Babylon.
  88176. * 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.
  88177. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  88178. * @example https://doc.babylonjs.com/babylon101/particles
  88179. */
  88180. export class BaseParticleSystem {
  88181. /**
  88182. * Source color is added to the destination color without alpha affecting the result
  88183. */
  88184. static BLENDMODE_ONEONE: number;
  88185. /**
  88186. * Blend current color and particle color using particle’s alpha
  88187. */
  88188. static BLENDMODE_STANDARD: number;
  88189. /**
  88190. * Add current color and particle color multiplied by particle’s alpha
  88191. */
  88192. static BLENDMODE_ADD: number;
  88193. /**
  88194. * Multiply current color with particle color
  88195. */
  88196. static BLENDMODE_MULTIPLY: number;
  88197. /**
  88198. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  88199. */
  88200. static BLENDMODE_MULTIPLYADD: number;
  88201. /**
  88202. * List of animations used by the particle system.
  88203. */
  88204. animations: Animation[];
  88205. /**
  88206. * The id of the Particle system.
  88207. */
  88208. id: string;
  88209. /**
  88210. * The friendly name of the Particle system.
  88211. */
  88212. name: string;
  88213. /**
  88214. * The rendering group used by the Particle system to chose when to render.
  88215. */
  88216. renderingGroupId: number;
  88217. /**
  88218. * The emitter represents the Mesh or position we are attaching the particle system to.
  88219. */
  88220. emitter: Nullable<AbstractMesh | Vector3>;
  88221. /**
  88222. * The maximum number of particles to emit per frame
  88223. */
  88224. emitRate: number;
  88225. /**
  88226. * If you want to launch only a few particles at once, that can be done, as well.
  88227. */
  88228. manualEmitCount: number;
  88229. /**
  88230. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  88231. */
  88232. updateSpeed: number;
  88233. /**
  88234. * The amount of time the particle system is running (depends of the overall update speed).
  88235. */
  88236. targetStopDuration: number;
  88237. /**
  88238. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  88239. */
  88240. disposeOnStop: boolean;
  88241. /**
  88242. * Minimum power of emitting particles.
  88243. */
  88244. minEmitPower: number;
  88245. /**
  88246. * Maximum power of emitting particles.
  88247. */
  88248. maxEmitPower: number;
  88249. /**
  88250. * Minimum life time of emitting particles.
  88251. */
  88252. minLifeTime: number;
  88253. /**
  88254. * Maximum life time of emitting particles.
  88255. */
  88256. maxLifeTime: number;
  88257. /**
  88258. * Minimum Size of emitting particles.
  88259. */
  88260. minSize: number;
  88261. /**
  88262. * Maximum Size of emitting particles.
  88263. */
  88264. maxSize: number;
  88265. /**
  88266. * Minimum scale of emitting particles on X axis.
  88267. */
  88268. minScaleX: number;
  88269. /**
  88270. * Maximum scale of emitting particles on X axis.
  88271. */
  88272. maxScaleX: number;
  88273. /**
  88274. * Minimum scale of emitting particles on Y axis.
  88275. */
  88276. minScaleY: number;
  88277. /**
  88278. * Maximum scale of emitting particles on Y axis.
  88279. */
  88280. maxScaleY: number;
  88281. /**
  88282. * Gets or sets the minimal initial rotation in radians.
  88283. */
  88284. minInitialRotation: number;
  88285. /**
  88286. * Gets or sets the maximal initial rotation in radians.
  88287. */
  88288. maxInitialRotation: number;
  88289. /**
  88290. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  88291. */
  88292. minAngularSpeed: number;
  88293. /**
  88294. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  88295. */
  88296. maxAngularSpeed: number;
  88297. /**
  88298. * The texture used to render each particle. (this can be a spritesheet)
  88299. */
  88300. particleTexture: Nullable<Texture>;
  88301. /**
  88302. * The layer mask we are rendering the particles through.
  88303. */
  88304. layerMask: number;
  88305. /**
  88306. * This can help using your own shader to render the particle system.
  88307. * The according effect will be created
  88308. */
  88309. customShader: any;
  88310. /**
  88311. * By default particle system starts as soon as they are created. This prevents the
  88312. * automatic start to happen and let you decide when to start emitting particles.
  88313. */
  88314. preventAutoStart: boolean;
  88315. private _noiseTexture;
  88316. /**
  88317. * Gets or sets a texture used to add random noise to particle positions
  88318. */
  88319. get noiseTexture(): Nullable<ProceduralTexture>;
  88320. set noiseTexture(value: Nullable<ProceduralTexture>);
  88321. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  88322. noiseStrength: Vector3;
  88323. /**
  88324. * Callback triggered when the particle animation is ending.
  88325. */
  88326. onAnimationEnd: Nullable<() => void>;
  88327. /**
  88328. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  88329. */
  88330. blendMode: number;
  88331. /**
  88332. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  88333. * to override the particles.
  88334. */
  88335. forceDepthWrite: boolean;
  88336. /** 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 */
  88337. preWarmCycles: number;
  88338. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  88339. preWarmStepOffset: number;
  88340. /**
  88341. * 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)
  88342. */
  88343. spriteCellChangeSpeed: number;
  88344. /**
  88345. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  88346. */
  88347. startSpriteCellID: number;
  88348. /**
  88349. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  88350. */
  88351. endSpriteCellID: number;
  88352. /**
  88353. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  88354. */
  88355. spriteCellWidth: number;
  88356. /**
  88357. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  88358. */
  88359. spriteCellHeight: number;
  88360. /**
  88361. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  88362. */
  88363. spriteRandomStartCell: boolean;
  88364. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  88365. translationPivot: Vector2;
  88366. /** @hidden */
  88367. protected _isAnimationSheetEnabled: boolean;
  88368. /**
  88369. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  88370. */
  88371. beginAnimationOnStart: boolean;
  88372. /**
  88373. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  88374. */
  88375. beginAnimationFrom: number;
  88376. /**
  88377. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  88378. */
  88379. beginAnimationTo: number;
  88380. /**
  88381. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  88382. */
  88383. beginAnimationLoop: boolean;
  88384. /**
  88385. * Gets or sets a world offset applied to all particles
  88386. */
  88387. worldOffset: Vector3;
  88388. /**
  88389. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  88390. */
  88391. get isAnimationSheetEnabled(): boolean;
  88392. set isAnimationSheetEnabled(value: boolean);
  88393. /**
  88394. * Get hosting scene
  88395. * @returns the scene
  88396. */
  88397. getScene(): Scene;
  88398. /**
  88399. * You can use gravity if you want to give an orientation to your particles.
  88400. */
  88401. gravity: Vector3;
  88402. protected _colorGradients: Nullable<Array<ColorGradient>>;
  88403. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  88404. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  88405. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  88406. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  88407. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  88408. protected _dragGradients: Nullable<Array<FactorGradient>>;
  88409. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  88410. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  88411. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  88412. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  88413. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  88414. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  88415. /**
  88416. * Defines the delay in milliseconds before starting the system (0 by default)
  88417. */
  88418. startDelay: number;
  88419. /**
  88420. * Gets the current list of drag gradients.
  88421. * You must use addDragGradient and removeDragGradient to udpate this list
  88422. * @returns the list of drag gradients
  88423. */
  88424. getDragGradients(): Nullable<Array<FactorGradient>>;
  88425. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  88426. limitVelocityDamping: number;
  88427. /**
  88428. * Gets the current list of limit velocity gradients.
  88429. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  88430. * @returns the list of limit velocity gradients
  88431. */
  88432. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  88433. /**
  88434. * Gets the current list of color gradients.
  88435. * You must use addColorGradient and removeColorGradient to udpate this list
  88436. * @returns the list of color gradients
  88437. */
  88438. getColorGradients(): Nullable<Array<ColorGradient>>;
  88439. /**
  88440. * Gets the current list of size gradients.
  88441. * You must use addSizeGradient and removeSizeGradient to udpate this list
  88442. * @returns the list of size gradients
  88443. */
  88444. getSizeGradients(): Nullable<Array<FactorGradient>>;
  88445. /**
  88446. * Gets the current list of color remap gradients.
  88447. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  88448. * @returns the list of color remap gradients
  88449. */
  88450. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  88451. /**
  88452. * Gets the current list of alpha remap gradients.
  88453. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  88454. * @returns the list of alpha remap gradients
  88455. */
  88456. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  88457. /**
  88458. * Gets the current list of life time gradients.
  88459. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  88460. * @returns the list of life time gradients
  88461. */
  88462. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  88463. /**
  88464. * Gets the current list of angular speed gradients.
  88465. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  88466. * @returns the list of angular speed gradients
  88467. */
  88468. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  88469. /**
  88470. * Gets the current list of velocity gradients.
  88471. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  88472. * @returns the list of velocity gradients
  88473. */
  88474. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  88475. /**
  88476. * Gets the current list of start size gradients.
  88477. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  88478. * @returns the list of start size gradients
  88479. */
  88480. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  88481. /**
  88482. * Gets the current list of emit rate gradients.
  88483. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  88484. * @returns the list of emit rate gradients
  88485. */
  88486. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  88487. /**
  88488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88489. * This only works when particleEmitterTyps is a BoxParticleEmitter
  88490. */
  88491. get direction1(): Vector3;
  88492. set direction1(value: Vector3);
  88493. /**
  88494. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88495. * This only works when particleEmitterTyps is a BoxParticleEmitter
  88496. */
  88497. get direction2(): Vector3;
  88498. set direction2(value: Vector3);
  88499. /**
  88500. * 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.
  88501. * This only works when particleEmitterTyps is a BoxParticleEmitter
  88502. */
  88503. get minEmitBox(): Vector3;
  88504. set minEmitBox(value: Vector3);
  88505. /**
  88506. * 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.
  88507. * This only works when particleEmitterTyps is a BoxParticleEmitter
  88508. */
  88509. get maxEmitBox(): Vector3;
  88510. set maxEmitBox(value: Vector3);
  88511. /**
  88512. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  88513. */
  88514. color1: Color4;
  88515. /**
  88516. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  88517. */
  88518. color2: Color4;
  88519. /**
  88520. * Color the particle will have at the end of its lifetime
  88521. */
  88522. colorDead: Color4;
  88523. /**
  88524. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  88525. */
  88526. textureMask: Color4;
  88527. /**
  88528. * The particle emitter type defines the emitter used by the particle system.
  88529. * It can be for example box, sphere, or cone...
  88530. */
  88531. particleEmitterType: IParticleEmitterType;
  88532. /** @hidden */
  88533. _isSubEmitter: boolean;
  88534. /**
  88535. * Gets or sets the billboard mode to use when isBillboardBased = true.
  88536. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  88537. */
  88538. billboardMode: number;
  88539. protected _isBillboardBased: boolean;
  88540. /**
  88541. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  88542. */
  88543. get isBillboardBased(): boolean;
  88544. set isBillboardBased(value: boolean);
  88545. /**
  88546. * The scene the particle system belongs to.
  88547. */
  88548. protected _scene: Scene;
  88549. /**
  88550. * Local cache of defines for image processing.
  88551. */
  88552. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  88553. /**
  88554. * Default configuration related to image processing available in the standard Material.
  88555. */
  88556. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88557. /**
  88558. * Gets the image processing configuration used either in this material.
  88559. */
  88560. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  88561. /**
  88562. * Sets the Default image processing configuration used either in the this material.
  88563. *
  88564. * If sets to null, the scene one is in use.
  88565. */
  88566. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  88567. /**
  88568. * Attaches a new image processing configuration to the Standard Material.
  88569. * @param configuration
  88570. */
  88571. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  88572. /** @hidden */
  88573. protected _reset(): void;
  88574. /** @hidden */
  88575. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  88576. /**
  88577. * Instantiates a particle system.
  88578. * 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.
  88579. * @param name The name of the particle system
  88580. */
  88581. constructor(name: string);
  88582. /**
  88583. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  88584. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88585. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88586. * @returns the emitter
  88587. */
  88588. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  88589. /**
  88590. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  88591. * @param radius The radius of the hemisphere to emit from
  88592. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88593. * @returns the emitter
  88594. */
  88595. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  88596. /**
  88597. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  88598. * @param radius The radius of the sphere to emit from
  88599. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88600. * @returns the emitter
  88601. */
  88602. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  88603. /**
  88604. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  88605. * @param radius The radius of the sphere to emit from
  88606. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  88607. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  88608. * @returns the emitter
  88609. */
  88610. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  88611. /**
  88612. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  88613. * @param radius The radius of the emission cylinder
  88614. * @param height The height of the emission cylinder
  88615. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  88616. * @param directionRandomizer How much to randomize the particle direction [0-1]
  88617. * @returns the emitter
  88618. */
  88619. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  88620. /**
  88621. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  88622. * @param radius The radius of the cylinder to emit from
  88623. * @param height The height of the emission cylinder
  88624. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88625. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  88626. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  88627. * @returns the emitter
  88628. */
  88629. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  88630. /**
  88631. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  88632. * @param radius The radius of the cone to emit from
  88633. * @param angle The base angle of the cone
  88634. * @returns the emitter
  88635. */
  88636. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  88637. /**
  88638. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  88639. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88640. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88641. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88642. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88643. * @returns the emitter
  88644. */
  88645. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  88646. }
  88647. }
  88648. declare module BABYLON {
  88649. /**
  88650. * Type of sub emitter
  88651. */
  88652. export enum SubEmitterType {
  88653. /**
  88654. * Attached to the particle over it's lifetime
  88655. */
  88656. ATTACHED = 0,
  88657. /**
  88658. * Created when the particle dies
  88659. */
  88660. END = 1
  88661. }
  88662. /**
  88663. * Sub emitter class used to emit particles from an existing particle
  88664. */
  88665. export class SubEmitter {
  88666. /**
  88667. * the particle system to be used by the sub emitter
  88668. */
  88669. particleSystem: ParticleSystem;
  88670. /**
  88671. * Type of the submitter (Default: END)
  88672. */
  88673. type: SubEmitterType;
  88674. /**
  88675. * 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)
  88676. * Note: This only is supported when using an emitter of type Mesh
  88677. */
  88678. inheritDirection: boolean;
  88679. /**
  88680. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  88681. */
  88682. inheritedVelocityAmount: number;
  88683. /**
  88684. * Creates a sub emitter
  88685. * @param particleSystem the particle system to be used by the sub emitter
  88686. */
  88687. constructor(
  88688. /**
  88689. * the particle system to be used by the sub emitter
  88690. */
  88691. particleSystem: ParticleSystem);
  88692. /**
  88693. * Clones the sub emitter
  88694. * @returns the cloned sub emitter
  88695. */
  88696. clone(): SubEmitter;
  88697. /**
  88698. * Serialize current object to a JSON object
  88699. * @returns the serialized object
  88700. */
  88701. serialize(): any;
  88702. /** @hidden */
  88703. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  88704. /**
  88705. * Creates a new SubEmitter from a serialized JSON version
  88706. * @param serializationObject defines the JSON object to read from
  88707. * @param scene defines the hosting scene
  88708. * @param rootUrl defines the rootUrl for data loading
  88709. * @returns a new SubEmitter
  88710. */
  88711. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  88712. /** Release associated resources */
  88713. dispose(): void;
  88714. }
  88715. }
  88716. declare module BABYLON {
  88717. /** @hidden */
  88718. export var clipPlaneFragmentDeclaration: {
  88719. name: string;
  88720. shader: string;
  88721. };
  88722. }
  88723. declare module BABYLON {
  88724. /** @hidden */
  88725. export var imageProcessingDeclaration: {
  88726. name: string;
  88727. shader: string;
  88728. };
  88729. }
  88730. declare module BABYLON {
  88731. /** @hidden */
  88732. export var imageProcessingFunctions: {
  88733. name: string;
  88734. shader: string;
  88735. };
  88736. }
  88737. declare module BABYLON {
  88738. /** @hidden */
  88739. export var clipPlaneFragment: {
  88740. name: string;
  88741. shader: string;
  88742. };
  88743. }
  88744. declare module BABYLON {
  88745. /** @hidden */
  88746. export var particlesPixelShader: {
  88747. name: string;
  88748. shader: string;
  88749. };
  88750. }
  88751. declare module BABYLON {
  88752. /** @hidden */
  88753. export var clipPlaneVertexDeclaration: {
  88754. name: string;
  88755. shader: string;
  88756. };
  88757. }
  88758. declare module BABYLON {
  88759. /** @hidden */
  88760. export var clipPlaneVertex: {
  88761. name: string;
  88762. shader: string;
  88763. };
  88764. }
  88765. declare module BABYLON {
  88766. /** @hidden */
  88767. export var particlesVertexShader: {
  88768. name: string;
  88769. shader: string;
  88770. };
  88771. }
  88772. declare module BABYLON {
  88773. /**
  88774. * This represents a particle system in Babylon.
  88775. * 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.
  88776. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  88777. * @example https://doc.babylonjs.com/babylon101/particles
  88778. */
  88779. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  88780. /**
  88781. * Billboard mode will only apply to Y axis
  88782. */
  88783. static readonly BILLBOARDMODE_Y: number;
  88784. /**
  88785. * Billboard mode will apply to all axes
  88786. */
  88787. static readonly BILLBOARDMODE_ALL: number;
  88788. /**
  88789. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  88790. */
  88791. static readonly BILLBOARDMODE_STRETCHED: number;
  88792. /**
  88793. * This function can be defined to provide custom update for active particles.
  88794. * This function will be called instead of regular update (age, position, color, etc.).
  88795. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  88796. */
  88797. updateFunction: (particles: Particle[]) => void;
  88798. private _emitterWorldMatrix;
  88799. /**
  88800. * This function can be defined to specify initial direction for every new particle.
  88801. * It by default use the emitterType defined function
  88802. */
  88803. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  88804. /**
  88805. * This function can be defined to specify initial position for every new particle.
  88806. * It by default use the emitterType defined function
  88807. */
  88808. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  88809. /**
  88810. * @hidden
  88811. */
  88812. _inheritedVelocityOffset: Vector3;
  88813. /**
  88814. * An event triggered when the system is disposed
  88815. */
  88816. onDisposeObservable: Observable<ParticleSystem>;
  88817. private _onDisposeObserver;
  88818. /**
  88819. * Sets a callback that will be triggered when the system is disposed
  88820. */
  88821. set onDispose(callback: () => void);
  88822. private _particles;
  88823. private _epsilon;
  88824. private _capacity;
  88825. private _stockParticles;
  88826. private _newPartsExcess;
  88827. private _vertexData;
  88828. private _vertexBuffer;
  88829. private _vertexBuffers;
  88830. private _spriteBuffer;
  88831. private _indexBuffer;
  88832. private _effect;
  88833. private _customEffect;
  88834. private _cachedDefines;
  88835. private _scaledColorStep;
  88836. private _colorDiff;
  88837. private _scaledDirection;
  88838. private _scaledGravity;
  88839. private _currentRenderId;
  88840. private _alive;
  88841. private _useInstancing;
  88842. private _started;
  88843. private _stopped;
  88844. private _actualFrame;
  88845. private _scaledUpdateSpeed;
  88846. private _vertexBufferSize;
  88847. /** @hidden */
  88848. _currentEmitRateGradient: Nullable<FactorGradient>;
  88849. /** @hidden */
  88850. _currentEmitRate1: number;
  88851. /** @hidden */
  88852. _currentEmitRate2: number;
  88853. /** @hidden */
  88854. _currentStartSizeGradient: Nullable<FactorGradient>;
  88855. /** @hidden */
  88856. _currentStartSize1: number;
  88857. /** @hidden */
  88858. _currentStartSize2: number;
  88859. private readonly _rawTextureWidth;
  88860. private _rampGradientsTexture;
  88861. private _useRampGradients;
  88862. /** Gets or sets a boolean indicating that ramp gradients must be used
  88863. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88864. */
  88865. get useRampGradients(): boolean;
  88866. set useRampGradients(value: boolean);
  88867. /**
  88868. * 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.
  88869. * 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: [])
  88870. */
  88871. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  88872. private _subEmitters;
  88873. /**
  88874. * @hidden
  88875. * If the particle systems emitter should be disposed when the particle system is disposed
  88876. */
  88877. _disposeEmitterOnDispose: boolean;
  88878. /**
  88879. * The current active Sub-systems, this property is used by the root particle system only.
  88880. */
  88881. activeSubSystems: Array<ParticleSystem>;
  88882. private _rootParticleSystem;
  88883. /**
  88884. * Gets the current list of active particles
  88885. */
  88886. get particles(): Particle[];
  88887. /**
  88888. * Returns the string "ParticleSystem"
  88889. * @returns a string containing the class name
  88890. */
  88891. getClassName(): string;
  88892. /**
  88893. * Instantiates a particle system.
  88894. * 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.
  88895. * @param name The name of the particle system
  88896. * @param capacity The max number of particles alive at the same time
  88897. * @param scene The scene the particle system belongs to
  88898. * @param customEffect a custom effect used to change the way particles are rendered by default
  88899. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  88900. * @param epsilon Offset used to render the particles
  88901. */
  88902. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  88903. private _addFactorGradient;
  88904. private _removeFactorGradient;
  88905. /**
  88906. * Adds a new life time gradient
  88907. * @param gradient defines the gradient to use (between 0 and 1)
  88908. * @param factor defines the life time factor to affect to the specified gradient
  88909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88910. * @returns the current particle system
  88911. */
  88912. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88913. /**
  88914. * Remove a specific life time gradient
  88915. * @param gradient defines the gradient to remove
  88916. * @returns the current particle system
  88917. */
  88918. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88919. /**
  88920. * Adds a new size gradient
  88921. * @param gradient defines the gradient to use (between 0 and 1)
  88922. * @param factor defines the size factor to affect to the specified gradient
  88923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88924. * @returns the current particle system
  88925. */
  88926. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88927. /**
  88928. * Remove a specific size gradient
  88929. * @param gradient defines the gradient to remove
  88930. * @returns the current particle system
  88931. */
  88932. removeSizeGradient(gradient: number): IParticleSystem;
  88933. /**
  88934. * Adds a new color remap gradient
  88935. * @param gradient defines the gradient to use (between 0 and 1)
  88936. * @param min defines the color remap minimal range
  88937. * @param max defines the color remap maximal range
  88938. * @returns the current particle system
  88939. */
  88940. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88941. /**
  88942. * Remove a specific color remap gradient
  88943. * @param gradient defines the gradient to remove
  88944. * @returns the current particle system
  88945. */
  88946. removeColorRemapGradient(gradient: number): IParticleSystem;
  88947. /**
  88948. * Adds a new alpha remap gradient
  88949. * @param gradient defines the gradient to use (between 0 and 1)
  88950. * @param min defines the alpha remap minimal range
  88951. * @param max defines the alpha remap maximal range
  88952. * @returns the current particle system
  88953. */
  88954. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88955. /**
  88956. * Remove a specific alpha remap gradient
  88957. * @param gradient defines the gradient to remove
  88958. * @returns the current particle system
  88959. */
  88960. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  88961. /**
  88962. * Adds a new angular speed gradient
  88963. * @param gradient defines the gradient to use (between 0 and 1)
  88964. * @param factor defines the angular speed to affect to the specified gradient
  88965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88966. * @returns the current particle system
  88967. */
  88968. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88969. /**
  88970. * Remove a specific angular speed gradient
  88971. * @param gradient defines the gradient to remove
  88972. * @returns the current particle system
  88973. */
  88974. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88975. /**
  88976. * Adds a new velocity gradient
  88977. * @param gradient defines the gradient to use (between 0 and 1)
  88978. * @param factor defines the velocity to affect to the specified gradient
  88979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88980. * @returns the current particle system
  88981. */
  88982. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88983. /**
  88984. * Remove a specific velocity gradient
  88985. * @param gradient defines the gradient to remove
  88986. * @returns the current particle system
  88987. */
  88988. removeVelocityGradient(gradient: number): IParticleSystem;
  88989. /**
  88990. * Adds a new limit velocity gradient
  88991. * @param gradient defines the gradient to use (between 0 and 1)
  88992. * @param factor defines the limit velocity value to affect to the specified gradient
  88993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88994. * @returns the current particle system
  88995. */
  88996. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88997. /**
  88998. * Remove a specific limit velocity gradient
  88999. * @param gradient defines the gradient to remove
  89000. * @returns the current particle system
  89001. */
  89002. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89003. /**
  89004. * Adds a new drag gradient
  89005. * @param gradient defines the gradient to use (between 0 and 1)
  89006. * @param factor defines the drag value to affect to the specified gradient
  89007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89008. * @returns the current particle system
  89009. */
  89010. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89011. /**
  89012. * Remove a specific drag gradient
  89013. * @param gradient defines the gradient to remove
  89014. * @returns the current particle system
  89015. */
  89016. removeDragGradient(gradient: number): IParticleSystem;
  89017. /**
  89018. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89019. * @param gradient defines the gradient to use (between 0 and 1)
  89020. * @param factor defines the emit rate value to affect to the specified gradient
  89021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89022. * @returns the current particle system
  89023. */
  89024. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89025. /**
  89026. * Remove a specific emit rate gradient
  89027. * @param gradient defines the gradient to remove
  89028. * @returns the current particle system
  89029. */
  89030. removeEmitRateGradient(gradient: number): IParticleSystem;
  89031. /**
  89032. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89033. * @param gradient defines the gradient to use (between 0 and 1)
  89034. * @param factor defines the start size value to affect to the specified gradient
  89035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89036. * @returns the current particle system
  89037. */
  89038. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89039. /**
  89040. * Remove a specific start size gradient
  89041. * @param gradient defines the gradient to remove
  89042. * @returns the current particle system
  89043. */
  89044. removeStartSizeGradient(gradient: number): IParticleSystem;
  89045. private _createRampGradientTexture;
  89046. /**
  89047. * Gets the current list of ramp gradients.
  89048. * You must use addRampGradient and removeRampGradient to udpate this list
  89049. * @returns the list of ramp gradients
  89050. */
  89051. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89052. /**
  89053. * Adds a new ramp gradient used to remap particle colors
  89054. * @param gradient defines the gradient to use (between 0 and 1)
  89055. * @param color defines the color to affect to the specified gradient
  89056. * @returns the current particle system
  89057. */
  89058. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  89059. /**
  89060. * Remove a specific ramp gradient
  89061. * @param gradient defines the gradient to remove
  89062. * @returns the current particle system
  89063. */
  89064. removeRampGradient(gradient: number): ParticleSystem;
  89065. /**
  89066. * Adds a new color gradient
  89067. * @param gradient defines the gradient to use (between 0 and 1)
  89068. * @param color1 defines the color to affect to the specified gradient
  89069. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89070. * @returns this particle system
  89071. */
  89072. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89073. /**
  89074. * Remove a specific color gradient
  89075. * @param gradient defines the gradient to remove
  89076. * @returns this particle system
  89077. */
  89078. removeColorGradient(gradient: number): IParticleSystem;
  89079. private _fetchR;
  89080. protected _reset(): void;
  89081. private _resetEffect;
  89082. private _createVertexBuffers;
  89083. private _createIndexBuffer;
  89084. /**
  89085. * Gets the maximum number of particles active at the same time.
  89086. * @returns The max number of active particles.
  89087. */
  89088. getCapacity(): number;
  89089. /**
  89090. * Gets whether there are still active particles in the system.
  89091. * @returns True if it is alive, otherwise false.
  89092. */
  89093. isAlive(): boolean;
  89094. /**
  89095. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89096. * @returns True if it has been started, otherwise false.
  89097. */
  89098. isStarted(): boolean;
  89099. private _prepareSubEmitterInternalArray;
  89100. /**
  89101. * Starts the particle system and begins to emit
  89102. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  89103. */
  89104. start(delay?: number): void;
  89105. /**
  89106. * Stops the particle system.
  89107. * @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.
  89108. */
  89109. stop(stopSubEmitters?: boolean): void;
  89110. /**
  89111. * Remove all active particles
  89112. */
  89113. reset(): void;
  89114. /**
  89115. * @hidden (for internal use only)
  89116. */
  89117. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  89118. /**
  89119. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  89120. * Its lifetime will start back at 0.
  89121. */
  89122. recycleParticle: (particle: Particle) => void;
  89123. private _stopSubEmitters;
  89124. private _createParticle;
  89125. private _removeFromRoot;
  89126. private _emitFromParticle;
  89127. private _update;
  89128. /** @hidden */
  89129. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  89130. /** @hidden */
  89131. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  89132. /** @hidden */
  89133. private _getEffect;
  89134. /**
  89135. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  89136. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  89137. */
  89138. animate(preWarmOnly?: boolean): void;
  89139. private _appendParticleVertices;
  89140. /**
  89141. * Rebuilds the particle system.
  89142. */
  89143. rebuild(): void;
  89144. /**
  89145. * Is this system ready to be used/rendered
  89146. * @return true if the system is ready
  89147. */
  89148. isReady(): boolean;
  89149. private _render;
  89150. /**
  89151. * Renders the particle system in its current state.
  89152. * @returns the current number of particles
  89153. */
  89154. render(): number;
  89155. /**
  89156. * Disposes the particle system and free the associated resources
  89157. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89158. */
  89159. dispose(disposeTexture?: boolean): void;
  89160. /**
  89161. * Clones the particle system.
  89162. * @param name The name of the cloned object
  89163. * @param newEmitter The new emitter to use
  89164. * @returns the cloned particle system
  89165. */
  89166. clone(name: string, newEmitter: any): ParticleSystem;
  89167. /**
  89168. * Serializes the particle system to a JSON object.
  89169. * @returns the JSON object
  89170. */
  89171. serialize(): any;
  89172. /** @hidden */
  89173. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  89174. /** @hidden */
  89175. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  89176. /**
  89177. * Parses a JSON object to create a particle system.
  89178. * @param parsedParticleSystem The JSON object to parse
  89179. * @param scene The scene to create the particle system in
  89180. * @param rootUrl The root url to use to load external dependencies like texture
  89181. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  89182. * @returns the Parsed particle system
  89183. */
  89184. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  89185. }
  89186. }
  89187. declare module BABYLON {
  89188. /**
  89189. * A particle represents one of the element emitted by a particle system.
  89190. * This is mainly define by its coordinates, direction, velocity and age.
  89191. */
  89192. export class Particle {
  89193. /**
  89194. * The particle system the particle belongs to.
  89195. */
  89196. particleSystem: ParticleSystem;
  89197. private static _Count;
  89198. /**
  89199. * Unique ID of the particle
  89200. */
  89201. id: number;
  89202. /**
  89203. * The world position of the particle in the scene.
  89204. */
  89205. position: Vector3;
  89206. /**
  89207. * The world direction of the particle in the scene.
  89208. */
  89209. direction: Vector3;
  89210. /**
  89211. * The color of the particle.
  89212. */
  89213. color: Color4;
  89214. /**
  89215. * The color change of the particle per step.
  89216. */
  89217. colorStep: Color4;
  89218. /**
  89219. * Defines how long will the life of the particle be.
  89220. */
  89221. lifeTime: number;
  89222. /**
  89223. * The current age of the particle.
  89224. */
  89225. age: number;
  89226. /**
  89227. * The current size of the particle.
  89228. */
  89229. size: number;
  89230. /**
  89231. * The current scale of the particle.
  89232. */
  89233. scale: Vector2;
  89234. /**
  89235. * The current angle of the particle.
  89236. */
  89237. angle: number;
  89238. /**
  89239. * Defines how fast is the angle changing.
  89240. */
  89241. angularSpeed: number;
  89242. /**
  89243. * Defines the cell index used by the particle to be rendered from a sprite.
  89244. */
  89245. cellIndex: number;
  89246. /**
  89247. * The information required to support color remapping
  89248. */
  89249. remapData: Vector4;
  89250. /** @hidden */
  89251. _randomCellOffset?: number;
  89252. /** @hidden */
  89253. _initialDirection: Nullable<Vector3>;
  89254. /** @hidden */
  89255. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  89256. /** @hidden */
  89257. _initialStartSpriteCellID: number;
  89258. /** @hidden */
  89259. _initialEndSpriteCellID: number;
  89260. /** @hidden */
  89261. _currentColorGradient: Nullable<ColorGradient>;
  89262. /** @hidden */
  89263. _currentColor1: Color4;
  89264. /** @hidden */
  89265. _currentColor2: Color4;
  89266. /** @hidden */
  89267. _currentSizeGradient: Nullable<FactorGradient>;
  89268. /** @hidden */
  89269. _currentSize1: number;
  89270. /** @hidden */
  89271. _currentSize2: number;
  89272. /** @hidden */
  89273. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  89274. /** @hidden */
  89275. _currentAngularSpeed1: number;
  89276. /** @hidden */
  89277. _currentAngularSpeed2: number;
  89278. /** @hidden */
  89279. _currentVelocityGradient: Nullable<FactorGradient>;
  89280. /** @hidden */
  89281. _currentVelocity1: number;
  89282. /** @hidden */
  89283. _currentVelocity2: number;
  89284. /** @hidden */
  89285. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  89286. /** @hidden */
  89287. _currentLimitVelocity1: number;
  89288. /** @hidden */
  89289. _currentLimitVelocity2: number;
  89290. /** @hidden */
  89291. _currentDragGradient: Nullable<FactorGradient>;
  89292. /** @hidden */
  89293. _currentDrag1: number;
  89294. /** @hidden */
  89295. _currentDrag2: number;
  89296. /** @hidden */
  89297. _randomNoiseCoordinates1: Vector3;
  89298. /** @hidden */
  89299. _randomNoiseCoordinates2: Vector3;
  89300. /**
  89301. * Creates a new instance Particle
  89302. * @param particleSystem the particle system the particle belongs to
  89303. */
  89304. constructor(
  89305. /**
  89306. * The particle system the particle belongs to.
  89307. */
  89308. particleSystem: ParticleSystem);
  89309. private updateCellInfoFromSystem;
  89310. /**
  89311. * Defines how the sprite cell index is updated for the particle
  89312. */
  89313. updateCellIndex(): void;
  89314. /** @hidden */
  89315. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  89316. /** @hidden */
  89317. _inheritParticleInfoToSubEmitters(): void;
  89318. /** @hidden */
  89319. _reset(): void;
  89320. /**
  89321. * Copy the properties of particle to another one.
  89322. * @param other the particle to copy the information to.
  89323. */
  89324. copyTo(other: Particle): void;
  89325. }
  89326. }
  89327. declare module BABYLON {
  89328. /**
  89329. * Particle emitter represents a volume emitting particles.
  89330. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  89331. */
  89332. export interface IParticleEmitterType {
  89333. /**
  89334. * Called by the particle System when the direction is computed for the created particle.
  89335. * @param worldMatrix is the world matrix of the particle system
  89336. * @param directionToUpdate is the direction vector to update with the result
  89337. * @param particle is the particle we are computed the direction for
  89338. */
  89339. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89340. /**
  89341. * Called by the particle System when the position is computed for the created particle.
  89342. * @param worldMatrix is the world matrix of the particle system
  89343. * @param positionToUpdate is the position vector to update with the result
  89344. * @param particle is the particle we are computed the position for
  89345. */
  89346. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89347. /**
  89348. * Clones the current emitter and returns a copy of it
  89349. * @returns the new emitter
  89350. */
  89351. clone(): IParticleEmitterType;
  89352. /**
  89353. * Called by the GPUParticleSystem to setup the update shader
  89354. * @param effect defines the update shader
  89355. */
  89356. applyToShader(effect: Effect): void;
  89357. /**
  89358. * Returns a string to use to update the GPU particles update shader
  89359. * @returns the effect defines string
  89360. */
  89361. getEffectDefines(): string;
  89362. /**
  89363. * Returns a string representing the class name
  89364. * @returns a string containing the class name
  89365. */
  89366. getClassName(): string;
  89367. /**
  89368. * Serializes the particle system to a JSON object.
  89369. * @returns the JSON object
  89370. */
  89371. serialize(): any;
  89372. /**
  89373. * Parse properties from a JSON object
  89374. * @param serializationObject defines the JSON object
  89375. */
  89376. parse(serializationObject: any): void;
  89377. }
  89378. }
  89379. declare module BABYLON {
  89380. /**
  89381. * Particle emitter emitting particles from the inside of a box.
  89382. * It emits the particles randomly between 2 given directions.
  89383. */
  89384. export class BoxParticleEmitter implements IParticleEmitterType {
  89385. /**
  89386. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89387. */
  89388. direction1: Vector3;
  89389. /**
  89390. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89391. */
  89392. direction2: Vector3;
  89393. /**
  89394. * 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.
  89395. */
  89396. minEmitBox: Vector3;
  89397. /**
  89398. * 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.
  89399. */
  89400. maxEmitBox: Vector3;
  89401. /**
  89402. * Creates a new instance BoxParticleEmitter
  89403. */
  89404. constructor();
  89405. /**
  89406. * Called by the particle System when the direction is computed for the created particle.
  89407. * @param worldMatrix is the world matrix of the particle system
  89408. * @param directionToUpdate is the direction vector to update with the result
  89409. * @param particle is the particle we are computed the direction for
  89410. */
  89411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89412. /**
  89413. * Called by the particle System when the position is computed for the created particle.
  89414. * @param worldMatrix is the world matrix of the particle system
  89415. * @param positionToUpdate is the position vector to update with the result
  89416. * @param particle is the particle we are computed the position for
  89417. */
  89418. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89419. /**
  89420. * Clones the current emitter and returns a copy of it
  89421. * @returns the new emitter
  89422. */
  89423. clone(): BoxParticleEmitter;
  89424. /**
  89425. * Called by the GPUParticleSystem to setup the update shader
  89426. * @param effect defines the update shader
  89427. */
  89428. applyToShader(effect: Effect): void;
  89429. /**
  89430. * Returns a string to use to update the GPU particles update shader
  89431. * @returns a string containng the defines string
  89432. */
  89433. getEffectDefines(): string;
  89434. /**
  89435. * Returns the string "BoxParticleEmitter"
  89436. * @returns a string containing the class name
  89437. */
  89438. getClassName(): string;
  89439. /**
  89440. * Serializes the particle system to a JSON object.
  89441. * @returns the JSON object
  89442. */
  89443. serialize(): any;
  89444. /**
  89445. * Parse properties from a JSON object
  89446. * @param serializationObject defines the JSON object
  89447. */
  89448. parse(serializationObject: any): void;
  89449. }
  89450. }
  89451. declare module BABYLON {
  89452. /**
  89453. * Particle emitter emitting particles from the inside of a cone.
  89454. * It emits the particles alongside the cone volume from the base to the particle.
  89455. * The emission direction might be randomized.
  89456. */
  89457. export class ConeParticleEmitter implements IParticleEmitterType {
  89458. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  89459. directionRandomizer: number;
  89460. private _radius;
  89461. private _angle;
  89462. private _height;
  89463. /**
  89464. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  89465. */
  89466. radiusRange: number;
  89467. /**
  89468. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  89469. */
  89470. heightRange: number;
  89471. /**
  89472. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  89473. */
  89474. emitFromSpawnPointOnly: boolean;
  89475. /**
  89476. * Gets or sets the radius of the emission cone
  89477. */
  89478. get radius(): number;
  89479. set radius(value: number);
  89480. /**
  89481. * Gets or sets the angle of the emission cone
  89482. */
  89483. get angle(): number;
  89484. set angle(value: number);
  89485. private _buildHeight;
  89486. /**
  89487. * Creates a new instance ConeParticleEmitter
  89488. * @param radius the radius of the emission cone (1 by default)
  89489. * @param angle the cone base angle (PI by default)
  89490. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  89491. */
  89492. constructor(radius?: number, angle?: number,
  89493. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  89494. directionRandomizer?: number);
  89495. /**
  89496. * Called by the particle System when the direction is computed for the created particle.
  89497. * @param worldMatrix is the world matrix of the particle system
  89498. * @param directionToUpdate is the direction vector to update with the result
  89499. * @param particle is the particle we are computed the direction for
  89500. */
  89501. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89502. /**
  89503. * Called by the particle System when the position is computed for the created particle.
  89504. * @param worldMatrix is the world matrix of the particle system
  89505. * @param positionToUpdate is the position vector to update with the result
  89506. * @param particle is the particle we are computed the position for
  89507. */
  89508. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89509. /**
  89510. * Clones the current emitter and returns a copy of it
  89511. * @returns the new emitter
  89512. */
  89513. clone(): ConeParticleEmitter;
  89514. /**
  89515. * Called by the GPUParticleSystem to setup the update shader
  89516. * @param effect defines the update shader
  89517. */
  89518. applyToShader(effect: Effect): void;
  89519. /**
  89520. * Returns a string to use to update the GPU particles update shader
  89521. * @returns a string containng the defines string
  89522. */
  89523. getEffectDefines(): string;
  89524. /**
  89525. * Returns the string "ConeParticleEmitter"
  89526. * @returns a string containing the class name
  89527. */
  89528. getClassName(): string;
  89529. /**
  89530. * Serializes the particle system to a JSON object.
  89531. * @returns the JSON object
  89532. */
  89533. serialize(): any;
  89534. /**
  89535. * Parse properties from a JSON object
  89536. * @param serializationObject defines the JSON object
  89537. */
  89538. parse(serializationObject: any): void;
  89539. }
  89540. }
  89541. declare module BABYLON {
  89542. /**
  89543. * Particle emitter emitting particles from the inside of a cylinder.
  89544. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  89545. */
  89546. export class CylinderParticleEmitter implements IParticleEmitterType {
  89547. /**
  89548. * The radius of the emission cylinder.
  89549. */
  89550. radius: number;
  89551. /**
  89552. * The height of the emission cylinder.
  89553. */
  89554. height: number;
  89555. /**
  89556. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89557. */
  89558. radiusRange: number;
  89559. /**
  89560. * How much to randomize the particle direction [0-1].
  89561. */
  89562. directionRandomizer: number;
  89563. /**
  89564. * Creates a new instance CylinderParticleEmitter
  89565. * @param radius the radius of the emission cylinder (1 by default)
  89566. * @param height the height of the emission cylinder (1 by default)
  89567. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89568. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89569. */
  89570. constructor(
  89571. /**
  89572. * The radius of the emission cylinder.
  89573. */
  89574. radius?: number,
  89575. /**
  89576. * The height of the emission cylinder.
  89577. */
  89578. height?: number,
  89579. /**
  89580. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89581. */
  89582. radiusRange?: number,
  89583. /**
  89584. * How much to randomize the particle direction [0-1].
  89585. */
  89586. directionRandomizer?: number);
  89587. /**
  89588. * Called by the particle System when the direction is computed for the created particle.
  89589. * @param worldMatrix is the world matrix of the particle system
  89590. * @param directionToUpdate is the direction vector to update with the result
  89591. * @param particle is the particle we are computed the direction for
  89592. */
  89593. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89594. /**
  89595. * Called by the particle System when the position is computed for the created particle.
  89596. * @param worldMatrix is the world matrix of the particle system
  89597. * @param positionToUpdate is the position vector to update with the result
  89598. * @param particle is the particle we are computed the position for
  89599. */
  89600. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89601. /**
  89602. * Clones the current emitter and returns a copy of it
  89603. * @returns the new emitter
  89604. */
  89605. clone(): CylinderParticleEmitter;
  89606. /**
  89607. * Called by the GPUParticleSystem to setup the update shader
  89608. * @param effect defines the update shader
  89609. */
  89610. applyToShader(effect: Effect): void;
  89611. /**
  89612. * Returns a string to use to update the GPU particles update shader
  89613. * @returns a string containng the defines string
  89614. */
  89615. getEffectDefines(): string;
  89616. /**
  89617. * Returns the string "CylinderParticleEmitter"
  89618. * @returns a string containing the class name
  89619. */
  89620. getClassName(): string;
  89621. /**
  89622. * Serializes the particle system to a JSON object.
  89623. * @returns the JSON object
  89624. */
  89625. serialize(): any;
  89626. /**
  89627. * Parse properties from a JSON object
  89628. * @param serializationObject defines the JSON object
  89629. */
  89630. parse(serializationObject: any): void;
  89631. }
  89632. /**
  89633. * Particle emitter emitting particles from the inside of a cylinder.
  89634. * It emits the particles randomly between two vectors.
  89635. */
  89636. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  89637. /**
  89638. * The min limit of the emission direction.
  89639. */
  89640. direction1: Vector3;
  89641. /**
  89642. * The max limit of the emission direction.
  89643. */
  89644. direction2: Vector3;
  89645. /**
  89646. * Creates a new instance CylinderDirectedParticleEmitter
  89647. * @param radius the radius of the emission cylinder (1 by default)
  89648. * @param height the height of the emission cylinder (1 by default)
  89649. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89650. * @param direction1 the min limit of the emission direction (up vector by default)
  89651. * @param direction2 the max limit of the emission direction (up vector by default)
  89652. */
  89653. constructor(radius?: number, height?: number, radiusRange?: number,
  89654. /**
  89655. * The min limit of the emission direction.
  89656. */
  89657. direction1?: Vector3,
  89658. /**
  89659. * The max limit of the emission direction.
  89660. */
  89661. direction2?: Vector3);
  89662. /**
  89663. * Called by the particle System when the direction is computed for the created particle.
  89664. * @param worldMatrix is the world matrix of the particle system
  89665. * @param directionToUpdate is the direction vector to update with the result
  89666. * @param particle is the particle we are computed the direction for
  89667. */
  89668. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89669. /**
  89670. * Clones the current emitter and returns a copy of it
  89671. * @returns the new emitter
  89672. */
  89673. clone(): CylinderDirectedParticleEmitter;
  89674. /**
  89675. * Called by the GPUParticleSystem to setup the update shader
  89676. * @param effect defines the update shader
  89677. */
  89678. applyToShader(effect: Effect): void;
  89679. /**
  89680. * Returns a string to use to update the GPU particles update shader
  89681. * @returns a string containng the defines string
  89682. */
  89683. getEffectDefines(): string;
  89684. /**
  89685. * Returns the string "CylinderDirectedParticleEmitter"
  89686. * @returns a string containing the class name
  89687. */
  89688. getClassName(): string;
  89689. /**
  89690. * Serializes the particle system to a JSON object.
  89691. * @returns the JSON object
  89692. */
  89693. serialize(): any;
  89694. /**
  89695. * Parse properties from a JSON object
  89696. * @param serializationObject defines the JSON object
  89697. */
  89698. parse(serializationObject: any): void;
  89699. }
  89700. }
  89701. declare module BABYLON {
  89702. /**
  89703. * Particle emitter emitting particles from the inside of a hemisphere.
  89704. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  89705. */
  89706. export class HemisphericParticleEmitter implements IParticleEmitterType {
  89707. /**
  89708. * The radius of the emission hemisphere.
  89709. */
  89710. radius: number;
  89711. /**
  89712. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89713. */
  89714. radiusRange: number;
  89715. /**
  89716. * How much to randomize the particle direction [0-1].
  89717. */
  89718. directionRandomizer: number;
  89719. /**
  89720. * Creates a new instance HemisphericParticleEmitter
  89721. * @param radius the radius of the emission hemisphere (1 by default)
  89722. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89723. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89724. */
  89725. constructor(
  89726. /**
  89727. * The radius of the emission hemisphere.
  89728. */
  89729. radius?: number,
  89730. /**
  89731. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89732. */
  89733. radiusRange?: number,
  89734. /**
  89735. * How much to randomize the particle direction [0-1].
  89736. */
  89737. directionRandomizer?: number);
  89738. /**
  89739. * Called by the particle System when the direction is computed for the created particle.
  89740. * @param worldMatrix is the world matrix of the particle system
  89741. * @param directionToUpdate is the direction vector to update with the result
  89742. * @param particle is the particle we are computed the direction for
  89743. */
  89744. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89745. /**
  89746. * Called by the particle System when the position is computed for the created particle.
  89747. * @param worldMatrix is the world matrix of the particle system
  89748. * @param positionToUpdate is the position vector to update with the result
  89749. * @param particle is the particle we are computed the position for
  89750. */
  89751. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89752. /**
  89753. * Clones the current emitter and returns a copy of it
  89754. * @returns the new emitter
  89755. */
  89756. clone(): HemisphericParticleEmitter;
  89757. /**
  89758. * Called by the GPUParticleSystem to setup the update shader
  89759. * @param effect defines the update shader
  89760. */
  89761. applyToShader(effect: Effect): void;
  89762. /**
  89763. * Returns a string to use to update the GPU particles update shader
  89764. * @returns a string containng the defines string
  89765. */
  89766. getEffectDefines(): string;
  89767. /**
  89768. * Returns the string "HemisphericParticleEmitter"
  89769. * @returns a string containing the class name
  89770. */
  89771. getClassName(): string;
  89772. /**
  89773. * Serializes the particle system to a JSON object.
  89774. * @returns the JSON object
  89775. */
  89776. serialize(): any;
  89777. /**
  89778. * Parse properties from a JSON object
  89779. * @param serializationObject defines the JSON object
  89780. */
  89781. parse(serializationObject: any): void;
  89782. }
  89783. }
  89784. declare module BABYLON {
  89785. /**
  89786. * Particle emitter emitting particles from a point.
  89787. * It emits the particles randomly between 2 given directions.
  89788. */
  89789. export class PointParticleEmitter implements IParticleEmitterType {
  89790. /**
  89791. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89792. */
  89793. direction1: Vector3;
  89794. /**
  89795. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89796. */
  89797. direction2: Vector3;
  89798. /**
  89799. * Creates a new instance PointParticleEmitter
  89800. */
  89801. constructor();
  89802. /**
  89803. * Called by the particle System when the direction is computed for the created particle.
  89804. * @param worldMatrix is the world matrix of the particle system
  89805. * @param directionToUpdate is the direction vector to update with the result
  89806. * @param particle is the particle we are computed the direction for
  89807. */
  89808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89809. /**
  89810. * Called by the particle System when the position is computed for the created particle.
  89811. * @param worldMatrix is the world matrix of the particle system
  89812. * @param positionToUpdate is the position vector to update with the result
  89813. * @param particle is the particle we are computed the position for
  89814. */
  89815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89816. /**
  89817. * Clones the current emitter and returns a copy of it
  89818. * @returns the new emitter
  89819. */
  89820. clone(): PointParticleEmitter;
  89821. /**
  89822. * Called by the GPUParticleSystem to setup the update shader
  89823. * @param effect defines the update shader
  89824. */
  89825. applyToShader(effect: Effect): void;
  89826. /**
  89827. * Returns a string to use to update the GPU particles update shader
  89828. * @returns a string containng the defines string
  89829. */
  89830. getEffectDefines(): string;
  89831. /**
  89832. * Returns the string "PointParticleEmitter"
  89833. * @returns a string containing the class name
  89834. */
  89835. getClassName(): string;
  89836. /**
  89837. * Serializes the particle system to a JSON object.
  89838. * @returns the JSON object
  89839. */
  89840. serialize(): any;
  89841. /**
  89842. * Parse properties from a JSON object
  89843. * @param serializationObject defines the JSON object
  89844. */
  89845. parse(serializationObject: any): void;
  89846. }
  89847. }
  89848. declare module BABYLON {
  89849. /**
  89850. * Particle emitter emitting particles from the inside of a sphere.
  89851. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  89852. */
  89853. export class SphereParticleEmitter implements IParticleEmitterType {
  89854. /**
  89855. * The radius of the emission sphere.
  89856. */
  89857. radius: number;
  89858. /**
  89859. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89860. */
  89861. radiusRange: number;
  89862. /**
  89863. * How much to randomize the particle direction [0-1].
  89864. */
  89865. directionRandomizer: number;
  89866. /**
  89867. * Creates a new instance SphereParticleEmitter
  89868. * @param radius the radius of the emission sphere (1 by default)
  89869. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89870. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89871. */
  89872. constructor(
  89873. /**
  89874. * The radius of the emission sphere.
  89875. */
  89876. radius?: number,
  89877. /**
  89878. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89879. */
  89880. radiusRange?: number,
  89881. /**
  89882. * How much to randomize the particle direction [0-1].
  89883. */
  89884. directionRandomizer?: number);
  89885. /**
  89886. * Called by the particle System when the direction is computed for the created particle.
  89887. * @param worldMatrix is the world matrix of the particle system
  89888. * @param directionToUpdate is the direction vector to update with the result
  89889. * @param particle is the particle we are computed the direction for
  89890. */
  89891. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89892. /**
  89893. * Called by the particle System when the position is computed for the created particle.
  89894. * @param worldMatrix is the world matrix of the particle system
  89895. * @param positionToUpdate is the position vector to update with the result
  89896. * @param particle is the particle we are computed the position for
  89897. */
  89898. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89899. /**
  89900. * Clones the current emitter and returns a copy of it
  89901. * @returns the new emitter
  89902. */
  89903. clone(): SphereParticleEmitter;
  89904. /**
  89905. * Called by the GPUParticleSystem to setup the update shader
  89906. * @param effect defines the update shader
  89907. */
  89908. applyToShader(effect: Effect): void;
  89909. /**
  89910. * Returns a string to use to update the GPU particles update shader
  89911. * @returns a string containng the defines string
  89912. */
  89913. getEffectDefines(): string;
  89914. /**
  89915. * Returns the string "SphereParticleEmitter"
  89916. * @returns a string containing the class name
  89917. */
  89918. getClassName(): string;
  89919. /**
  89920. * Serializes the particle system to a JSON object.
  89921. * @returns the JSON object
  89922. */
  89923. serialize(): any;
  89924. /**
  89925. * Parse properties from a JSON object
  89926. * @param serializationObject defines the JSON object
  89927. */
  89928. parse(serializationObject: any): void;
  89929. }
  89930. /**
  89931. * Particle emitter emitting particles from the inside of a sphere.
  89932. * It emits the particles randomly between two vectors.
  89933. */
  89934. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  89935. /**
  89936. * The min limit of the emission direction.
  89937. */
  89938. direction1: Vector3;
  89939. /**
  89940. * The max limit of the emission direction.
  89941. */
  89942. direction2: Vector3;
  89943. /**
  89944. * Creates a new instance SphereDirectedParticleEmitter
  89945. * @param radius the radius of the emission sphere (1 by default)
  89946. * @param direction1 the min limit of the emission direction (up vector by default)
  89947. * @param direction2 the max limit of the emission direction (up vector by default)
  89948. */
  89949. constructor(radius?: number,
  89950. /**
  89951. * The min limit of the emission direction.
  89952. */
  89953. direction1?: Vector3,
  89954. /**
  89955. * The max limit of the emission direction.
  89956. */
  89957. direction2?: Vector3);
  89958. /**
  89959. * Called by the particle System when the direction is computed for the created particle.
  89960. * @param worldMatrix is the world matrix of the particle system
  89961. * @param directionToUpdate is the direction vector to update with the result
  89962. * @param particle is the particle we are computed the direction for
  89963. */
  89964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89965. /**
  89966. * Clones the current emitter and returns a copy of it
  89967. * @returns the new emitter
  89968. */
  89969. clone(): SphereDirectedParticleEmitter;
  89970. /**
  89971. * Called by the GPUParticleSystem to setup the update shader
  89972. * @param effect defines the update shader
  89973. */
  89974. applyToShader(effect: Effect): void;
  89975. /**
  89976. * Returns a string to use to update the GPU particles update shader
  89977. * @returns a string containng the defines string
  89978. */
  89979. getEffectDefines(): string;
  89980. /**
  89981. * Returns the string "SphereDirectedParticleEmitter"
  89982. * @returns a string containing the class name
  89983. */
  89984. getClassName(): string;
  89985. /**
  89986. * Serializes the particle system to a JSON object.
  89987. * @returns the JSON object
  89988. */
  89989. serialize(): any;
  89990. /**
  89991. * Parse properties from a JSON object
  89992. * @param serializationObject defines the JSON object
  89993. */
  89994. parse(serializationObject: any): void;
  89995. }
  89996. }
  89997. declare module BABYLON {
  89998. /**
  89999. * Interface representing a particle system in Babylon.js.
  90000. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  90001. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  90002. */
  90003. export interface IParticleSystem {
  90004. /**
  90005. * List of animations used by the particle system.
  90006. */
  90007. animations: Animation[];
  90008. /**
  90009. * The id of the Particle system.
  90010. */
  90011. id: string;
  90012. /**
  90013. * The name of the Particle system.
  90014. */
  90015. name: string;
  90016. /**
  90017. * The emitter represents the Mesh or position we are attaching the particle system to.
  90018. */
  90019. emitter: Nullable<AbstractMesh | Vector3>;
  90020. /**
  90021. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90022. */
  90023. isBillboardBased: boolean;
  90024. /**
  90025. * The rendering group used by the Particle system to chose when to render.
  90026. */
  90027. renderingGroupId: number;
  90028. /**
  90029. * The layer mask we are rendering the particles through.
  90030. */
  90031. layerMask: number;
  90032. /**
  90033. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90034. */
  90035. updateSpeed: number;
  90036. /**
  90037. * The amount of time the particle system is running (depends of the overall update speed).
  90038. */
  90039. targetStopDuration: number;
  90040. /**
  90041. * The texture used to render each particle. (this can be a spritesheet)
  90042. */
  90043. particleTexture: Nullable<Texture>;
  90044. /**
  90045. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  90046. */
  90047. blendMode: number;
  90048. /**
  90049. * Minimum life time of emitting particles.
  90050. */
  90051. minLifeTime: number;
  90052. /**
  90053. * Maximum life time of emitting particles.
  90054. */
  90055. maxLifeTime: number;
  90056. /**
  90057. * Minimum Size of emitting particles.
  90058. */
  90059. minSize: number;
  90060. /**
  90061. * Maximum Size of emitting particles.
  90062. */
  90063. maxSize: number;
  90064. /**
  90065. * Minimum scale of emitting particles on X axis.
  90066. */
  90067. minScaleX: number;
  90068. /**
  90069. * Maximum scale of emitting particles on X axis.
  90070. */
  90071. maxScaleX: number;
  90072. /**
  90073. * Minimum scale of emitting particles on Y axis.
  90074. */
  90075. minScaleY: number;
  90076. /**
  90077. * Maximum scale of emitting particles on Y axis.
  90078. */
  90079. maxScaleY: number;
  90080. /**
  90081. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  90082. */
  90083. color1: Color4;
  90084. /**
  90085. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  90086. */
  90087. color2: Color4;
  90088. /**
  90089. * Color the particle will have at the end of its lifetime.
  90090. */
  90091. colorDead: Color4;
  90092. /**
  90093. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  90094. */
  90095. emitRate: number;
  90096. /**
  90097. * You can use gravity if you want to give an orientation to your particles.
  90098. */
  90099. gravity: Vector3;
  90100. /**
  90101. * Minimum power of emitting particles.
  90102. */
  90103. minEmitPower: number;
  90104. /**
  90105. * Maximum power of emitting particles.
  90106. */
  90107. maxEmitPower: number;
  90108. /**
  90109. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90110. */
  90111. minAngularSpeed: number;
  90112. /**
  90113. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90114. */
  90115. maxAngularSpeed: number;
  90116. /**
  90117. * Gets or sets the minimal initial rotation in radians.
  90118. */
  90119. minInitialRotation: number;
  90120. /**
  90121. * Gets or sets the maximal initial rotation in radians.
  90122. */
  90123. maxInitialRotation: number;
  90124. /**
  90125. * The particle emitter type defines the emitter used by the particle system.
  90126. * It can be for example box, sphere, or cone...
  90127. */
  90128. particleEmitterType: Nullable<IParticleEmitterType>;
  90129. /**
  90130. * Defines the delay in milliseconds before starting the system (0 by default)
  90131. */
  90132. startDelay: number;
  90133. /**
  90134. * 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
  90135. */
  90136. preWarmCycles: number;
  90137. /**
  90138. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  90139. */
  90140. preWarmStepOffset: number;
  90141. /**
  90142. * 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)
  90143. */
  90144. spriteCellChangeSpeed: number;
  90145. /**
  90146. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90147. */
  90148. startSpriteCellID: number;
  90149. /**
  90150. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90151. */
  90152. endSpriteCellID: number;
  90153. /**
  90154. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90155. */
  90156. spriteCellWidth: number;
  90157. /**
  90158. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90159. */
  90160. spriteCellHeight: number;
  90161. /**
  90162. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90163. */
  90164. spriteRandomStartCell: boolean;
  90165. /**
  90166. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  90167. */
  90168. isAnimationSheetEnabled: boolean;
  90169. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90170. translationPivot: Vector2;
  90171. /**
  90172. * Gets or sets a texture used to add random noise to particle positions
  90173. */
  90174. noiseTexture: Nullable<BaseTexture>;
  90175. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90176. noiseStrength: Vector3;
  90177. /**
  90178. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90179. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90180. */
  90181. billboardMode: number;
  90182. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90183. limitVelocityDamping: number;
  90184. /**
  90185. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90186. */
  90187. beginAnimationOnStart: boolean;
  90188. /**
  90189. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90190. */
  90191. beginAnimationFrom: number;
  90192. /**
  90193. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90194. */
  90195. beginAnimationTo: number;
  90196. /**
  90197. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90198. */
  90199. beginAnimationLoop: boolean;
  90200. /**
  90201. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90202. */
  90203. disposeOnStop: boolean;
  90204. /**
  90205. * Gets the maximum number of particles active at the same time.
  90206. * @returns The max number of active particles.
  90207. */
  90208. getCapacity(): number;
  90209. /**
  90210. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90211. * @returns True if it has been started, otherwise false.
  90212. */
  90213. isStarted(): boolean;
  90214. /**
  90215. * Animates the particle system for this frame.
  90216. */
  90217. animate(): void;
  90218. /**
  90219. * Renders the particle system in its current state.
  90220. * @returns the current number of particles
  90221. */
  90222. render(): number;
  90223. /**
  90224. * Dispose the particle system and frees its associated resources.
  90225. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90226. */
  90227. dispose(disposeTexture?: boolean): void;
  90228. /**
  90229. * Clones the particle system.
  90230. * @param name The name of the cloned object
  90231. * @param newEmitter The new emitter to use
  90232. * @returns the cloned particle system
  90233. */
  90234. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  90235. /**
  90236. * Serializes the particle system to a JSON object.
  90237. * @returns the JSON object
  90238. */
  90239. serialize(): any;
  90240. /**
  90241. * Rebuild the particle system
  90242. */
  90243. rebuild(): void;
  90244. /**
  90245. * Starts the particle system and begins to emit
  90246. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  90247. */
  90248. start(delay?: number): void;
  90249. /**
  90250. * Stops the particle system.
  90251. */
  90252. stop(): void;
  90253. /**
  90254. * Remove all active particles
  90255. */
  90256. reset(): void;
  90257. /**
  90258. * Is this system ready to be used/rendered
  90259. * @return true if the system is ready
  90260. */
  90261. isReady(): boolean;
  90262. /**
  90263. * Adds a new color gradient
  90264. * @param gradient defines the gradient to use (between 0 and 1)
  90265. * @param color1 defines the color to affect to the specified gradient
  90266. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90267. * @returns the current particle system
  90268. */
  90269. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90270. /**
  90271. * Remove a specific color gradient
  90272. * @param gradient defines the gradient to remove
  90273. * @returns the current particle system
  90274. */
  90275. removeColorGradient(gradient: number): IParticleSystem;
  90276. /**
  90277. * Adds a new size gradient
  90278. * @param gradient defines the gradient to use (between 0 and 1)
  90279. * @param factor defines the size factor to affect to the specified gradient
  90280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90281. * @returns the current particle system
  90282. */
  90283. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90284. /**
  90285. * Remove a specific size gradient
  90286. * @param gradient defines the gradient to remove
  90287. * @returns the current particle system
  90288. */
  90289. removeSizeGradient(gradient: number): IParticleSystem;
  90290. /**
  90291. * Gets the current list of color gradients.
  90292. * You must use addColorGradient and removeColorGradient to udpate this list
  90293. * @returns the list of color gradients
  90294. */
  90295. getColorGradients(): Nullable<Array<ColorGradient>>;
  90296. /**
  90297. * Gets the current list of size gradients.
  90298. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90299. * @returns the list of size gradients
  90300. */
  90301. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90302. /**
  90303. * Gets the current list of angular speed gradients.
  90304. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90305. * @returns the list of angular speed gradients
  90306. */
  90307. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90308. /**
  90309. * Adds a new angular speed gradient
  90310. * @param gradient defines the gradient to use (between 0 and 1)
  90311. * @param factor defines the angular speed to affect to the specified gradient
  90312. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90313. * @returns the current particle system
  90314. */
  90315. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90316. /**
  90317. * Remove a specific angular speed gradient
  90318. * @param gradient defines the gradient to remove
  90319. * @returns the current particle system
  90320. */
  90321. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90322. /**
  90323. * Gets the current list of velocity gradients.
  90324. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90325. * @returns the list of velocity gradients
  90326. */
  90327. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90328. /**
  90329. * Adds a new velocity gradient
  90330. * @param gradient defines the gradient to use (between 0 and 1)
  90331. * @param factor defines the velocity to affect to the specified gradient
  90332. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90333. * @returns the current particle system
  90334. */
  90335. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90336. /**
  90337. * Remove a specific velocity gradient
  90338. * @param gradient defines the gradient to remove
  90339. * @returns the current particle system
  90340. */
  90341. removeVelocityGradient(gradient: number): IParticleSystem;
  90342. /**
  90343. * Gets the current list of limit velocity gradients.
  90344. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90345. * @returns the list of limit velocity gradients
  90346. */
  90347. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90348. /**
  90349. * Adds a new limit velocity gradient
  90350. * @param gradient defines the gradient to use (between 0 and 1)
  90351. * @param factor defines the limit velocity to affect to the specified gradient
  90352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90353. * @returns the current particle system
  90354. */
  90355. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90356. /**
  90357. * Remove a specific limit velocity gradient
  90358. * @param gradient defines the gradient to remove
  90359. * @returns the current particle system
  90360. */
  90361. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90362. /**
  90363. * Adds a new drag gradient
  90364. * @param gradient defines the gradient to use (between 0 and 1)
  90365. * @param factor defines the drag to affect to the specified gradient
  90366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90367. * @returns the current particle system
  90368. */
  90369. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90370. /**
  90371. * Remove a specific drag gradient
  90372. * @param gradient defines the gradient to remove
  90373. * @returns the current particle system
  90374. */
  90375. removeDragGradient(gradient: number): IParticleSystem;
  90376. /**
  90377. * Gets the current list of drag gradients.
  90378. * You must use addDragGradient and removeDragGradient to udpate this list
  90379. * @returns the list of drag gradients
  90380. */
  90381. getDragGradients(): Nullable<Array<FactorGradient>>;
  90382. /**
  90383. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90384. * @param gradient defines the gradient to use (between 0 and 1)
  90385. * @param factor defines the emit rate to affect to the specified gradient
  90386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90387. * @returns the current particle system
  90388. */
  90389. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90390. /**
  90391. * Remove a specific emit rate gradient
  90392. * @param gradient defines the gradient to remove
  90393. * @returns the current particle system
  90394. */
  90395. removeEmitRateGradient(gradient: number): IParticleSystem;
  90396. /**
  90397. * Gets the current list of emit rate gradients.
  90398. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90399. * @returns the list of emit rate gradients
  90400. */
  90401. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90402. /**
  90403. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90404. * @param gradient defines the gradient to use (between 0 and 1)
  90405. * @param factor defines the start size to affect to the specified gradient
  90406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90407. * @returns the current particle system
  90408. */
  90409. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90410. /**
  90411. * Remove a specific start size gradient
  90412. * @param gradient defines the gradient to remove
  90413. * @returns the current particle system
  90414. */
  90415. removeStartSizeGradient(gradient: number): IParticleSystem;
  90416. /**
  90417. * Gets the current list of start size gradients.
  90418. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90419. * @returns the list of start size gradients
  90420. */
  90421. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90422. /**
  90423. * Adds a new life time gradient
  90424. * @param gradient defines the gradient to use (between 0 and 1)
  90425. * @param factor defines the life time factor to affect to the specified gradient
  90426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90427. * @returns the current particle system
  90428. */
  90429. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90430. /**
  90431. * Remove a specific life time gradient
  90432. * @param gradient defines the gradient to remove
  90433. * @returns the current particle system
  90434. */
  90435. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90436. /**
  90437. * Gets the current list of life time gradients.
  90438. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90439. * @returns the list of life time gradients
  90440. */
  90441. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90442. /**
  90443. * Gets the current list of color gradients.
  90444. * You must use addColorGradient and removeColorGradient to udpate this list
  90445. * @returns the list of color gradients
  90446. */
  90447. getColorGradients(): Nullable<Array<ColorGradient>>;
  90448. /**
  90449. * Adds a new ramp gradient used to remap particle colors
  90450. * @param gradient defines the gradient to use (between 0 and 1)
  90451. * @param color defines the color to affect to the specified gradient
  90452. * @returns the current particle system
  90453. */
  90454. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  90455. /**
  90456. * Gets the current list of ramp gradients.
  90457. * You must use addRampGradient and removeRampGradient to udpate this list
  90458. * @returns the list of ramp gradients
  90459. */
  90460. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90461. /** Gets or sets a boolean indicating that ramp gradients must be used
  90462. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90463. */
  90464. useRampGradients: boolean;
  90465. /**
  90466. * Adds a new color remap gradient
  90467. * @param gradient defines the gradient to use (between 0 and 1)
  90468. * @param min defines the color remap minimal range
  90469. * @param max defines the color remap maximal range
  90470. * @returns the current particle system
  90471. */
  90472. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90473. /**
  90474. * Gets the current list of color remap gradients.
  90475. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90476. * @returns the list of color remap gradients
  90477. */
  90478. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90479. /**
  90480. * Adds a new alpha remap gradient
  90481. * @param gradient defines the gradient to use (between 0 and 1)
  90482. * @param min defines the alpha remap minimal range
  90483. * @param max defines the alpha remap maximal range
  90484. * @returns the current particle system
  90485. */
  90486. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90487. /**
  90488. * Gets the current list of alpha remap gradients.
  90489. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90490. * @returns the list of alpha remap gradients
  90491. */
  90492. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90493. /**
  90494. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90495. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90496. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90497. * @returns the emitter
  90498. */
  90499. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90500. /**
  90501. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90502. * @param radius The radius of the hemisphere to emit from
  90503. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90504. * @returns the emitter
  90505. */
  90506. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  90507. /**
  90508. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90509. * @param radius The radius of the sphere to emit from
  90510. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90511. * @returns the emitter
  90512. */
  90513. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  90514. /**
  90515. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90516. * @param radius The radius of the sphere to emit from
  90517. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90518. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90519. * @returns the emitter
  90520. */
  90521. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  90522. /**
  90523. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90524. * @param radius The radius of the emission cylinder
  90525. * @param height The height of the emission cylinder
  90526. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90527. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90528. * @returns the emitter
  90529. */
  90530. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  90531. /**
  90532. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90533. * @param radius The radius of the cylinder to emit from
  90534. * @param height The height of the emission cylinder
  90535. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90536. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90537. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90538. * @returns the emitter
  90539. */
  90540. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  90541. /**
  90542. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90543. * @param radius The radius of the cone to emit from
  90544. * @param angle The base angle of the cone
  90545. * @returns the emitter
  90546. */
  90547. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  90548. /**
  90549. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90550. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90551. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90552. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90553. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90554. * @returns the emitter
  90555. */
  90556. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90557. /**
  90558. * Get hosting scene
  90559. * @returns the scene
  90560. */
  90561. getScene(): Scene;
  90562. }
  90563. }
  90564. declare module BABYLON {
  90565. /**
  90566. * Creates an instance based on a source mesh.
  90567. */
  90568. export class InstancedMesh extends AbstractMesh {
  90569. private _sourceMesh;
  90570. private _currentLOD;
  90571. /** @hidden */
  90572. _indexInSourceMeshInstanceArray: number;
  90573. constructor(name: string, source: Mesh);
  90574. /**
  90575. * Returns the string "InstancedMesh".
  90576. */
  90577. getClassName(): string;
  90578. /** Gets the list of lights affecting that mesh */
  90579. get lightSources(): Light[];
  90580. _resyncLightSources(): void;
  90581. _resyncLightSource(light: Light): void;
  90582. _removeLightSource(light: Light, dispose: boolean): void;
  90583. /**
  90584. * If the source mesh receives shadows
  90585. */
  90586. get receiveShadows(): boolean;
  90587. /**
  90588. * The material of the source mesh
  90589. */
  90590. get material(): Nullable<Material>;
  90591. /**
  90592. * Visibility of the source mesh
  90593. */
  90594. get visibility(): number;
  90595. /**
  90596. * Skeleton of the source mesh
  90597. */
  90598. get skeleton(): Nullable<Skeleton>;
  90599. /**
  90600. * Rendering ground id of the source mesh
  90601. */
  90602. get renderingGroupId(): number;
  90603. set renderingGroupId(value: number);
  90604. /**
  90605. * Returns the total number of vertices (integer).
  90606. */
  90607. getTotalVertices(): number;
  90608. /**
  90609. * Returns a positive integer : the total number of indices in this mesh geometry.
  90610. * @returns the numner of indices or zero if the mesh has no geometry.
  90611. */
  90612. getTotalIndices(): number;
  90613. /**
  90614. * The source mesh of the instance
  90615. */
  90616. get sourceMesh(): Mesh;
  90617. /**
  90618. * Is this node ready to be used/rendered
  90619. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90620. * @return {boolean} is it ready
  90621. */
  90622. isReady(completeCheck?: boolean): boolean;
  90623. /**
  90624. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90625. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  90626. * @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.
  90627. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  90628. */
  90629. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  90630. /**
  90631. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90632. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90633. * The `data` are either a numeric array either a Float32Array.
  90634. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  90635. * 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).
  90636. * Note that a new underlying VertexBuffer object is created each call.
  90637. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  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. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90656. /**
  90657. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90658. * If the mesh has no geometry, it is simply returned as it is.
  90659. * The `data` are either a numeric array either a Float32Array.
  90660. * No new underlying VertexBuffer object is created.
  90661. * 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.
  90662. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  90663. *
  90664. * Possible `kind` values :
  90665. * - VertexBuffer.PositionKind
  90666. * - VertexBuffer.UVKind
  90667. * - VertexBuffer.UV2Kind
  90668. * - VertexBuffer.UV3Kind
  90669. * - VertexBuffer.UV4Kind
  90670. * - VertexBuffer.UV5Kind
  90671. * - VertexBuffer.UV6Kind
  90672. * - VertexBuffer.ColorKind
  90673. * - VertexBuffer.MatricesIndicesKind
  90674. * - VertexBuffer.MatricesIndicesExtraKind
  90675. * - VertexBuffer.MatricesWeightsKind
  90676. * - VertexBuffer.MatricesWeightsExtraKind
  90677. *
  90678. * Returns the Mesh.
  90679. */
  90680. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  90681. /**
  90682. * Sets the mesh indices.
  90683. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  90684. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  90685. * This method creates a new index buffer each call.
  90686. * Returns the Mesh.
  90687. */
  90688. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  90689. /**
  90690. * Boolean : True if the mesh owns the requested kind of data.
  90691. */
  90692. isVerticesDataPresent(kind: string): boolean;
  90693. /**
  90694. * Returns an array of indices (IndicesArray).
  90695. */
  90696. getIndices(): Nullable<IndicesArray>;
  90697. get _positions(): Nullable<Vector3[]>;
  90698. /**
  90699. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90700. * This means the mesh underlying bounding box and sphere are recomputed.
  90701. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90702. * @returns the current mesh
  90703. */
  90704. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  90705. /** @hidden */
  90706. _preActivate(): InstancedMesh;
  90707. /** @hidden */
  90708. _activate(renderId: number, intermediateRendering: boolean): boolean;
  90709. /** @hidden */
  90710. _postActivate(): void;
  90711. getWorldMatrix(): Matrix;
  90712. get isAnInstance(): boolean;
  90713. /**
  90714. * Returns the current associated LOD AbstractMesh.
  90715. */
  90716. getLOD(camera: Camera): AbstractMesh;
  90717. /** @hidden */
  90718. _syncSubMeshes(): InstancedMesh;
  90719. /** @hidden */
  90720. _generatePointsArray(): boolean;
  90721. /**
  90722. * Creates a new InstancedMesh from the current mesh.
  90723. * - name (string) : the cloned mesh name
  90724. * - newParent (optional Node) : the optional Node to parent the clone to.
  90725. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  90726. *
  90727. * Returns the clone.
  90728. */
  90729. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90730. /**
  90731. * Disposes the InstancedMesh.
  90732. * Returns nothing.
  90733. */
  90734. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90735. }
  90736. interface Mesh {
  90737. /**
  90738. * Register a custom buffer that will be instanced
  90739. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  90740. * @param kind defines the buffer kind
  90741. * @param stride defines the stride in floats
  90742. */
  90743. registerInstancedBuffer(kind: string, stride: number): void;
  90744. /** @hidden */
  90745. _userInstancedBuffersStorage: {
  90746. data: {
  90747. [key: string]: Float32Array;
  90748. };
  90749. sizes: {
  90750. [key: string]: number;
  90751. };
  90752. vertexBuffers: {
  90753. [key: string]: Nullable<VertexBuffer>;
  90754. };
  90755. strides: {
  90756. [key: string]: number;
  90757. };
  90758. };
  90759. }
  90760. interface AbstractMesh {
  90761. /**
  90762. * Object used to store instanced buffers defined by user
  90763. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  90764. */
  90765. instancedBuffers: {
  90766. [key: string]: any;
  90767. };
  90768. }
  90769. }
  90770. declare module BABYLON {
  90771. /**
  90772. * Defines the options associated with the creation of a shader material.
  90773. */
  90774. export interface IShaderMaterialOptions {
  90775. /**
  90776. * Does the material work in alpha blend mode
  90777. */
  90778. needAlphaBlending: boolean;
  90779. /**
  90780. * Does the material work in alpha test mode
  90781. */
  90782. needAlphaTesting: boolean;
  90783. /**
  90784. * The list of attribute names used in the shader
  90785. */
  90786. attributes: string[];
  90787. /**
  90788. * The list of unifrom names used in the shader
  90789. */
  90790. uniforms: string[];
  90791. /**
  90792. * The list of UBO names used in the shader
  90793. */
  90794. uniformBuffers: string[];
  90795. /**
  90796. * The list of sampler names used in the shader
  90797. */
  90798. samplers: string[];
  90799. /**
  90800. * The list of defines used in the shader
  90801. */
  90802. defines: string[];
  90803. }
  90804. /**
  90805. * 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.
  90806. *
  90807. * This returned material effects how the mesh will look based on the code in the shaders.
  90808. *
  90809. * @see http://doc.babylonjs.com/how_to/shader_material
  90810. */
  90811. export class ShaderMaterial extends Material {
  90812. private _shaderPath;
  90813. private _options;
  90814. private _textures;
  90815. private _textureArrays;
  90816. private _floats;
  90817. private _ints;
  90818. private _floatsArrays;
  90819. private _colors3;
  90820. private _colors3Arrays;
  90821. private _colors4;
  90822. private _colors4Arrays;
  90823. private _vectors2;
  90824. private _vectors3;
  90825. private _vectors4;
  90826. private _matrices;
  90827. private _matrixArrays;
  90828. private _matrices3x3;
  90829. private _matrices2x2;
  90830. private _vectors2Arrays;
  90831. private _vectors3Arrays;
  90832. private _vectors4Arrays;
  90833. private _cachedWorldViewMatrix;
  90834. private _cachedWorldViewProjectionMatrix;
  90835. private _renderId;
  90836. private _multiview;
  90837. /**
  90838. * Instantiate a new shader material.
  90839. * 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.
  90840. * This returned material effects how the mesh will look based on the code in the shaders.
  90841. * @see http://doc.babylonjs.com/how_to/shader_material
  90842. * @param name Define the name of the material in the scene
  90843. * @param scene Define the scene the material belongs to
  90844. * @param shaderPath Defines the route to the shader code in one of three ways:
  90845. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  90846. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  90847. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  90848. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  90849. * @param options Define the options used to create the shader
  90850. */
  90851. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  90852. /**
  90853. * Gets the shader path used to define the shader code
  90854. * It can be modified to trigger a new compilation
  90855. */
  90856. get shaderPath(): any;
  90857. /**
  90858. * Sets the shader path used to define the shader code
  90859. * It can be modified to trigger a new compilation
  90860. */
  90861. set shaderPath(shaderPath: any);
  90862. /**
  90863. * Gets the options used to compile the shader.
  90864. * They can be modified to trigger a new compilation
  90865. */
  90866. get options(): IShaderMaterialOptions;
  90867. /**
  90868. * Gets the current class name of the material e.g. "ShaderMaterial"
  90869. * Mainly use in serialization.
  90870. * @returns the class name
  90871. */
  90872. getClassName(): string;
  90873. /**
  90874. * Specifies if the material will require alpha blending
  90875. * @returns a boolean specifying if alpha blending is needed
  90876. */
  90877. needAlphaBlending(): boolean;
  90878. /**
  90879. * Specifies if this material should be rendered in alpha test mode
  90880. * @returns a boolean specifying if an alpha test is needed.
  90881. */
  90882. needAlphaTesting(): boolean;
  90883. private _checkUniform;
  90884. /**
  90885. * Set a texture in the shader.
  90886. * @param name Define the name of the uniform samplers as defined in the shader
  90887. * @param texture Define the texture to bind to this sampler
  90888. * @return the material itself allowing "fluent" like uniform updates
  90889. */
  90890. setTexture(name: string, texture: Texture): ShaderMaterial;
  90891. /**
  90892. * Set a texture array in the shader.
  90893. * @param name Define the name of the uniform sampler array as defined in the shader
  90894. * @param textures Define the list of textures to bind to this sampler
  90895. * @return the material itself allowing "fluent" like uniform updates
  90896. */
  90897. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  90898. /**
  90899. * Set a float in the shader.
  90900. * @param name Define the name of the uniform as defined in the shader
  90901. * @param value Define the value to give to the uniform
  90902. * @return the material itself allowing "fluent" like uniform updates
  90903. */
  90904. setFloat(name: string, value: number): ShaderMaterial;
  90905. /**
  90906. * Set a int in the shader.
  90907. * @param name Define the name of the uniform as defined in the shader
  90908. * @param value Define the value to give to the uniform
  90909. * @return the material itself allowing "fluent" like uniform updates
  90910. */
  90911. setInt(name: string, value: number): ShaderMaterial;
  90912. /**
  90913. * Set an array of floats in the shader.
  90914. * @param name Define the name of the uniform as defined in the shader
  90915. * @param value Define the value to give to the uniform
  90916. * @return the material itself allowing "fluent" like uniform updates
  90917. */
  90918. setFloats(name: string, value: number[]): ShaderMaterial;
  90919. /**
  90920. * Set a vec3 in the shader from a Color3.
  90921. * @param name Define the name of the uniform as defined in the shader
  90922. * @param value Define the value to give to the uniform
  90923. * @return the material itself allowing "fluent" like uniform updates
  90924. */
  90925. setColor3(name: string, value: Color3): ShaderMaterial;
  90926. /**
  90927. * Set a vec3 array in the shader from a Color3 array.
  90928. * @param name Define the name of the uniform as defined in the shader
  90929. * @param value Define the value to give to the uniform
  90930. * @return the material itself allowing "fluent" like uniform updates
  90931. */
  90932. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  90933. /**
  90934. * Set a vec4 in the shader from a Color4.
  90935. * @param name Define the name of the uniform as defined in the shader
  90936. * @param value Define the value to give to the uniform
  90937. * @return the material itself allowing "fluent" like uniform updates
  90938. */
  90939. setColor4(name: string, value: Color4): ShaderMaterial;
  90940. /**
  90941. * Set a vec4 array in the shader from a Color4 array.
  90942. * @param name Define the name of the uniform as defined in the shader
  90943. * @param value Define the value to give to the uniform
  90944. * @return the material itself allowing "fluent" like uniform updates
  90945. */
  90946. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  90947. /**
  90948. * Set a vec2 in the shader from a Vector2.
  90949. * @param name Define the name of the uniform as defined in the shader
  90950. * @param value Define the value to give to the uniform
  90951. * @return the material itself allowing "fluent" like uniform updates
  90952. */
  90953. setVector2(name: string, value: Vector2): ShaderMaterial;
  90954. /**
  90955. * Set a vec3 in the shader from a Vector3.
  90956. * @param name Define the name of the uniform as defined in the shader
  90957. * @param value Define the value to give to the uniform
  90958. * @return the material itself allowing "fluent" like uniform updates
  90959. */
  90960. setVector3(name: string, value: Vector3): ShaderMaterial;
  90961. /**
  90962. * Set a vec4 in the shader from a Vector4.
  90963. * @param name Define the name of the uniform as defined in the shader
  90964. * @param value Define the value to give to the uniform
  90965. * @return the material itself allowing "fluent" like uniform updates
  90966. */
  90967. setVector4(name: string, value: Vector4): ShaderMaterial;
  90968. /**
  90969. * Set a mat4 in the shader from a Matrix.
  90970. * @param name Define the name of the uniform as defined in the shader
  90971. * @param value Define the value to give to the uniform
  90972. * @return the material itself allowing "fluent" like uniform updates
  90973. */
  90974. setMatrix(name: string, value: Matrix): ShaderMaterial;
  90975. /**
  90976. * Set a float32Array in the shader from a matrix array.
  90977. * @param name Define the name of the uniform as defined in the shader
  90978. * @param value Define the value to give to the uniform
  90979. * @return the material itself allowing "fluent" like uniform updates
  90980. */
  90981. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  90982. /**
  90983. * Set a mat3 in the shader from a Float32Array.
  90984. * @param name Define the name of the uniform as defined in the shader
  90985. * @param value Define the value to give to the uniform
  90986. * @return the material itself allowing "fluent" like uniform updates
  90987. */
  90988. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  90989. /**
  90990. * Set a mat2 in the shader from a Float32Array.
  90991. * @param name Define the name of the uniform as defined in the shader
  90992. * @param value Define the value to give to the uniform
  90993. * @return the material itself allowing "fluent" like uniform updates
  90994. */
  90995. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  90996. /**
  90997. * Set a vec2 array in the shader from a number array.
  90998. * @param name Define the name of the uniform as defined in the shader
  90999. * @param value Define the value to give to the uniform
  91000. * @return the material itself allowing "fluent" like uniform updates
  91001. */
  91002. setArray2(name: string, value: number[]): ShaderMaterial;
  91003. /**
  91004. * Set a vec3 array in the shader from a number array.
  91005. * @param name Define the name of the uniform as defined in the shader
  91006. * @param value Define the value to give to the uniform
  91007. * @return the material itself allowing "fluent" like uniform updates
  91008. */
  91009. setArray3(name: string, value: number[]): ShaderMaterial;
  91010. /**
  91011. * Set a vec4 array in the shader from a number array.
  91012. * @param name Define the name of the uniform as defined in the shader
  91013. * @param value Define the value to give to the uniform
  91014. * @return the material itself allowing "fluent" like uniform updates
  91015. */
  91016. setArray4(name: string, value: number[]): ShaderMaterial;
  91017. private _checkCache;
  91018. /**
  91019. * Specifies that the submesh is ready to be used
  91020. * @param mesh defines the mesh to check
  91021. * @param subMesh defines which submesh to check
  91022. * @param useInstances specifies that instances should be used
  91023. * @returns a boolean indicating that the submesh is ready or not
  91024. */
  91025. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91026. /**
  91027. * Checks if the material is ready to render the requested mesh
  91028. * @param mesh Define the mesh to render
  91029. * @param useInstances Define whether or not the material is used with instances
  91030. * @returns true if ready, otherwise false
  91031. */
  91032. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91033. /**
  91034. * Binds the world matrix to the material
  91035. * @param world defines the world transformation matrix
  91036. */
  91037. bindOnlyWorldMatrix(world: Matrix): void;
  91038. /**
  91039. * Binds the material to the mesh
  91040. * @param world defines the world transformation matrix
  91041. * @param mesh defines the mesh to bind the material to
  91042. */
  91043. bind(world: Matrix, mesh?: Mesh): void;
  91044. /**
  91045. * Gets the active textures from the material
  91046. * @returns an array of textures
  91047. */
  91048. getActiveTextures(): BaseTexture[];
  91049. /**
  91050. * Specifies if the material uses a texture
  91051. * @param texture defines the texture to check against the material
  91052. * @returns a boolean specifying if the material uses the texture
  91053. */
  91054. hasTexture(texture: BaseTexture): boolean;
  91055. /**
  91056. * Makes a duplicate of the material, and gives it a new name
  91057. * @param name defines the new name for the duplicated material
  91058. * @returns the cloned material
  91059. */
  91060. clone(name: string): ShaderMaterial;
  91061. /**
  91062. * Disposes the material
  91063. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91064. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91065. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91066. */
  91067. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91068. /**
  91069. * Serializes this material in a JSON representation
  91070. * @returns the serialized material object
  91071. */
  91072. serialize(): any;
  91073. /**
  91074. * Creates a shader material from parsed shader material data
  91075. * @param source defines the JSON represnetation of the material
  91076. * @param scene defines the hosting scene
  91077. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91078. * @returns a new material
  91079. */
  91080. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  91081. }
  91082. }
  91083. declare module BABYLON {
  91084. /** @hidden */
  91085. export var colorPixelShader: {
  91086. name: string;
  91087. shader: string;
  91088. };
  91089. }
  91090. declare module BABYLON {
  91091. /** @hidden */
  91092. export var colorVertexShader: {
  91093. name: string;
  91094. shader: string;
  91095. };
  91096. }
  91097. declare module BABYLON {
  91098. /**
  91099. * Line mesh
  91100. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  91101. */
  91102. export class LinesMesh extends Mesh {
  91103. /**
  91104. * If vertex color should be applied to the mesh
  91105. */
  91106. readonly useVertexColor?: boolean | undefined;
  91107. /**
  91108. * If vertex alpha should be applied to the mesh
  91109. */
  91110. readonly useVertexAlpha?: boolean | undefined;
  91111. /**
  91112. * Color of the line (Default: White)
  91113. */
  91114. color: Color3;
  91115. /**
  91116. * Alpha of the line (Default: 1)
  91117. */
  91118. alpha: number;
  91119. /**
  91120. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91121. * This margin is expressed in world space coordinates, so its value may vary.
  91122. * Default value is 0.1
  91123. */
  91124. intersectionThreshold: number;
  91125. private _colorShader;
  91126. private color4;
  91127. /**
  91128. * Creates a new LinesMesh
  91129. * @param name defines the name
  91130. * @param scene defines the hosting scene
  91131. * @param parent defines the parent mesh if any
  91132. * @param source defines the optional source LinesMesh used to clone data from
  91133. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91134. * When false, achieved by calling a clone(), also passing False.
  91135. * This will make creation of children, recursive.
  91136. * @param useVertexColor defines if this LinesMesh supports vertex color
  91137. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  91138. */
  91139. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  91140. /**
  91141. * If vertex color should be applied to the mesh
  91142. */
  91143. useVertexColor?: boolean | undefined,
  91144. /**
  91145. * If vertex alpha should be applied to the mesh
  91146. */
  91147. useVertexAlpha?: boolean | undefined);
  91148. private _addClipPlaneDefine;
  91149. private _removeClipPlaneDefine;
  91150. isReady(): boolean;
  91151. /**
  91152. * Returns the string "LineMesh"
  91153. */
  91154. getClassName(): string;
  91155. /**
  91156. * @hidden
  91157. */
  91158. get material(): Material;
  91159. /**
  91160. * @hidden
  91161. */
  91162. set material(value: Material);
  91163. /**
  91164. * @hidden
  91165. */
  91166. get checkCollisions(): boolean;
  91167. /** @hidden */
  91168. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91169. /** @hidden */
  91170. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91171. /**
  91172. * Disposes of the line mesh
  91173. * @param doNotRecurse If children should be disposed
  91174. */
  91175. dispose(doNotRecurse?: boolean): void;
  91176. /**
  91177. * Returns a new LineMesh object cloned from the current one.
  91178. */
  91179. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  91180. /**
  91181. * Creates a new InstancedLinesMesh object from the mesh model.
  91182. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91183. * @param name defines the name of the new instance
  91184. * @returns a new InstancedLinesMesh
  91185. */
  91186. createInstance(name: string): InstancedLinesMesh;
  91187. }
  91188. /**
  91189. * Creates an instance based on a source LinesMesh
  91190. */
  91191. export class InstancedLinesMesh extends InstancedMesh {
  91192. /**
  91193. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91194. * This margin is expressed in world space coordinates, so its value may vary.
  91195. * Initilized with the intersectionThreshold value of the source LinesMesh
  91196. */
  91197. intersectionThreshold: number;
  91198. constructor(name: string, source: LinesMesh);
  91199. /**
  91200. * Returns the string "InstancedLinesMesh".
  91201. */
  91202. getClassName(): string;
  91203. }
  91204. }
  91205. declare module BABYLON {
  91206. /** @hidden */
  91207. export var linePixelShader: {
  91208. name: string;
  91209. shader: string;
  91210. };
  91211. }
  91212. declare module BABYLON {
  91213. /** @hidden */
  91214. export var lineVertexShader: {
  91215. name: string;
  91216. shader: string;
  91217. };
  91218. }
  91219. declare module BABYLON {
  91220. interface AbstractMesh {
  91221. /**
  91222. * Gets the edgesRenderer associated with the mesh
  91223. */
  91224. edgesRenderer: Nullable<EdgesRenderer>;
  91225. }
  91226. interface LinesMesh {
  91227. /**
  91228. * Enables the edge rendering mode on the mesh.
  91229. * This mode makes the mesh edges visible
  91230. * @param epsilon defines the maximal distance between two angles to detect a face
  91231. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91232. * @returns the currentAbstractMesh
  91233. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91234. */
  91235. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91236. }
  91237. interface InstancedLinesMesh {
  91238. /**
  91239. * Enables the edge rendering mode on the mesh.
  91240. * This mode makes the mesh edges visible
  91241. * @param epsilon defines the maximal distance between two angles to detect a face
  91242. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91243. * @returns the current InstancedLinesMesh
  91244. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91245. */
  91246. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  91247. }
  91248. /**
  91249. * Defines the minimum contract an Edges renderer should follow.
  91250. */
  91251. export interface IEdgesRenderer extends IDisposable {
  91252. /**
  91253. * Gets or sets a boolean indicating if the edgesRenderer is active
  91254. */
  91255. isEnabled: boolean;
  91256. /**
  91257. * Renders the edges of the attached mesh,
  91258. */
  91259. render(): void;
  91260. /**
  91261. * Checks wether or not the edges renderer is ready to render.
  91262. * @return true if ready, otherwise false.
  91263. */
  91264. isReady(): boolean;
  91265. }
  91266. /**
  91267. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  91268. */
  91269. export class EdgesRenderer implements IEdgesRenderer {
  91270. /**
  91271. * Define the size of the edges with an orthographic camera
  91272. */
  91273. edgesWidthScalerForOrthographic: number;
  91274. /**
  91275. * Define the size of the edges with a perspective camera
  91276. */
  91277. edgesWidthScalerForPerspective: number;
  91278. protected _source: AbstractMesh;
  91279. protected _linesPositions: number[];
  91280. protected _linesNormals: number[];
  91281. protected _linesIndices: number[];
  91282. protected _epsilon: number;
  91283. protected _indicesCount: number;
  91284. protected _lineShader: ShaderMaterial;
  91285. protected _ib: DataBuffer;
  91286. protected _buffers: {
  91287. [key: string]: Nullable<VertexBuffer>;
  91288. };
  91289. protected _checkVerticesInsteadOfIndices: boolean;
  91290. private _meshRebuildObserver;
  91291. private _meshDisposeObserver;
  91292. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  91293. isEnabled: boolean;
  91294. /**
  91295. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  91296. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  91297. * @param source Mesh used to create edges
  91298. * @param epsilon sum of angles in adjacency to check for edge
  91299. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  91300. * @param generateEdgesLines - should generate Lines or only prepare resources.
  91301. */
  91302. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  91303. protected _prepareRessources(): void;
  91304. /** @hidden */
  91305. _rebuild(): void;
  91306. /**
  91307. * Releases the required resources for the edges renderer
  91308. */
  91309. dispose(): void;
  91310. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  91311. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  91312. /**
  91313. * Checks if the pair of p0 and p1 is en edge
  91314. * @param faceIndex
  91315. * @param edge
  91316. * @param faceNormals
  91317. * @param p0
  91318. * @param p1
  91319. * @private
  91320. */
  91321. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  91322. /**
  91323. * push line into the position, normal and index buffer
  91324. * @protected
  91325. */
  91326. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  91327. /**
  91328. * Generates lines edges from adjacencjes
  91329. * @private
  91330. */
  91331. _generateEdgesLines(): void;
  91332. /**
  91333. * Checks wether or not the edges renderer is ready to render.
  91334. * @return true if ready, otherwise false.
  91335. */
  91336. isReady(): boolean;
  91337. /**
  91338. * Renders the edges of the attached mesh,
  91339. */
  91340. render(): void;
  91341. }
  91342. /**
  91343. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  91344. */
  91345. export class LineEdgesRenderer extends EdgesRenderer {
  91346. /**
  91347. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  91348. * @param source LineMesh used to generate edges
  91349. * @param epsilon not important (specified angle for edge detection)
  91350. * @param checkVerticesInsteadOfIndices not important for LineMesh
  91351. */
  91352. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  91353. /**
  91354. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  91355. */
  91356. _generateEdgesLines(): void;
  91357. }
  91358. }
  91359. declare module BABYLON {
  91360. /**
  91361. * This represents the object necessary to create a rendering group.
  91362. * This is exclusively used and created by the rendering manager.
  91363. * To modify the behavior, you use the available helpers in your scene or meshes.
  91364. * @hidden
  91365. */
  91366. export class RenderingGroup {
  91367. index: number;
  91368. private static _zeroVector;
  91369. private _scene;
  91370. private _opaqueSubMeshes;
  91371. private _transparentSubMeshes;
  91372. private _alphaTestSubMeshes;
  91373. private _depthOnlySubMeshes;
  91374. private _particleSystems;
  91375. private _spriteManagers;
  91376. private _opaqueSortCompareFn;
  91377. private _alphaTestSortCompareFn;
  91378. private _transparentSortCompareFn;
  91379. private _renderOpaque;
  91380. private _renderAlphaTest;
  91381. private _renderTransparent;
  91382. /** @hidden */
  91383. _edgesRenderers: SmartArray<IEdgesRenderer>;
  91384. onBeforeTransparentRendering: () => void;
  91385. /**
  91386. * Set the opaque sort comparison function.
  91387. * If null the sub meshes will be render in the order they were created
  91388. */
  91389. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91390. /**
  91391. * Set the alpha test sort comparison function.
  91392. * If null the sub meshes will be render in the order they were created
  91393. */
  91394. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91395. /**
  91396. * Set the transparent sort comparison function.
  91397. * If null the sub meshes will be render in the order they were created
  91398. */
  91399. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91400. /**
  91401. * Creates a new rendering group.
  91402. * @param index The rendering group index
  91403. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  91404. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  91405. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  91406. */
  91407. 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>);
  91408. /**
  91409. * Render all the sub meshes contained in the group.
  91410. * @param customRenderFunction Used to override the default render behaviour of the group.
  91411. * @returns true if rendered some submeshes.
  91412. */
  91413. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  91414. /**
  91415. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  91416. * @param subMeshes The submeshes to render
  91417. */
  91418. private renderOpaqueSorted;
  91419. /**
  91420. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  91421. * @param subMeshes The submeshes to render
  91422. */
  91423. private renderAlphaTestSorted;
  91424. /**
  91425. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  91426. * @param subMeshes The submeshes to render
  91427. */
  91428. private renderTransparentSorted;
  91429. /**
  91430. * Renders the submeshes in a specified order.
  91431. * @param subMeshes The submeshes to sort before render
  91432. * @param sortCompareFn The comparison function use to sort
  91433. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  91434. * @param transparent Specifies to activate blending if true
  91435. */
  91436. private static renderSorted;
  91437. /**
  91438. * Renders the submeshes in the order they were dispatched (no sort applied).
  91439. * @param subMeshes The submeshes to render
  91440. */
  91441. private static renderUnsorted;
  91442. /**
  91443. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91444. * are rendered back to front if in the same alpha index.
  91445. *
  91446. * @param a The first submesh
  91447. * @param b The second submesh
  91448. * @returns The result of the comparison
  91449. */
  91450. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  91451. /**
  91452. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91453. * are rendered back to front.
  91454. *
  91455. * @param a The first submesh
  91456. * @param b The second submesh
  91457. * @returns The result of the comparison
  91458. */
  91459. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  91460. /**
  91461. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91462. * are rendered front to back (prevent overdraw).
  91463. *
  91464. * @param a The first submesh
  91465. * @param b The second submesh
  91466. * @returns The result of the comparison
  91467. */
  91468. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  91469. /**
  91470. * Resets the different lists of submeshes to prepare a new frame.
  91471. */
  91472. prepare(): void;
  91473. dispose(): void;
  91474. /**
  91475. * Inserts the submesh in its correct queue depending on its material.
  91476. * @param subMesh The submesh to dispatch
  91477. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  91478. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  91479. */
  91480. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  91481. dispatchSprites(spriteManager: ISpriteManager): void;
  91482. dispatchParticles(particleSystem: IParticleSystem): void;
  91483. private _renderParticles;
  91484. private _renderSprites;
  91485. }
  91486. }
  91487. declare module BABYLON {
  91488. /**
  91489. * Interface describing the different options available in the rendering manager
  91490. * regarding Auto Clear between groups.
  91491. */
  91492. export interface IRenderingManagerAutoClearSetup {
  91493. /**
  91494. * Defines whether or not autoclear is enable.
  91495. */
  91496. autoClear: boolean;
  91497. /**
  91498. * Defines whether or not to autoclear the depth buffer.
  91499. */
  91500. depth: boolean;
  91501. /**
  91502. * Defines whether or not to autoclear the stencil buffer.
  91503. */
  91504. stencil: boolean;
  91505. }
  91506. /**
  91507. * This class is used by the onRenderingGroupObservable
  91508. */
  91509. export class RenderingGroupInfo {
  91510. /**
  91511. * The Scene that being rendered
  91512. */
  91513. scene: Scene;
  91514. /**
  91515. * The camera currently used for the rendering pass
  91516. */
  91517. camera: Nullable<Camera>;
  91518. /**
  91519. * The ID of the renderingGroup being processed
  91520. */
  91521. renderingGroupId: number;
  91522. }
  91523. /**
  91524. * This is the manager responsible of all the rendering for meshes sprites and particles.
  91525. * It is enable to manage the different groups as well as the different necessary sort functions.
  91526. * This should not be used directly aside of the few static configurations
  91527. */
  91528. export class RenderingManager {
  91529. /**
  91530. * The max id used for rendering groups (not included)
  91531. */
  91532. static MAX_RENDERINGGROUPS: number;
  91533. /**
  91534. * The min id used for rendering groups (included)
  91535. */
  91536. static MIN_RENDERINGGROUPS: number;
  91537. /**
  91538. * Used to globally prevent autoclearing scenes.
  91539. */
  91540. static AUTOCLEAR: boolean;
  91541. /**
  91542. * @hidden
  91543. */
  91544. _useSceneAutoClearSetup: boolean;
  91545. private _scene;
  91546. private _renderingGroups;
  91547. private _depthStencilBufferAlreadyCleaned;
  91548. private _autoClearDepthStencil;
  91549. private _customOpaqueSortCompareFn;
  91550. private _customAlphaTestSortCompareFn;
  91551. private _customTransparentSortCompareFn;
  91552. private _renderingGroupInfo;
  91553. /**
  91554. * Instantiates a new rendering group for a particular scene
  91555. * @param scene Defines the scene the groups belongs to
  91556. */
  91557. constructor(scene: Scene);
  91558. private _clearDepthStencilBuffer;
  91559. /**
  91560. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  91561. * @hidden
  91562. */
  91563. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  91564. /**
  91565. * Resets the different information of the group to prepare a new frame
  91566. * @hidden
  91567. */
  91568. reset(): void;
  91569. /**
  91570. * Dispose and release the group and its associated resources.
  91571. * @hidden
  91572. */
  91573. dispose(): void;
  91574. /**
  91575. * Clear the info related to rendering groups preventing retention points during dispose.
  91576. */
  91577. freeRenderingGroups(): void;
  91578. private _prepareRenderingGroup;
  91579. /**
  91580. * Add a sprite manager to the rendering manager in order to render it this frame.
  91581. * @param spriteManager Define the sprite manager to render
  91582. */
  91583. dispatchSprites(spriteManager: ISpriteManager): void;
  91584. /**
  91585. * Add a particle system to the rendering manager in order to render it this frame.
  91586. * @param particleSystem Define the particle system to render
  91587. */
  91588. dispatchParticles(particleSystem: IParticleSystem): void;
  91589. /**
  91590. * Add a submesh to the manager in order to render it this frame
  91591. * @param subMesh The submesh to dispatch
  91592. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  91593. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  91594. */
  91595. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  91596. /**
  91597. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91598. * This allowed control for front to back rendering or reversly depending of the special needs.
  91599. *
  91600. * @param renderingGroupId The rendering group id corresponding to its index
  91601. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91602. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91603. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91604. */
  91605. 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;
  91606. /**
  91607. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91608. *
  91609. * @param renderingGroupId The rendering group id corresponding to its index
  91610. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91611. * @param depth Automatically clears depth between groups if true and autoClear is true.
  91612. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  91613. */
  91614. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  91615. /**
  91616. * Gets the current auto clear configuration for one rendering group of the rendering
  91617. * manager.
  91618. * @param index the rendering group index to get the information for
  91619. * @returns The auto clear setup for the requested rendering group
  91620. */
  91621. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  91622. }
  91623. }
  91624. declare module BABYLON {
  91625. /**
  91626. * This Helps creating a texture that will be created from a camera in your scene.
  91627. * It is basically a dynamic texture that could be used to create special effects for instance.
  91628. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  91629. */
  91630. export class RenderTargetTexture extends Texture {
  91631. isCube: boolean;
  91632. /**
  91633. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  91634. */
  91635. static readonly REFRESHRATE_RENDER_ONCE: number;
  91636. /**
  91637. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  91638. */
  91639. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  91640. /**
  91641. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  91642. * the central point of your effect and can save a lot of performances.
  91643. */
  91644. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  91645. /**
  91646. * Use this predicate to dynamically define the list of mesh you want to render.
  91647. * If set, the renderList property will be overwritten.
  91648. */
  91649. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  91650. private _renderList;
  91651. /**
  91652. * Use this list to define the list of mesh you want to render.
  91653. */
  91654. get renderList(): Nullable<Array<AbstractMesh>>;
  91655. set renderList(value: Nullable<Array<AbstractMesh>>);
  91656. private _hookArray;
  91657. /**
  91658. * Define if particles should be rendered in your texture.
  91659. */
  91660. renderParticles: boolean;
  91661. /**
  91662. * Define if sprites should be rendered in your texture.
  91663. */
  91664. renderSprites: boolean;
  91665. /**
  91666. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  91667. */
  91668. coordinatesMode: number;
  91669. /**
  91670. * Define the camera used to render the texture.
  91671. */
  91672. activeCamera: Nullable<Camera>;
  91673. /**
  91674. * Override the render function of the texture with your own one.
  91675. */
  91676. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  91677. /**
  91678. * Define if camera post processes should be use while rendering the texture.
  91679. */
  91680. useCameraPostProcesses: boolean;
  91681. /**
  91682. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  91683. */
  91684. ignoreCameraViewport: boolean;
  91685. private _postProcessManager;
  91686. private _postProcesses;
  91687. private _resizeObserver;
  91688. /**
  91689. * An event triggered when the texture is unbind.
  91690. */
  91691. onBeforeBindObservable: Observable<RenderTargetTexture>;
  91692. /**
  91693. * An event triggered when the texture is unbind.
  91694. */
  91695. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  91696. private _onAfterUnbindObserver;
  91697. /**
  91698. * Set a after unbind callback in the texture.
  91699. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  91700. */
  91701. set onAfterUnbind(callback: () => void);
  91702. /**
  91703. * An event triggered before rendering the texture
  91704. */
  91705. onBeforeRenderObservable: Observable<number>;
  91706. private _onBeforeRenderObserver;
  91707. /**
  91708. * Set a before render callback in the texture.
  91709. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  91710. */
  91711. set onBeforeRender(callback: (faceIndex: number) => void);
  91712. /**
  91713. * An event triggered after rendering the texture
  91714. */
  91715. onAfterRenderObservable: Observable<number>;
  91716. private _onAfterRenderObserver;
  91717. /**
  91718. * Set a after render callback in the texture.
  91719. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  91720. */
  91721. set onAfterRender(callback: (faceIndex: number) => void);
  91722. /**
  91723. * An event triggered after the texture clear
  91724. */
  91725. onClearObservable: Observable<Engine>;
  91726. private _onClearObserver;
  91727. /**
  91728. * Set a clear callback in the texture.
  91729. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  91730. */
  91731. set onClear(callback: (Engine: Engine) => void);
  91732. /**
  91733. * An event triggered when the texture is resized.
  91734. */
  91735. onResizeObservable: Observable<RenderTargetTexture>;
  91736. /**
  91737. * Define the clear color of the Render Target if it should be different from the scene.
  91738. */
  91739. clearColor: Color4;
  91740. protected _size: number | {
  91741. width: number;
  91742. height: number;
  91743. };
  91744. protected _initialSizeParameter: number | {
  91745. width: number;
  91746. height: number;
  91747. } | {
  91748. ratio: number;
  91749. };
  91750. protected _sizeRatio: Nullable<number>;
  91751. /** @hidden */
  91752. _generateMipMaps: boolean;
  91753. protected _renderingManager: RenderingManager;
  91754. /** @hidden */
  91755. _waitingRenderList: string[];
  91756. protected _doNotChangeAspectRatio: boolean;
  91757. protected _currentRefreshId: number;
  91758. protected _refreshRate: number;
  91759. protected _textureMatrix: Matrix;
  91760. protected _samples: number;
  91761. protected _renderTargetOptions: RenderTargetCreationOptions;
  91762. /**
  91763. * Gets render target creation options that were used.
  91764. */
  91765. get renderTargetOptions(): RenderTargetCreationOptions;
  91766. protected _engine: Engine;
  91767. protected _onRatioRescale(): void;
  91768. /**
  91769. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  91770. * It must define where the camera used to render the texture is set
  91771. */
  91772. boundingBoxPosition: Vector3;
  91773. private _boundingBoxSize;
  91774. /**
  91775. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  91776. * When defined, the cubemap will switch to local mode
  91777. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  91778. * @example https://www.babylonjs-playground.com/#RNASML
  91779. */
  91780. set boundingBoxSize(value: Vector3);
  91781. get boundingBoxSize(): Vector3;
  91782. /**
  91783. * In case the RTT has been created with a depth texture, get the associated
  91784. * depth texture.
  91785. * Otherwise, return null.
  91786. */
  91787. depthStencilTexture: Nullable<InternalTexture>;
  91788. /**
  91789. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  91790. * or used a shadow, depth texture...
  91791. * @param name The friendly name of the texture
  91792. * @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)
  91793. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  91794. * @param generateMipMaps True if mip maps need to be generated after render.
  91795. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  91796. * @param type The type of the buffer in the RTT (int, half float, float...)
  91797. * @param isCube True if a cube texture needs to be created
  91798. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  91799. * @param generateDepthBuffer True to generate a depth buffer
  91800. * @param generateStencilBuffer True to generate a stencil buffer
  91801. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  91802. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  91803. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91804. */
  91805. constructor(name: string, size: number | {
  91806. width: number;
  91807. height: number;
  91808. } | {
  91809. ratio: number;
  91810. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  91811. /**
  91812. * Creates a depth stencil texture.
  91813. * This is only available in WebGL 2 or with the depth texture extension available.
  91814. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  91815. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  91816. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  91817. */
  91818. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  91819. private _processSizeParameter;
  91820. /**
  91821. * Define the number of samples to use in case of MSAA.
  91822. * It defaults to one meaning no MSAA has been enabled.
  91823. */
  91824. get samples(): number;
  91825. set samples(value: number);
  91826. /**
  91827. * Resets the refresh counter of the texture and start bak from scratch.
  91828. * Could be useful to regenerate the texture if it is setup to render only once.
  91829. */
  91830. resetRefreshCounter(): void;
  91831. /**
  91832. * Define the refresh rate of the texture or the rendering frequency.
  91833. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91834. */
  91835. get refreshRate(): number;
  91836. set refreshRate(value: number);
  91837. /**
  91838. * Adds a post process to the render target rendering passes.
  91839. * @param postProcess define the post process to add
  91840. */
  91841. addPostProcess(postProcess: PostProcess): void;
  91842. /**
  91843. * Clear all the post processes attached to the render target
  91844. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  91845. */
  91846. clearPostProcesses(dispose?: boolean): void;
  91847. /**
  91848. * Remove one of the post process from the list of attached post processes to the texture
  91849. * @param postProcess define the post process to remove from the list
  91850. */
  91851. removePostProcess(postProcess: PostProcess): void;
  91852. /** @hidden */
  91853. _shouldRender(): boolean;
  91854. /**
  91855. * Gets the actual render size of the texture.
  91856. * @returns the width of the render size
  91857. */
  91858. getRenderSize(): number;
  91859. /**
  91860. * Gets the actual render width of the texture.
  91861. * @returns the width of the render size
  91862. */
  91863. getRenderWidth(): number;
  91864. /**
  91865. * Gets the actual render height of the texture.
  91866. * @returns the height of the render size
  91867. */
  91868. getRenderHeight(): number;
  91869. /**
  91870. * Get if the texture can be rescaled or not.
  91871. */
  91872. get canRescale(): boolean;
  91873. /**
  91874. * Resize the texture using a ratio.
  91875. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  91876. */
  91877. scale(ratio: number): void;
  91878. /**
  91879. * Get the texture reflection matrix used to rotate/transform the reflection.
  91880. * @returns the reflection matrix
  91881. */
  91882. getReflectionTextureMatrix(): Matrix;
  91883. /**
  91884. * Resize the texture to a new desired size.
  91885. * Be carrefull as it will recreate all the data in the new texture.
  91886. * @param size Define the new size. It can be:
  91887. * - a number for squared texture,
  91888. * - an object containing { width: number, height: number }
  91889. * - or an object containing a ratio { ratio: number }
  91890. */
  91891. resize(size: number | {
  91892. width: number;
  91893. height: number;
  91894. } | {
  91895. ratio: number;
  91896. }): void;
  91897. /**
  91898. * Renders all the objects from the render list into the texture.
  91899. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  91900. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  91901. */
  91902. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  91903. private _bestReflectionRenderTargetDimension;
  91904. /**
  91905. * @hidden
  91906. * @param faceIndex face index to bind to if this is a cubetexture
  91907. */
  91908. _bindFrameBuffer(faceIndex?: number): void;
  91909. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  91910. private renderToTarget;
  91911. /**
  91912. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91913. * This allowed control for front to back rendering or reversly depending of the special needs.
  91914. *
  91915. * @param renderingGroupId The rendering group id corresponding to its index
  91916. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91917. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91918. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91919. */
  91920. 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;
  91921. /**
  91922. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91923. *
  91924. * @param renderingGroupId The rendering group id corresponding to its index
  91925. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91926. */
  91927. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  91928. /**
  91929. * Clones the texture.
  91930. * @returns the cloned texture
  91931. */
  91932. clone(): RenderTargetTexture;
  91933. /**
  91934. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  91935. * @returns The JSON representation of the texture
  91936. */
  91937. serialize(): any;
  91938. /**
  91939. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  91940. */
  91941. disposeFramebufferObjects(): void;
  91942. /**
  91943. * Dispose the texture and release its associated resources.
  91944. */
  91945. dispose(): void;
  91946. /** @hidden */
  91947. _rebuild(): void;
  91948. /**
  91949. * Clear the info related to rendering groups preventing retention point in material dispose.
  91950. */
  91951. freeRenderingGroups(): void;
  91952. /**
  91953. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  91954. * @returns the view count
  91955. */
  91956. getViewCount(): number;
  91957. }
  91958. }
  91959. declare module BABYLON {
  91960. /**
  91961. * Options for compiling materials.
  91962. */
  91963. export interface IMaterialCompilationOptions {
  91964. /**
  91965. * Defines whether clip planes are enabled.
  91966. */
  91967. clipPlane: boolean;
  91968. /**
  91969. * Defines whether instances are enabled.
  91970. */
  91971. useInstances: boolean;
  91972. }
  91973. /**
  91974. * Base class for the main features of a material in Babylon.js
  91975. */
  91976. export class Material implements IAnimatable {
  91977. /**
  91978. * Returns the triangle fill mode
  91979. */
  91980. static readonly TriangleFillMode: number;
  91981. /**
  91982. * Returns the wireframe mode
  91983. */
  91984. static readonly WireFrameFillMode: number;
  91985. /**
  91986. * Returns the point fill mode
  91987. */
  91988. static readonly PointFillMode: number;
  91989. /**
  91990. * Returns the point list draw mode
  91991. */
  91992. static readonly PointListDrawMode: number;
  91993. /**
  91994. * Returns the line list draw mode
  91995. */
  91996. static readonly LineListDrawMode: number;
  91997. /**
  91998. * Returns the line loop draw mode
  91999. */
  92000. static readonly LineLoopDrawMode: number;
  92001. /**
  92002. * Returns the line strip draw mode
  92003. */
  92004. static readonly LineStripDrawMode: number;
  92005. /**
  92006. * Returns the triangle strip draw mode
  92007. */
  92008. static readonly TriangleStripDrawMode: number;
  92009. /**
  92010. * Returns the triangle fan draw mode
  92011. */
  92012. static readonly TriangleFanDrawMode: number;
  92013. /**
  92014. * Stores the clock-wise side orientation
  92015. */
  92016. static readonly ClockWiseSideOrientation: number;
  92017. /**
  92018. * Stores the counter clock-wise side orientation
  92019. */
  92020. static readonly CounterClockWiseSideOrientation: number;
  92021. /**
  92022. * The dirty texture flag value
  92023. */
  92024. static readonly TextureDirtyFlag: number;
  92025. /**
  92026. * The dirty light flag value
  92027. */
  92028. static readonly LightDirtyFlag: number;
  92029. /**
  92030. * The dirty fresnel flag value
  92031. */
  92032. static readonly FresnelDirtyFlag: number;
  92033. /**
  92034. * The dirty attribute flag value
  92035. */
  92036. static readonly AttributesDirtyFlag: number;
  92037. /**
  92038. * The dirty misc flag value
  92039. */
  92040. static readonly MiscDirtyFlag: number;
  92041. /**
  92042. * The all dirty flag value
  92043. */
  92044. static readonly AllDirtyFlag: number;
  92045. /**
  92046. * The ID of the material
  92047. */
  92048. id: string;
  92049. /**
  92050. * Gets or sets the unique id of the material
  92051. */
  92052. uniqueId: number;
  92053. /**
  92054. * The name of the material
  92055. */
  92056. name: string;
  92057. /**
  92058. * Gets or sets user defined metadata
  92059. */
  92060. metadata: any;
  92061. /**
  92062. * For internal use only. Please do not use.
  92063. */
  92064. reservedDataStore: any;
  92065. /**
  92066. * Specifies if the ready state should be checked on each call
  92067. */
  92068. checkReadyOnEveryCall: boolean;
  92069. /**
  92070. * Specifies if the ready state should be checked once
  92071. */
  92072. checkReadyOnlyOnce: boolean;
  92073. /**
  92074. * The state of the material
  92075. */
  92076. state: string;
  92077. /**
  92078. * The alpha value of the material
  92079. */
  92080. protected _alpha: number;
  92081. /**
  92082. * List of inspectable custom properties (used by the Inspector)
  92083. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92084. */
  92085. inspectableCustomProperties: IInspectable[];
  92086. /**
  92087. * Sets the alpha value of the material
  92088. */
  92089. set alpha(value: number);
  92090. /**
  92091. * Gets the alpha value of the material
  92092. */
  92093. get alpha(): number;
  92094. /**
  92095. * Specifies if back face culling is enabled
  92096. */
  92097. protected _backFaceCulling: boolean;
  92098. /**
  92099. * Sets the back-face culling state
  92100. */
  92101. set backFaceCulling(value: boolean);
  92102. /**
  92103. * Gets the back-face culling state
  92104. */
  92105. get backFaceCulling(): boolean;
  92106. /**
  92107. * Stores the value for side orientation
  92108. */
  92109. sideOrientation: number;
  92110. /**
  92111. * Callback triggered when the material is compiled
  92112. */
  92113. onCompiled: Nullable<(effect: Effect) => void>;
  92114. /**
  92115. * Callback triggered when an error occurs
  92116. */
  92117. onError: Nullable<(effect: Effect, errors: string) => void>;
  92118. /**
  92119. * Callback triggered to get the render target textures
  92120. */
  92121. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  92122. /**
  92123. * Gets a boolean indicating that current material needs to register RTT
  92124. */
  92125. get hasRenderTargetTextures(): boolean;
  92126. /**
  92127. * Specifies if the material should be serialized
  92128. */
  92129. doNotSerialize: boolean;
  92130. /**
  92131. * @hidden
  92132. */
  92133. _storeEffectOnSubMeshes: boolean;
  92134. /**
  92135. * Stores the animations for the material
  92136. */
  92137. animations: Nullable<Array<Animation>>;
  92138. /**
  92139. * An event triggered when the material is disposed
  92140. */
  92141. onDisposeObservable: Observable<Material>;
  92142. /**
  92143. * An observer which watches for dispose events
  92144. */
  92145. private _onDisposeObserver;
  92146. private _onUnBindObservable;
  92147. /**
  92148. * Called during a dispose event
  92149. */
  92150. set onDispose(callback: () => void);
  92151. private _onBindObservable;
  92152. /**
  92153. * An event triggered when the material is bound
  92154. */
  92155. get onBindObservable(): Observable<AbstractMesh>;
  92156. /**
  92157. * An observer which watches for bind events
  92158. */
  92159. private _onBindObserver;
  92160. /**
  92161. * Called during a bind event
  92162. */
  92163. set onBind(callback: (Mesh: AbstractMesh) => void);
  92164. /**
  92165. * An event triggered when the material is unbound
  92166. */
  92167. get onUnBindObservable(): Observable<Material>;
  92168. /**
  92169. * Stores the value of the alpha mode
  92170. */
  92171. private _alphaMode;
  92172. /**
  92173. * Sets the value of the alpha mode.
  92174. *
  92175. * | Value | Type | Description |
  92176. * | --- | --- | --- |
  92177. * | 0 | ALPHA_DISABLE | |
  92178. * | 1 | ALPHA_ADD | |
  92179. * | 2 | ALPHA_COMBINE | |
  92180. * | 3 | ALPHA_SUBTRACT | |
  92181. * | 4 | ALPHA_MULTIPLY | |
  92182. * | 5 | ALPHA_MAXIMIZED | |
  92183. * | 6 | ALPHA_ONEONE | |
  92184. * | 7 | ALPHA_PREMULTIPLIED | |
  92185. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  92186. * | 9 | ALPHA_INTERPOLATE | |
  92187. * | 10 | ALPHA_SCREENMODE | |
  92188. *
  92189. */
  92190. set alphaMode(value: number);
  92191. /**
  92192. * Gets the value of the alpha mode
  92193. */
  92194. get alphaMode(): number;
  92195. /**
  92196. * Stores the state of the need depth pre-pass value
  92197. */
  92198. private _needDepthPrePass;
  92199. /**
  92200. * Sets the need depth pre-pass value
  92201. */
  92202. set needDepthPrePass(value: boolean);
  92203. /**
  92204. * Gets the depth pre-pass value
  92205. */
  92206. get needDepthPrePass(): boolean;
  92207. /**
  92208. * Specifies if depth writing should be disabled
  92209. */
  92210. disableDepthWrite: boolean;
  92211. /**
  92212. * Specifies if depth writing should be forced
  92213. */
  92214. forceDepthWrite: boolean;
  92215. /**
  92216. * Specifies the depth function that should be used. 0 means the default engine function
  92217. */
  92218. depthFunction: number;
  92219. /**
  92220. * Specifies if there should be a separate pass for culling
  92221. */
  92222. separateCullingPass: boolean;
  92223. /**
  92224. * Stores the state specifing if fog should be enabled
  92225. */
  92226. private _fogEnabled;
  92227. /**
  92228. * Sets the state for enabling fog
  92229. */
  92230. set fogEnabled(value: boolean);
  92231. /**
  92232. * Gets the value of the fog enabled state
  92233. */
  92234. get fogEnabled(): boolean;
  92235. /**
  92236. * Stores the size of points
  92237. */
  92238. pointSize: number;
  92239. /**
  92240. * Stores the z offset value
  92241. */
  92242. zOffset: number;
  92243. /**
  92244. * Gets a value specifying if wireframe mode is enabled
  92245. */
  92246. get wireframe(): boolean;
  92247. /**
  92248. * Sets the state of wireframe mode
  92249. */
  92250. set wireframe(value: boolean);
  92251. /**
  92252. * Gets the value specifying if point clouds are enabled
  92253. */
  92254. get pointsCloud(): boolean;
  92255. /**
  92256. * Sets the state of point cloud mode
  92257. */
  92258. set pointsCloud(value: boolean);
  92259. /**
  92260. * Gets the material fill mode
  92261. */
  92262. get fillMode(): number;
  92263. /**
  92264. * Sets the material fill mode
  92265. */
  92266. set fillMode(value: number);
  92267. /**
  92268. * @hidden
  92269. * Stores the effects for the material
  92270. */
  92271. _effect: Nullable<Effect>;
  92272. /**
  92273. * Specifies if uniform buffers should be used
  92274. */
  92275. private _useUBO;
  92276. /**
  92277. * Stores a reference to the scene
  92278. */
  92279. private _scene;
  92280. /**
  92281. * Stores the fill mode state
  92282. */
  92283. private _fillMode;
  92284. /**
  92285. * Specifies if the depth write state should be cached
  92286. */
  92287. private _cachedDepthWriteState;
  92288. /**
  92289. * Specifies if the depth function state should be cached
  92290. */
  92291. private _cachedDepthFunctionState;
  92292. /**
  92293. * Stores the uniform buffer
  92294. */
  92295. protected _uniformBuffer: UniformBuffer;
  92296. /** @hidden */
  92297. _indexInSceneMaterialArray: number;
  92298. /** @hidden */
  92299. meshMap: Nullable<{
  92300. [id: string]: AbstractMesh | undefined;
  92301. }>;
  92302. /**
  92303. * Creates a material instance
  92304. * @param name defines the name of the material
  92305. * @param scene defines the scene to reference
  92306. * @param doNotAdd specifies if the material should be added to the scene
  92307. */
  92308. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  92309. /**
  92310. * Returns a string representation of the current material
  92311. * @param fullDetails defines a boolean indicating which levels of logging is desired
  92312. * @returns a string with material information
  92313. */
  92314. toString(fullDetails?: boolean): string;
  92315. /**
  92316. * Gets the class name of the material
  92317. * @returns a string with the class name of the material
  92318. */
  92319. getClassName(): string;
  92320. /**
  92321. * Specifies if updates for the material been locked
  92322. */
  92323. get isFrozen(): boolean;
  92324. /**
  92325. * Locks updates for the material
  92326. */
  92327. freeze(): void;
  92328. /**
  92329. * Unlocks updates for the material
  92330. */
  92331. unfreeze(): void;
  92332. /**
  92333. * Specifies if the material is ready to be used
  92334. * @param mesh defines the mesh to check
  92335. * @param useInstances specifies if instances should be used
  92336. * @returns a boolean indicating if the material is ready to be used
  92337. */
  92338. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  92339. /**
  92340. * Specifies that the submesh is ready to be used
  92341. * @param mesh defines the mesh to check
  92342. * @param subMesh defines which submesh to check
  92343. * @param useInstances specifies that instances should be used
  92344. * @returns a boolean indicating that the submesh is ready or not
  92345. */
  92346. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  92347. /**
  92348. * Returns the material effect
  92349. * @returns the effect associated with the material
  92350. */
  92351. getEffect(): Nullable<Effect>;
  92352. /**
  92353. * Returns the current scene
  92354. * @returns a Scene
  92355. */
  92356. getScene(): Scene;
  92357. /**
  92358. * Specifies if the material will require alpha blending
  92359. * @returns a boolean specifying if alpha blending is needed
  92360. */
  92361. needAlphaBlending(): boolean;
  92362. /**
  92363. * Specifies if the mesh will require alpha blending
  92364. * @param mesh defines the mesh to check
  92365. * @returns a boolean specifying if alpha blending is needed for the mesh
  92366. */
  92367. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  92368. /**
  92369. * Specifies if this material should be rendered in alpha test mode
  92370. * @returns a boolean specifying if an alpha test is needed.
  92371. */
  92372. needAlphaTesting(): boolean;
  92373. /**
  92374. * Gets the texture used for the alpha test
  92375. * @returns the texture to use for alpha testing
  92376. */
  92377. getAlphaTestTexture(): Nullable<BaseTexture>;
  92378. /**
  92379. * Marks the material to indicate that it needs to be re-calculated
  92380. */
  92381. markDirty(): void;
  92382. /** @hidden */
  92383. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  92384. /**
  92385. * Binds the material to the mesh
  92386. * @param world defines the world transformation matrix
  92387. * @param mesh defines the mesh to bind the material to
  92388. */
  92389. bind(world: Matrix, mesh?: Mesh): void;
  92390. /**
  92391. * Binds the submesh to the material
  92392. * @param world defines the world transformation matrix
  92393. * @param mesh defines the mesh containing the submesh
  92394. * @param subMesh defines the submesh to bind the material to
  92395. */
  92396. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  92397. /**
  92398. * Binds the world matrix to the material
  92399. * @param world defines the world transformation matrix
  92400. */
  92401. bindOnlyWorldMatrix(world: Matrix): void;
  92402. /**
  92403. * Binds the scene's uniform buffer to the effect.
  92404. * @param effect defines the effect to bind to the scene uniform buffer
  92405. * @param sceneUbo defines the uniform buffer storing scene data
  92406. */
  92407. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  92408. /**
  92409. * Binds the view matrix to the effect
  92410. * @param effect defines the effect to bind the view matrix to
  92411. */
  92412. bindView(effect: Effect): void;
  92413. /**
  92414. * Binds the view projection matrix to the effect
  92415. * @param effect defines the effect to bind the view projection matrix to
  92416. */
  92417. bindViewProjection(effect: Effect): void;
  92418. /**
  92419. * Specifies if material alpha testing should be turned on for the mesh
  92420. * @param mesh defines the mesh to check
  92421. */
  92422. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  92423. /**
  92424. * Processes to execute after binding the material to a mesh
  92425. * @param mesh defines the rendered mesh
  92426. */
  92427. protected _afterBind(mesh?: Mesh): void;
  92428. /**
  92429. * Unbinds the material from the mesh
  92430. */
  92431. unbind(): void;
  92432. /**
  92433. * Gets the active textures from the material
  92434. * @returns an array of textures
  92435. */
  92436. getActiveTextures(): BaseTexture[];
  92437. /**
  92438. * Specifies if the material uses a texture
  92439. * @param texture defines the texture to check against the material
  92440. * @returns a boolean specifying if the material uses the texture
  92441. */
  92442. hasTexture(texture: BaseTexture): boolean;
  92443. /**
  92444. * Makes a duplicate of the material, and gives it a new name
  92445. * @param name defines the new name for the duplicated material
  92446. * @returns the cloned material
  92447. */
  92448. clone(name: string): Nullable<Material>;
  92449. /**
  92450. * Gets the meshes bound to the material
  92451. * @returns an array of meshes bound to the material
  92452. */
  92453. getBindedMeshes(): AbstractMesh[];
  92454. /**
  92455. * Force shader compilation
  92456. * @param mesh defines the mesh associated with this material
  92457. * @param onCompiled defines a function to execute once the material is compiled
  92458. * @param options defines the options to configure the compilation
  92459. * @param onError defines a function to execute if the material fails compiling
  92460. */
  92461. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  92462. /**
  92463. * Force shader compilation
  92464. * @param mesh defines the mesh that will use this material
  92465. * @param options defines additional options for compiling the shaders
  92466. * @returns a promise that resolves when the compilation completes
  92467. */
  92468. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  92469. private static readonly _AllDirtyCallBack;
  92470. private static readonly _ImageProcessingDirtyCallBack;
  92471. private static readonly _TextureDirtyCallBack;
  92472. private static readonly _FresnelDirtyCallBack;
  92473. private static readonly _MiscDirtyCallBack;
  92474. private static readonly _LightsDirtyCallBack;
  92475. private static readonly _AttributeDirtyCallBack;
  92476. private static _FresnelAndMiscDirtyCallBack;
  92477. private static _TextureAndMiscDirtyCallBack;
  92478. private static readonly _DirtyCallbackArray;
  92479. private static readonly _RunDirtyCallBacks;
  92480. /**
  92481. * Marks a define in the material to indicate that it needs to be re-computed
  92482. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  92483. */
  92484. markAsDirty(flag: number): void;
  92485. /**
  92486. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  92487. * @param func defines a function which checks material defines against the submeshes
  92488. */
  92489. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  92490. /**
  92491. * Indicates that we need to re-calculated for all submeshes
  92492. */
  92493. protected _markAllSubMeshesAsAllDirty(): void;
  92494. /**
  92495. * Indicates that image processing needs to be re-calculated for all submeshes
  92496. */
  92497. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  92498. /**
  92499. * Indicates that textures need to be re-calculated for all submeshes
  92500. */
  92501. protected _markAllSubMeshesAsTexturesDirty(): void;
  92502. /**
  92503. * Indicates that fresnel needs to be re-calculated for all submeshes
  92504. */
  92505. protected _markAllSubMeshesAsFresnelDirty(): void;
  92506. /**
  92507. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  92508. */
  92509. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  92510. /**
  92511. * Indicates that lights need to be re-calculated for all submeshes
  92512. */
  92513. protected _markAllSubMeshesAsLightsDirty(): void;
  92514. /**
  92515. * Indicates that attributes need to be re-calculated for all submeshes
  92516. */
  92517. protected _markAllSubMeshesAsAttributesDirty(): void;
  92518. /**
  92519. * Indicates that misc needs to be re-calculated for all submeshes
  92520. */
  92521. protected _markAllSubMeshesAsMiscDirty(): void;
  92522. /**
  92523. * Indicates that textures and misc need to be re-calculated for all submeshes
  92524. */
  92525. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  92526. /**
  92527. * Disposes the material
  92528. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92529. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  92530. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  92531. */
  92532. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  92533. /** @hidden */
  92534. private releaseVertexArrayObject;
  92535. /**
  92536. * Serializes this material
  92537. * @returns the serialized material object
  92538. */
  92539. serialize(): any;
  92540. /**
  92541. * Creates a material from parsed material data
  92542. * @param parsedMaterial defines parsed material data
  92543. * @param scene defines the hosting scene
  92544. * @param rootUrl defines the root URL to use to load textures
  92545. * @returns a new material
  92546. */
  92547. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  92548. }
  92549. }
  92550. declare module BABYLON {
  92551. /**
  92552. * A multi-material is used to apply different materials to different parts of the same object without the need of
  92553. * separate meshes. This can be use to improve performances.
  92554. * @see http://doc.babylonjs.com/how_to/multi_materials
  92555. */
  92556. export class MultiMaterial extends Material {
  92557. private _subMaterials;
  92558. /**
  92559. * Gets or Sets the list of Materials used within the multi material.
  92560. * They need to be ordered according to the submeshes order in the associated mesh
  92561. */
  92562. get subMaterials(): Nullable<Material>[];
  92563. set subMaterials(value: Nullable<Material>[]);
  92564. /**
  92565. * Function used to align with Node.getChildren()
  92566. * @returns the list of Materials used within the multi material
  92567. */
  92568. getChildren(): Nullable<Material>[];
  92569. /**
  92570. * Instantiates a new Multi Material
  92571. * A multi-material is used to apply different materials to different parts of the same object without the need of
  92572. * separate meshes. This can be use to improve performances.
  92573. * @see http://doc.babylonjs.com/how_to/multi_materials
  92574. * @param name Define the name in the scene
  92575. * @param scene Define the scene the material belongs to
  92576. */
  92577. constructor(name: string, scene: Scene);
  92578. private _hookArray;
  92579. /**
  92580. * Get one of the submaterial by its index in the submaterials array
  92581. * @param index The index to look the sub material at
  92582. * @returns The Material if the index has been defined
  92583. */
  92584. getSubMaterial(index: number): Nullable<Material>;
  92585. /**
  92586. * Get the list of active textures for the whole sub materials list.
  92587. * @returns All the textures that will be used during the rendering
  92588. */
  92589. getActiveTextures(): BaseTexture[];
  92590. /**
  92591. * Gets the current class name of the material e.g. "MultiMaterial"
  92592. * Mainly use in serialization.
  92593. * @returns the class name
  92594. */
  92595. getClassName(): string;
  92596. /**
  92597. * Checks if the material is ready to render the requested sub mesh
  92598. * @param mesh Define the mesh the submesh belongs to
  92599. * @param subMesh Define the sub mesh to look readyness for
  92600. * @param useInstances Define whether or not the material is used with instances
  92601. * @returns true if ready, otherwise false
  92602. */
  92603. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  92604. /**
  92605. * Clones the current material and its related sub materials
  92606. * @param name Define the name of the newly cloned material
  92607. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  92608. * @returns the cloned material
  92609. */
  92610. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  92611. /**
  92612. * Serializes the materials into a JSON representation.
  92613. * @returns the JSON representation
  92614. */
  92615. serialize(): any;
  92616. /**
  92617. * Dispose the material and release its associated resources
  92618. * @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)
  92619. * @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)
  92620. * @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)
  92621. */
  92622. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  92623. /**
  92624. * Creates a MultiMaterial from parsed MultiMaterial data.
  92625. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  92626. * @param scene defines the hosting scene
  92627. * @returns a new MultiMaterial
  92628. */
  92629. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  92630. }
  92631. }
  92632. declare module BABYLON {
  92633. /**
  92634. * Base class for submeshes
  92635. */
  92636. export class BaseSubMesh {
  92637. /** @hidden */
  92638. _materialDefines: Nullable<MaterialDefines>;
  92639. /** @hidden */
  92640. _materialEffect: Nullable<Effect>;
  92641. /**
  92642. * Gets material defines used by the effect associated to the sub mesh
  92643. */
  92644. get materialDefines(): Nullable<MaterialDefines>;
  92645. /**
  92646. * Sets material defines used by the effect associated to the sub mesh
  92647. */
  92648. set materialDefines(defines: Nullable<MaterialDefines>);
  92649. /**
  92650. * Gets associated effect
  92651. */
  92652. get effect(): Nullable<Effect>;
  92653. /**
  92654. * Sets associated effect (effect used to render this submesh)
  92655. * @param effect defines the effect to associate with
  92656. * @param defines defines the set of defines used to compile this effect
  92657. */
  92658. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  92659. }
  92660. /**
  92661. * Defines a subdivision inside a mesh
  92662. */
  92663. export class SubMesh extends BaseSubMesh implements ICullable {
  92664. /** the material index to use */
  92665. materialIndex: number;
  92666. /** vertex index start */
  92667. verticesStart: number;
  92668. /** vertices count */
  92669. verticesCount: number;
  92670. /** index start */
  92671. indexStart: number;
  92672. /** indices count */
  92673. indexCount: number;
  92674. /** @hidden */
  92675. _linesIndexCount: number;
  92676. private _mesh;
  92677. private _renderingMesh;
  92678. private _boundingInfo;
  92679. private _linesIndexBuffer;
  92680. /** @hidden */
  92681. _lastColliderWorldVertices: Nullable<Vector3[]>;
  92682. /** @hidden */
  92683. _trianglePlanes: Plane[];
  92684. /** @hidden */
  92685. _lastColliderTransformMatrix: Nullable<Matrix>;
  92686. /** @hidden */
  92687. _renderId: number;
  92688. /** @hidden */
  92689. _alphaIndex: number;
  92690. /** @hidden */
  92691. _distanceToCamera: number;
  92692. /** @hidden */
  92693. _id: number;
  92694. private _currentMaterial;
  92695. /**
  92696. * Add a new submesh to a mesh
  92697. * @param materialIndex defines the material index to use
  92698. * @param verticesStart defines vertex index start
  92699. * @param verticesCount defines vertices count
  92700. * @param indexStart defines index start
  92701. * @param indexCount defines indices count
  92702. * @param mesh defines the parent mesh
  92703. * @param renderingMesh defines an optional rendering mesh
  92704. * @param createBoundingBox defines if bounding box should be created for this submesh
  92705. * @returns the new submesh
  92706. */
  92707. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  92708. /**
  92709. * Creates a new submesh
  92710. * @param materialIndex defines the material index to use
  92711. * @param verticesStart defines vertex index start
  92712. * @param verticesCount defines vertices count
  92713. * @param indexStart defines index start
  92714. * @param indexCount defines indices count
  92715. * @param mesh defines the parent mesh
  92716. * @param renderingMesh defines an optional rendering mesh
  92717. * @param createBoundingBox defines if bounding box should be created for this submesh
  92718. */
  92719. constructor(
  92720. /** the material index to use */
  92721. materialIndex: number,
  92722. /** vertex index start */
  92723. verticesStart: number,
  92724. /** vertices count */
  92725. verticesCount: number,
  92726. /** index start */
  92727. indexStart: number,
  92728. /** indices count */
  92729. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  92730. /**
  92731. * Returns true if this submesh covers the entire parent mesh
  92732. * @ignorenaming
  92733. */
  92734. get IsGlobal(): boolean;
  92735. /**
  92736. * Returns the submesh BoudingInfo object
  92737. * @returns current bounding info (or mesh's one if the submesh is global)
  92738. */
  92739. getBoundingInfo(): BoundingInfo;
  92740. /**
  92741. * Sets the submesh BoundingInfo
  92742. * @param boundingInfo defines the new bounding info to use
  92743. * @returns the SubMesh
  92744. */
  92745. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  92746. /**
  92747. * Returns the mesh of the current submesh
  92748. * @return the parent mesh
  92749. */
  92750. getMesh(): AbstractMesh;
  92751. /**
  92752. * Returns the rendering mesh of the submesh
  92753. * @returns the rendering mesh (could be different from parent mesh)
  92754. */
  92755. getRenderingMesh(): Mesh;
  92756. /**
  92757. * Returns the submesh material
  92758. * @returns null or the current material
  92759. */
  92760. getMaterial(): Nullable<Material>;
  92761. /**
  92762. * Sets a new updated BoundingInfo object to the submesh
  92763. * @param data defines an optional position array to use to determine the bounding info
  92764. * @returns the SubMesh
  92765. */
  92766. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  92767. /** @hidden */
  92768. _checkCollision(collider: Collider): boolean;
  92769. /**
  92770. * Updates the submesh BoundingInfo
  92771. * @param world defines the world matrix to use to update the bounding info
  92772. * @returns the submesh
  92773. */
  92774. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  92775. /**
  92776. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  92777. * @param frustumPlanes defines the frustum planes
  92778. * @returns true if the submesh is intersecting with the frustum
  92779. */
  92780. isInFrustum(frustumPlanes: Plane[]): boolean;
  92781. /**
  92782. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  92783. * @param frustumPlanes defines the frustum planes
  92784. * @returns true if the submesh is inside the frustum
  92785. */
  92786. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92787. /**
  92788. * Renders the submesh
  92789. * @param enableAlphaMode defines if alpha needs to be used
  92790. * @returns the submesh
  92791. */
  92792. render(enableAlphaMode: boolean): SubMesh;
  92793. /**
  92794. * @hidden
  92795. */
  92796. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  92797. /**
  92798. * Checks if the submesh intersects with a ray
  92799. * @param ray defines the ray to test
  92800. * @returns true is the passed ray intersects the submesh bounding box
  92801. */
  92802. canIntersects(ray: Ray): boolean;
  92803. /**
  92804. * Intersects current submesh with a ray
  92805. * @param ray defines the ray to test
  92806. * @param positions defines mesh's positions array
  92807. * @param indices defines mesh's indices array
  92808. * @param fastCheck defines if only bounding info should be used
  92809. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92810. * @returns intersection info or null if no intersection
  92811. */
  92812. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  92813. /** @hidden */
  92814. private _intersectLines;
  92815. /** @hidden */
  92816. private _intersectUnIndexedLines;
  92817. /** @hidden */
  92818. private _intersectTriangles;
  92819. /** @hidden */
  92820. private _intersectUnIndexedTriangles;
  92821. /** @hidden */
  92822. _rebuild(): void;
  92823. /**
  92824. * Creates a new submesh from the passed mesh
  92825. * @param newMesh defines the new hosting mesh
  92826. * @param newRenderingMesh defines an optional rendering mesh
  92827. * @returns the new submesh
  92828. */
  92829. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  92830. /**
  92831. * Release associated resources
  92832. */
  92833. dispose(): void;
  92834. /**
  92835. * Gets the class name
  92836. * @returns the string "SubMesh".
  92837. */
  92838. getClassName(): string;
  92839. /**
  92840. * Creates a new submesh from indices data
  92841. * @param materialIndex the index of the main mesh material
  92842. * @param startIndex the index where to start the copy in the mesh indices array
  92843. * @param indexCount the number of indices to copy then from the startIndex
  92844. * @param mesh the main mesh to create the submesh from
  92845. * @param renderingMesh the optional rendering mesh
  92846. * @returns a new submesh
  92847. */
  92848. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  92849. }
  92850. }
  92851. declare module BABYLON {
  92852. /**
  92853. * Class used to represent data loading progression
  92854. */
  92855. export class SceneLoaderFlags {
  92856. private static _ForceFullSceneLoadingForIncremental;
  92857. private static _ShowLoadingScreen;
  92858. private static _CleanBoneMatrixWeights;
  92859. private static _loggingLevel;
  92860. /**
  92861. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  92862. */
  92863. static get ForceFullSceneLoadingForIncremental(): boolean;
  92864. static set ForceFullSceneLoadingForIncremental(value: boolean);
  92865. /**
  92866. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  92867. */
  92868. static get ShowLoadingScreen(): boolean;
  92869. static set ShowLoadingScreen(value: boolean);
  92870. /**
  92871. * Defines the current logging level (while loading the scene)
  92872. * @ignorenaming
  92873. */
  92874. static get loggingLevel(): number;
  92875. static set loggingLevel(value: number);
  92876. /**
  92877. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  92878. */
  92879. static get CleanBoneMatrixWeights(): boolean;
  92880. static set CleanBoneMatrixWeights(value: boolean);
  92881. }
  92882. }
  92883. declare module BABYLON {
  92884. /**
  92885. * Class used to store geometry data (vertex buffers + index buffer)
  92886. */
  92887. export class Geometry implements IGetSetVerticesData {
  92888. /**
  92889. * Gets or sets the ID of the geometry
  92890. */
  92891. id: string;
  92892. /**
  92893. * Gets or sets the unique ID of the geometry
  92894. */
  92895. uniqueId: number;
  92896. /**
  92897. * Gets the delay loading state of the geometry (none by default which means not delayed)
  92898. */
  92899. delayLoadState: number;
  92900. /**
  92901. * Gets the file containing the data to load when running in delay load state
  92902. */
  92903. delayLoadingFile: Nullable<string>;
  92904. /**
  92905. * Callback called when the geometry is updated
  92906. */
  92907. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  92908. private _scene;
  92909. private _engine;
  92910. private _meshes;
  92911. private _totalVertices;
  92912. /** @hidden */
  92913. _indices: IndicesArray;
  92914. /** @hidden */
  92915. _vertexBuffers: {
  92916. [key: string]: VertexBuffer;
  92917. };
  92918. private _isDisposed;
  92919. private _extend;
  92920. private _boundingBias;
  92921. /** @hidden */
  92922. _delayInfo: Array<string>;
  92923. private _indexBuffer;
  92924. private _indexBufferIsUpdatable;
  92925. /** @hidden */
  92926. _boundingInfo: Nullable<BoundingInfo>;
  92927. /** @hidden */
  92928. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  92929. /** @hidden */
  92930. _softwareSkinningFrameId: number;
  92931. private _vertexArrayObjects;
  92932. private _updatable;
  92933. /** @hidden */
  92934. _positions: Nullable<Vector3[]>;
  92935. /**
  92936. * 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
  92937. */
  92938. get boundingBias(): Vector2;
  92939. /**
  92940. * 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
  92941. */
  92942. set boundingBias(value: Vector2);
  92943. /**
  92944. * Static function used to attach a new empty geometry to a mesh
  92945. * @param mesh defines the mesh to attach the geometry to
  92946. * @returns the new Geometry
  92947. */
  92948. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  92949. /**
  92950. * Creates a new geometry
  92951. * @param id defines the unique ID
  92952. * @param scene defines the hosting scene
  92953. * @param vertexData defines the VertexData used to get geometry data
  92954. * @param updatable defines if geometry must be updatable (false by default)
  92955. * @param mesh defines the mesh that will be associated with the geometry
  92956. */
  92957. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  92958. /**
  92959. * Gets the current extend of the geometry
  92960. */
  92961. get extend(): {
  92962. minimum: Vector3;
  92963. maximum: Vector3;
  92964. };
  92965. /**
  92966. * Gets the hosting scene
  92967. * @returns the hosting Scene
  92968. */
  92969. getScene(): Scene;
  92970. /**
  92971. * Gets the hosting engine
  92972. * @returns the hosting Engine
  92973. */
  92974. getEngine(): Engine;
  92975. /**
  92976. * Defines if the geometry is ready to use
  92977. * @returns true if the geometry is ready to be used
  92978. */
  92979. isReady(): boolean;
  92980. /**
  92981. * Gets a value indicating that the geometry should not be serialized
  92982. */
  92983. get doNotSerialize(): boolean;
  92984. /** @hidden */
  92985. _rebuild(): void;
  92986. /**
  92987. * Affects all geometry data in one call
  92988. * @param vertexData defines the geometry data
  92989. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  92990. */
  92991. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  92992. /**
  92993. * Set specific vertex data
  92994. * @param kind defines the data kind (Position, normal, etc...)
  92995. * @param data defines the vertex data to use
  92996. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92997. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92998. */
  92999. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  93000. /**
  93001. * Removes a specific vertex data
  93002. * @param kind defines the data kind (Position, normal, etc...)
  93003. */
  93004. removeVerticesData(kind: string): void;
  93005. /**
  93006. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  93007. * @param buffer defines the vertex buffer to use
  93008. * @param totalVertices defines the total number of vertices for position kind (could be null)
  93009. */
  93010. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  93011. /**
  93012. * Update a specific vertex buffer
  93013. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  93014. * It will do nothing if the buffer is not updatable
  93015. * @param kind defines the data kind (Position, normal, etc...)
  93016. * @param data defines the data to use
  93017. * @param offset defines the offset in the target buffer where to store the data
  93018. * @param useBytes set to true if the offset is in bytes
  93019. */
  93020. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  93021. /**
  93022. * Update a specific vertex buffer
  93023. * This function will create a new buffer if the current one is not updatable
  93024. * @param kind defines the data kind (Position, normal, etc...)
  93025. * @param data defines the data to use
  93026. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  93027. */
  93028. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  93029. private _updateBoundingInfo;
  93030. /** @hidden */
  93031. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  93032. /**
  93033. * Gets total number of vertices
  93034. * @returns the total number of vertices
  93035. */
  93036. getTotalVertices(): number;
  93037. /**
  93038. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  93039. * @param kind defines the data kind (Position, normal, etc...)
  93040. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  93041. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93042. * @returns a float array containing vertex data
  93043. */
  93044. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93045. /**
  93046. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  93047. * @param kind defines the data kind (Position, normal, etc...)
  93048. * @returns true if the vertex buffer with the specified kind is updatable
  93049. */
  93050. isVertexBufferUpdatable(kind: string): boolean;
  93051. /**
  93052. * Gets a specific vertex buffer
  93053. * @param kind defines the data kind (Position, normal, etc...)
  93054. * @returns a VertexBuffer
  93055. */
  93056. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  93057. /**
  93058. * Returns all vertex buffers
  93059. * @return an object holding all vertex buffers indexed by kind
  93060. */
  93061. getVertexBuffers(): Nullable<{
  93062. [key: string]: VertexBuffer;
  93063. }>;
  93064. /**
  93065. * Gets a boolean indicating if specific vertex buffer is present
  93066. * @param kind defines the data kind (Position, normal, etc...)
  93067. * @returns true if data is present
  93068. */
  93069. isVerticesDataPresent(kind: string): boolean;
  93070. /**
  93071. * Gets a list of all attached data kinds (Position, normal, etc...)
  93072. * @returns a list of string containing all kinds
  93073. */
  93074. getVerticesDataKinds(): string[];
  93075. /**
  93076. * Update index buffer
  93077. * @param indices defines the indices to store in the index buffer
  93078. * @param offset defines the offset in the target buffer where to store the data
  93079. * @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)
  93080. */
  93081. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  93082. /**
  93083. * Creates a new index buffer
  93084. * @param indices defines the indices to store in the index buffer
  93085. * @param totalVertices defines the total number of vertices (could be null)
  93086. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  93087. */
  93088. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  93089. /**
  93090. * Return the total number of indices
  93091. * @returns the total number of indices
  93092. */
  93093. getTotalIndices(): number;
  93094. /**
  93095. * Gets the index buffer array
  93096. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  93097. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93098. * @returns the index buffer array
  93099. */
  93100. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93101. /**
  93102. * Gets the index buffer
  93103. * @return the index buffer
  93104. */
  93105. getIndexBuffer(): Nullable<DataBuffer>;
  93106. /** @hidden */
  93107. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  93108. /**
  93109. * Release the associated resources for a specific mesh
  93110. * @param mesh defines the source mesh
  93111. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  93112. */
  93113. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  93114. /**
  93115. * Apply current geometry to a given mesh
  93116. * @param mesh defines the mesh to apply geometry to
  93117. */
  93118. applyToMesh(mesh: Mesh): void;
  93119. private _updateExtend;
  93120. private _applyToMesh;
  93121. private notifyUpdate;
  93122. /**
  93123. * Load the geometry if it was flagged as delay loaded
  93124. * @param scene defines the hosting scene
  93125. * @param onLoaded defines a callback called when the geometry is loaded
  93126. */
  93127. load(scene: Scene, onLoaded?: () => void): void;
  93128. private _queueLoad;
  93129. /**
  93130. * Invert the geometry to move from a right handed system to a left handed one.
  93131. */
  93132. toLeftHanded(): void;
  93133. /** @hidden */
  93134. _resetPointsArrayCache(): void;
  93135. /** @hidden */
  93136. _generatePointsArray(): boolean;
  93137. /**
  93138. * Gets a value indicating if the geometry is disposed
  93139. * @returns true if the geometry was disposed
  93140. */
  93141. isDisposed(): boolean;
  93142. private _disposeVertexArrayObjects;
  93143. /**
  93144. * Free all associated resources
  93145. */
  93146. dispose(): void;
  93147. /**
  93148. * Clone the current geometry into a new geometry
  93149. * @param id defines the unique ID of the new geometry
  93150. * @returns a new geometry object
  93151. */
  93152. copy(id: string): Geometry;
  93153. /**
  93154. * Serialize the current geometry info (and not the vertices data) into a JSON object
  93155. * @return a JSON representation of the current geometry data (without the vertices data)
  93156. */
  93157. serialize(): any;
  93158. private toNumberArray;
  93159. /**
  93160. * Serialize all vertices data into a JSON oject
  93161. * @returns a JSON representation of the current geometry data
  93162. */
  93163. serializeVerticeData(): any;
  93164. /**
  93165. * Extracts a clone of a mesh geometry
  93166. * @param mesh defines the source mesh
  93167. * @param id defines the unique ID of the new geometry object
  93168. * @returns the new geometry object
  93169. */
  93170. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  93171. /**
  93172. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  93173. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93174. * Be aware Math.random() could cause collisions, but:
  93175. * "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"
  93176. * @returns a string containing a new GUID
  93177. */
  93178. static RandomId(): string;
  93179. /** @hidden */
  93180. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  93181. private static _CleanMatricesWeights;
  93182. /**
  93183. * Create a new geometry from persisted data (Using .babylon file format)
  93184. * @param parsedVertexData defines the persisted data
  93185. * @param scene defines the hosting scene
  93186. * @param rootUrl defines the root url to use to load assets (like delayed data)
  93187. * @returns the new geometry object
  93188. */
  93189. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  93190. }
  93191. }
  93192. declare module BABYLON {
  93193. /**
  93194. * Define an interface for all classes that will get and set the data on vertices
  93195. */
  93196. export interface IGetSetVerticesData {
  93197. /**
  93198. * Gets a boolean indicating if specific vertex data is present
  93199. * @param kind defines the vertex data kind to use
  93200. * @returns true is data kind is present
  93201. */
  93202. isVerticesDataPresent(kind: string): boolean;
  93203. /**
  93204. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  93205. * @param kind defines the data kind (Position, normal, etc...)
  93206. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  93207. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93208. * @returns a float array containing vertex data
  93209. */
  93210. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93211. /**
  93212. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93213. * @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.
  93214. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93215. * @returns the indices array or an empty array if the mesh has no geometry
  93216. */
  93217. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93218. /**
  93219. * Set specific vertex data
  93220. * @param kind defines the data kind (Position, normal, etc...)
  93221. * @param data defines the vertex data to use
  93222. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  93223. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  93224. */
  93225. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  93226. /**
  93227. * Update a specific associated vertex buffer
  93228. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93229. * - VertexBuffer.PositionKind
  93230. * - VertexBuffer.UVKind
  93231. * - VertexBuffer.UV2Kind
  93232. * - VertexBuffer.UV3Kind
  93233. * - VertexBuffer.UV4Kind
  93234. * - VertexBuffer.UV5Kind
  93235. * - VertexBuffer.UV6Kind
  93236. * - VertexBuffer.ColorKind
  93237. * - VertexBuffer.MatricesIndicesKind
  93238. * - VertexBuffer.MatricesIndicesExtraKind
  93239. * - VertexBuffer.MatricesWeightsKind
  93240. * - VertexBuffer.MatricesWeightsExtraKind
  93241. * @param data defines the data source
  93242. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  93243. * @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)
  93244. */
  93245. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  93246. /**
  93247. * Creates a new index buffer
  93248. * @param indices defines the indices to store in the index buffer
  93249. * @param totalVertices defines the total number of vertices (could be null)
  93250. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  93251. */
  93252. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  93253. }
  93254. /**
  93255. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  93256. */
  93257. export class VertexData {
  93258. /**
  93259. * Mesh side orientation : usually the external or front surface
  93260. */
  93261. static readonly FRONTSIDE: number;
  93262. /**
  93263. * Mesh side orientation : usually the internal or back surface
  93264. */
  93265. static readonly BACKSIDE: number;
  93266. /**
  93267. * Mesh side orientation : both internal and external or front and back surfaces
  93268. */
  93269. static readonly DOUBLESIDE: number;
  93270. /**
  93271. * Mesh side orientation : by default, `FRONTSIDE`
  93272. */
  93273. static readonly DEFAULTSIDE: number;
  93274. /**
  93275. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  93276. */
  93277. positions: Nullable<FloatArray>;
  93278. /**
  93279. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  93280. */
  93281. normals: Nullable<FloatArray>;
  93282. /**
  93283. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  93284. */
  93285. tangents: Nullable<FloatArray>;
  93286. /**
  93287. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93288. */
  93289. uvs: Nullable<FloatArray>;
  93290. /**
  93291. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93292. */
  93293. uvs2: Nullable<FloatArray>;
  93294. /**
  93295. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93296. */
  93297. uvs3: Nullable<FloatArray>;
  93298. /**
  93299. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93300. */
  93301. uvs4: Nullable<FloatArray>;
  93302. /**
  93303. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93304. */
  93305. uvs5: Nullable<FloatArray>;
  93306. /**
  93307. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93308. */
  93309. uvs6: Nullable<FloatArray>;
  93310. /**
  93311. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  93312. */
  93313. colors: Nullable<FloatArray>;
  93314. /**
  93315. * 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).
  93316. */
  93317. matricesIndices: Nullable<FloatArray>;
  93318. /**
  93319. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  93320. */
  93321. matricesWeights: Nullable<FloatArray>;
  93322. /**
  93323. * An array extending the number of possible indices
  93324. */
  93325. matricesIndicesExtra: Nullable<FloatArray>;
  93326. /**
  93327. * An array extending the number of possible weights when the number of indices is extended
  93328. */
  93329. matricesWeightsExtra: Nullable<FloatArray>;
  93330. /**
  93331. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  93332. */
  93333. indices: Nullable<IndicesArray>;
  93334. /**
  93335. * Uses the passed data array to set the set the values for the specified kind of data
  93336. * @param data a linear array of floating numbers
  93337. * @param kind the type of data that is being set, eg positions, colors etc
  93338. */
  93339. set(data: FloatArray, kind: string): void;
  93340. /**
  93341. * Associates the vertexData to the passed Mesh.
  93342. * Sets it as updatable or not (default `false`)
  93343. * @param mesh the mesh the vertexData is applied to
  93344. * @param updatable when used and having the value true allows new data to update the vertexData
  93345. * @returns the VertexData
  93346. */
  93347. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  93348. /**
  93349. * Associates the vertexData to the passed Geometry.
  93350. * Sets it as updatable or not (default `false`)
  93351. * @param geometry the geometry the vertexData is applied to
  93352. * @param updatable when used and having the value true allows new data to update the vertexData
  93353. * @returns VertexData
  93354. */
  93355. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  93356. /**
  93357. * Updates the associated mesh
  93358. * @param mesh the mesh to be updated
  93359. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  93360. * @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
  93361. * @returns VertexData
  93362. */
  93363. updateMesh(mesh: Mesh): VertexData;
  93364. /**
  93365. * Updates the associated geometry
  93366. * @param geometry the geometry to be updated
  93367. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  93368. * @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
  93369. * @returns VertexData.
  93370. */
  93371. updateGeometry(geometry: Geometry): VertexData;
  93372. private _applyTo;
  93373. private _update;
  93374. /**
  93375. * Transforms each position and each normal of the vertexData according to the passed Matrix
  93376. * @param matrix the transforming matrix
  93377. * @returns the VertexData
  93378. */
  93379. transform(matrix: Matrix): VertexData;
  93380. /**
  93381. * Merges the passed VertexData into the current one
  93382. * @param other the VertexData to be merged into the current one
  93383. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  93384. * @returns the modified VertexData
  93385. */
  93386. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  93387. private _mergeElement;
  93388. private _validate;
  93389. /**
  93390. * Serializes the VertexData
  93391. * @returns a serialized object
  93392. */
  93393. serialize(): any;
  93394. /**
  93395. * Extracts the vertexData from a mesh
  93396. * @param mesh the mesh from which to extract the VertexData
  93397. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  93398. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  93399. * @returns the object VertexData associated to the passed mesh
  93400. */
  93401. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  93402. /**
  93403. * Extracts the vertexData from the geometry
  93404. * @param geometry the geometry from which to extract the VertexData
  93405. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  93406. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  93407. * @returns the object VertexData associated to the passed mesh
  93408. */
  93409. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  93410. private static _ExtractFrom;
  93411. /**
  93412. * Creates the VertexData for a Ribbon
  93413. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  93414. * * pathArray array of paths, each of which an array of successive Vector3
  93415. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  93416. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  93417. * * 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
  93418. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93419. * * 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)
  93420. * * 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)
  93421. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  93422. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  93423. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  93424. * @returns the VertexData of the ribbon
  93425. */
  93426. static CreateRibbon(options: {
  93427. pathArray: Vector3[][];
  93428. closeArray?: boolean;
  93429. closePath?: boolean;
  93430. offset?: number;
  93431. sideOrientation?: number;
  93432. frontUVs?: Vector4;
  93433. backUVs?: Vector4;
  93434. invertUV?: boolean;
  93435. uvs?: Vector2[];
  93436. colors?: Color4[];
  93437. }): VertexData;
  93438. /**
  93439. * Creates the VertexData for a box
  93440. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93441. * * size sets the width, height and depth of the box to the value of size, optional default 1
  93442. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  93443. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  93444. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  93445. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  93446. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  93447. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93448. * * 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)
  93449. * * 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)
  93450. * @returns the VertexData of the box
  93451. */
  93452. static CreateBox(options: {
  93453. size?: number;
  93454. width?: number;
  93455. height?: number;
  93456. depth?: number;
  93457. faceUV?: Vector4[];
  93458. faceColors?: Color4[];
  93459. sideOrientation?: number;
  93460. frontUVs?: Vector4;
  93461. backUVs?: Vector4;
  93462. }): VertexData;
  93463. /**
  93464. * Creates the VertexData for a tiled box
  93465. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93466. * * faceTiles sets the pattern, tile size and number of tiles for a face
  93467. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  93468. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  93469. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93470. * @returns the VertexData of the box
  93471. */
  93472. static CreateTiledBox(options: {
  93473. pattern?: number;
  93474. width?: number;
  93475. height?: number;
  93476. depth?: number;
  93477. tileSize?: number;
  93478. tileWidth?: number;
  93479. tileHeight?: number;
  93480. alignHorizontal?: number;
  93481. alignVertical?: number;
  93482. faceUV?: Vector4[];
  93483. faceColors?: Color4[];
  93484. sideOrientation?: number;
  93485. }): VertexData;
  93486. /**
  93487. * Creates the VertexData for a tiled plane
  93488. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93489. * * pattern a limited pattern arrangement depending on the number
  93490. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  93491. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  93492. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  93493. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93494. * * 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)
  93495. * * 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)
  93496. * @returns the VertexData of the tiled plane
  93497. */
  93498. static CreateTiledPlane(options: {
  93499. pattern?: number;
  93500. tileSize?: number;
  93501. tileWidth?: number;
  93502. tileHeight?: number;
  93503. size?: number;
  93504. width?: number;
  93505. height?: number;
  93506. alignHorizontal?: number;
  93507. alignVertical?: number;
  93508. sideOrientation?: number;
  93509. frontUVs?: Vector4;
  93510. backUVs?: Vector4;
  93511. }): VertexData;
  93512. /**
  93513. * Creates the VertexData for an ellipsoid, defaults to a sphere
  93514. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93515. * * segments sets the number of horizontal strips optional, default 32
  93516. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  93517. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  93518. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  93519. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  93520. * * 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
  93521. * * 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
  93522. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93523. * * 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)
  93524. * * 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)
  93525. * @returns the VertexData of the ellipsoid
  93526. */
  93527. static CreateSphere(options: {
  93528. segments?: number;
  93529. diameter?: number;
  93530. diameterX?: number;
  93531. diameterY?: number;
  93532. diameterZ?: number;
  93533. arc?: number;
  93534. slice?: number;
  93535. sideOrientation?: number;
  93536. frontUVs?: Vector4;
  93537. backUVs?: Vector4;
  93538. }): VertexData;
  93539. /**
  93540. * Creates the VertexData for a cylinder, cone or prism
  93541. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93542. * * height sets the height (y direction) of the cylinder, optional, default 2
  93543. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  93544. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  93545. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  93546. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  93547. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  93548. * * 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
  93549. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93550. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93551. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  93552. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  93553. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93554. * * 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)
  93555. * * 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)
  93556. * @returns the VertexData of the cylinder, cone or prism
  93557. */
  93558. static CreateCylinder(options: {
  93559. height?: number;
  93560. diameterTop?: number;
  93561. diameterBottom?: number;
  93562. diameter?: number;
  93563. tessellation?: number;
  93564. subdivisions?: number;
  93565. arc?: number;
  93566. faceColors?: Color4[];
  93567. faceUV?: Vector4[];
  93568. hasRings?: boolean;
  93569. enclose?: boolean;
  93570. sideOrientation?: number;
  93571. frontUVs?: Vector4;
  93572. backUVs?: Vector4;
  93573. }): VertexData;
  93574. /**
  93575. * Creates the VertexData for a torus
  93576. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93577. * * diameter the diameter of the torus, optional default 1
  93578. * * thickness the diameter of the tube forming the torus, optional default 0.5
  93579. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  93580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93581. * * 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)
  93582. * * 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)
  93583. * @returns the VertexData of the torus
  93584. */
  93585. static CreateTorus(options: {
  93586. diameter?: number;
  93587. thickness?: number;
  93588. tessellation?: number;
  93589. sideOrientation?: number;
  93590. frontUVs?: Vector4;
  93591. backUVs?: Vector4;
  93592. }): VertexData;
  93593. /**
  93594. * Creates the VertexData of the LineSystem
  93595. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  93596. * - lines an array of lines, each line being an array of successive Vector3
  93597. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  93598. * @returns the VertexData of the LineSystem
  93599. */
  93600. static CreateLineSystem(options: {
  93601. lines: Vector3[][];
  93602. colors?: Nullable<Color4[][]>;
  93603. }): VertexData;
  93604. /**
  93605. * Create the VertexData for a DashedLines
  93606. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  93607. * - points an array successive Vector3
  93608. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  93609. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  93610. * - dashNb the intended total number of dashes, optional, default 200
  93611. * @returns the VertexData for the DashedLines
  93612. */
  93613. static CreateDashedLines(options: {
  93614. points: Vector3[];
  93615. dashSize?: number;
  93616. gapSize?: number;
  93617. dashNb?: number;
  93618. }): VertexData;
  93619. /**
  93620. * Creates the VertexData for a Ground
  93621. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  93622. * - width the width (x direction) of the ground, optional, default 1
  93623. * - height the height (z direction) of the ground, optional, default 1
  93624. * - subdivisions the number of subdivisions per side, optional, default 1
  93625. * @returns the VertexData of the Ground
  93626. */
  93627. static CreateGround(options: {
  93628. width?: number;
  93629. height?: number;
  93630. subdivisions?: number;
  93631. subdivisionsX?: number;
  93632. subdivisionsY?: number;
  93633. }): VertexData;
  93634. /**
  93635. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  93636. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  93637. * * xmin the ground minimum X coordinate, optional, default -1
  93638. * * zmin the ground minimum Z coordinate, optional, default -1
  93639. * * xmax the ground maximum X coordinate, optional, default 1
  93640. * * zmax the ground maximum Z coordinate, optional, default 1
  93641. * * 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}
  93642. * * 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}
  93643. * @returns the VertexData of the TiledGround
  93644. */
  93645. static CreateTiledGround(options: {
  93646. xmin: number;
  93647. zmin: number;
  93648. xmax: number;
  93649. zmax: number;
  93650. subdivisions?: {
  93651. w: number;
  93652. h: number;
  93653. };
  93654. precision?: {
  93655. w: number;
  93656. h: number;
  93657. };
  93658. }): VertexData;
  93659. /**
  93660. * Creates the VertexData of the Ground designed from a heightmap
  93661. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  93662. * * width the width (x direction) of the ground
  93663. * * height the height (z direction) of the ground
  93664. * * subdivisions the number of subdivisions per side
  93665. * * minHeight the minimum altitude on the ground, optional, default 0
  93666. * * maxHeight the maximum altitude on the ground, optional default 1
  93667. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  93668. * * buffer the array holding the image color data
  93669. * * bufferWidth the width of image
  93670. * * bufferHeight the height of image
  93671. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  93672. * @returns the VertexData of the Ground designed from a heightmap
  93673. */
  93674. static CreateGroundFromHeightMap(options: {
  93675. width: number;
  93676. height: number;
  93677. subdivisions: number;
  93678. minHeight: number;
  93679. maxHeight: number;
  93680. colorFilter: Color3;
  93681. buffer: Uint8Array;
  93682. bufferWidth: number;
  93683. bufferHeight: number;
  93684. alphaFilter: number;
  93685. }): VertexData;
  93686. /**
  93687. * Creates the VertexData for a Plane
  93688. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  93689. * * size sets the width and height of the plane to the value of size, optional default 1
  93690. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  93691. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  93692. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93693. * * 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)
  93694. * * 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)
  93695. * @returns the VertexData of the box
  93696. */
  93697. static CreatePlane(options: {
  93698. size?: number;
  93699. width?: number;
  93700. height?: number;
  93701. sideOrientation?: number;
  93702. frontUVs?: Vector4;
  93703. backUVs?: Vector4;
  93704. }): VertexData;
  93705. /**
  93706. * Creates the VertexData of the Disc or regular Polygon
  93707. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  93708. * * radius the radius of the disc, optional default 0.5
  93709. * * tessellation the number of polygon sides, optional, default 64
  93710. * * 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
  93711. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93712. * * 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)
  93713. * * 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)
  93714. * @returns the VertexData of the box
  93715. */
  93716. static CreateDisc(options: {
  93717. radius?: number;
  93718. tessellation?: number;
  93719. arc?: number;
  93720. sideOrientation?: number;
  93721. frontUVs?: Vector4;
  93722. backUVs?: Vector4;
  93723. }): VertexData;
  93724. /**
  93725. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  93726. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  93727. * @param polygon a mesh built from polygonTriangulation.build()
  93728. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93729. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93730. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93731. * @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)
  93732. * @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)
  93733. * @returns the VertexData of the Polygon
  93734. */
  93735. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  93736. /**
  93737. * Creates the VertexData of the IcoSphere
  93738. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  93739. * * radius the radius of the IcoSphere, optional default 1
  93740. * * radiusX allows stretching in the x direction, optional, default radius
  93741. * * radiusY allows stretching in the y direction, optional, default radius
  93742. * * radiusZ allows stretching in the z direction, optional, default radius
  93743. * * flat when true creates a flat shaded mesh, optional, default true
  93744. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93745. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93746. * * 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)
  93747. * * 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)
  93748. * @returns the VertexData of the IcoSphere
  93749. */
  93750. static CreateIcoSphere(options: {
  93751. radius?: number;
  93752. radiusX?: number;
  93753. radiusY?: number;
  93754. radiusZ?: number;
  93755. flat?: boolean;
  93756. subdivisions?: number;
  93757. sideOrientation?: number;
  93758. frontUVs?: Vector4;
  93759. backUVs?: Vector4;
  93760. }): VertexData;
  93761. /**
  93762. * Creates the VertexData for a Polyhedron
  93763. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  93764. * * type provided types are:
  93765. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  93766. * * 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)
  93767. * * size the size of the IcoSphere, optional default 1
  93768. * * sizeX allows stretching in the x direction, optional, default size
  93769. * * sizeY allows stretching in the y direction, optional, default size
  93770. * * sizeZ allows stretching in the z direction, optional, default size
  93771. * * 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
  93772. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93773. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93774. * * flat when true creates a flat shaded mesh, optional, default true
  93775. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93776. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93777. * * 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)
  93778. * * 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)
  93779. * @returns the VertexData of the Polyhedron
  93780. */
  93781. static CreatePolyhedron(options: {
  93782. type?: number;
  93783. size?: number;
  93784. sizeX?: number;
  93785. sizeY?: number;
  93786. sizeZ?: number;
  93787. custom?: any;
  93788. faceUV?: Vector4[];
  93789. faceColors?: Color4[];
  93790. flat?: boolean;
  93791. sideOrientation?: number;
  93792. frontUVs?: Vector4;
  93793. backUVs?: Vector4;
  93794. }): VertexData;
  93795. /**
  93796. * Creates the VertexData for a TorusKnot
  93797. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  93798. * * radius the radius of the torus knot, optional, default 2
  93799. * * tube the thickness of the tube, optional, default 0.5
  93800. * * radialSegments the number of sides on each tube segments, optional, default 32
  93801. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  93802. * * p the number of windings around the z axis, optional, default 2
  93803. * * q the number of windings around the x axis, optional, default 3
  93804. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93805. * * 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)
  93806. * * 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)
  93807. * @returns the VertexData of the Torus Knot
  93808. */
  93809. static CreateTorusKnot(options: {
  93810. radius?: number;
  93811. tube?: number;
  93812. radialSegments?: number;
  93813. tubularSegments?: number;
  93814. p?: number;
  93815. q?: number;
  93816. sideOrientation?: number;
  93817. frontUVs?: Vector4;
  93818. backUVs?: Vector4;
  93819. }): VertexData;
  93820. /**
  93821. * Compute normals for given positions and indices
  93822. * @param positions an array of vertex positions, [...., x, y, z, ......]
  93823. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  93824. * @param normals an array of vertex normals, [...., x, y, z, ......]
  93825. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  93826. * * facetNormals : optional array of facet normals (vector3)
  93827. * * facetPositions : optional array of facet positions (vector3)
  93828. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  93829. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  93830. * * bInfo : optional bounding info, required for facetPartitioning computation
  93831. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  93832. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  93833. * * useRightHandedSystem: optional boolean to for right handed system computation
  93834. * * depthSort : optional boolean to enable the facet depth sort computation
  93835. * * distanceTo : optional Vector3 to compute the facet depth from this location
  93836. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  93837. */
  93838. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  93839. facetNormals?: any;
  93840. facetPositions?: any;
  93841. facetPartitioning?: any;
  93842. ratio?: number;
  93843. bInfo?: any;
  93844. bbSize?: Vector3;
  93845. subDiv?: any;
  93846. useRightHandedSystem?: boolean;
  93847. depthSort?: boolean;
  93848. distanceTo?: Vector3;
  93849. depthSortedFacets?: any;
  93850. }): void;
  93851. /** @hidden */
  93852. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  93853. /**
  93854. * Applies VertexData created from the imported parameters to the geometry
  93855. * @param parsedVertexData the parsed data from an imported file
  93856. * @param geometry the geometry to apply the VertexData to
  93857. */
  93858. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  93859. }
  93860. }
  93861. declare module BABYLON {
  93862. /**
  93863. * Defines a target to use with MorphTargetManager
  93864. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93865. */
  93866. export class MorphTarget implements IAnimatable {
  93867. /** defines the name of the target */
  93868. name: string;
  93869. /**
  93870. * Gets or sets the list of animations
  93871. */
  93872. animations: Animation[];
  93873. private _scene;
  93874. private _positions;
  93875. private _normals;
  93876. private _tangents;
  93877. private _uvs;
  93878. private _influence;
  93879. private _uniqueId;
  93880. /**
  93881. * Observable raised when the influence changes
  93882. */
  93883. onInfluenceChanged: Observable<boolean>;
  93884. /** @hidden */
  93885. _onDataLayoutChanged: Observable<void>;
  93886. /**
  93887. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  93888. */
  93889. get influence(): number;
  93890. set influence(influence: number);
  93891. /**
  93892. * Gets or sets the id of the morph Target
  93893. */
  93894. id: string;
  93895. private _animationPropertiesOverride;
  93896. /**
  93897. * Gets or sets the animation properties override
  93898. */
  93899. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93900. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93901. /**
  93902. * Creates a new MorphTarget
  93903. * @param name defines the name of the target
  93904. * @param influence defines the influence to use
  93905. * @param scene defines the scene the morphtarget belongs to
  93906. */
  93907. constructor(
  93908. /** defines the name of the target */
  93909. name: string, influence?: number, scene?: Nullable<Scene>);
  93910. /**
  93911. * Gets the unique ID of this manager
  93912. */
  93913. get uniqueId(): number;
  93914. /**
  93915. * Gets a boolean defining if the target contains position data
  93916. */
  93917. get hasPositions(): boolean;
  93918. /**
  93919. * Gets a boolean defining if the target contains normal data
  93920. */
  93921. get hasNormals(): boolean;
  93922. /**
  93923. * Gets a boolean defining if the target contains tangent data
  93924. */
  93925. get hasTangents(): boolean;
  93926. /**
  93927. * Gets a boolean defining if the target contains texture coordinates data
  93928. */
  93929. get hasUVs(): boolean;
  93930. /**
  93931. * Affects position data to this target
  93932. * @param data defines the position data to use
  93933. */
  93934. setPositions(data: Nullable<FloatArray>): void;
  93935. /**
  93936. * Gets the position data stored in this target
  93937. * @returns a FloatArray containing the position data (or null if not present)
  93938. */
  93939. getPositions(): Nullable<FloatArray>;
  93940. /**
  93941. * Affects normal data to this target
  93942. * @param data defines the normal data to use
  93943. */
  93944. setNormals(data: Nullable<FloatArray>): void;
  93945. /**
  93946. * Gets the normal data stored in this target
  93947. * @returns a FloatArray containing the normal data (or null if not present)
  93948. */
  93949. getNormals(): Nullable<FloatArray>;
  93950. /**
  93951. * Affects tangent data to this target
  93952. * @param data defines the tangent data to use
  93953. */
  93954. setTangents(data: Nullable<FloatArray>): void;
  93955. /**
  93956. * Gets the tangent data stored in this target
  93957. * @returns a FloatArray containing the tangent data (or null if not present)
  93958. */
  93959. getTangents(): Nullable<FloatArray>;
  93960. /**
  93961. * Affects texture coordinates data to this target
  93962. * @param data defines the texture coordinates data to use
  93963. */
  93964. setUVs(data: Nullable<FloatArray>): void;
  93965. /**
  93966. * Gets the texture coordinates data stored in this target
  93967. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  93968. */
  93969. getUVs(): Nullable<FloatArray>;
  93970. /**
  93971. * Clone the current target
  93972. * @returns a new MorphTarget
  93973. */
  93974. clone(): MorphTarget;
  93975. /**
  93976. * Serializes the current target into a Serialization object
  93977. * @returns the serialized object
  93978. */
  93979. serialize(): any;
  93980. /**
  93981. * Returns the string "MorphTarget"
  93982. * @returns "MorphTarget"
  93983. */
  93984. getClassName(): string;
  93985. /**
  93986. * Creates a new target from serialized data
  93987. * @param serializationObject defines the serialized data to use
  93988. * @returns a new MorphTarget
  93989. */
  93990. static Parse(serializationObject: any): MorphTarget;
  93991. /**
  93992. * Creates a MorphTarget from mesh data
  93993. * @param mesh defines the source mesh
  93994. * @param name defines the name to use for the new target
  93995. * @param influence defines the influence to attach to the target
  93996. * @returns a new MorphTarget
  93997. */
  93998. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  93999. }
  94000. }
  94001. declare module BABYLON {
  94002. /**
  94003. * This class is used to deform meshes using morphing between different targets
  94004. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  94005. */
  94006. export class MorphTargetManager {
  94007. private _targets;
  94008. private _targetInfluenceChangedObservers;
  94009. private _targetDataLayoutChangedObservers;
  94010. private _activeTargets;
  94011. private _scene;
  94012. private _influences;
  94013. private _supportsNormals;
  94014. private _supportsTangents;
  94015. private _supportsUVs;
  94016. private _vertexCount;
  94017. private _uniqueId;
  94018. private _tempInfluences;
  94019. /**
  94020. * Gets or sets a boolean indicating if normals must be morphed
  94021. */
  94022. enableNormalMorphing: boolean;
  94023. /**
  94024. * Gets or sets a boolean indicating if tangents must be morphed
  94025. */
  94026. enableTangentMorphing: boolean;
  94027. /**
  94028. * Gets or sets a boolean indicating if UV must be morphed
  94029. */
  94030. enableUVMorphing: boolean;
  94031. /**
  94032. * Creates a new MorphTargetManager
  94033. * @param scene defines the current scene
  94034. */
  94035. constructor(scene?: Nullable<Scene>);
  94036. /**
  94037. * Gets the unique ID of this manager
  94038. */
  94039. get uniqueId(): number;
  94040. /**
  94041. * Gets the number of vertices handled by this manager
  94042. */
  94043. get vertexCount(): number;
  94044. /**
  94045. * Gets a boolean indicating if this manager supports morphing of normals
  94046. */
  94047. get supportsNormals(): boolean;
  94048. /**
  94049. * Gets a boolean indicating if this manager supports morphing of tangents
  94050. */
  94051. get supportsTangents(): boolean;
  94052. /**
  94053. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  94054. */
  94055. get supportsUVs(): boolean;
  94056. /**
  94057. * Gets the number of targets stored in this manager
  94058. */
  94059. get numTargets(): number;
  94060. /**
  94061. * Gets the number of influencers (ie. the number of targets with influences > 0)
  94062. */
  94063. get numInfluencers(): number;
  94064. /**
  94065. * Gets the list of influences (one per target)
  94066. */
  94067. get influences(): Float32Array;
  94068. /**
  94069. * Gets the active target at specified index. An active target is a target with an influence > 0
  94070. * @param index defines the index to check
  94071. * @returns the requested target
  94072. */
  94073. getActiveTarget(index: number): MorphTarget;
  94074. /**
  94075. * Gets the target at specified index
  94076. * @param index defines the index to check
  94077. * @returns the requested target
  94078. */
  94079. getTarget(index: number): MorphTarget;
  94080. /**
  94081. * Add a new target to this manager
  94082. * @param target defines the target to add
  94083. */
  94084. addTarget(target: MorphTarget): void;
  94085. /**
  94086. * Removes a target from the manager
  94087. * @param target defines the target to remove
  94088. */
  94089. removeTarget(target: MorphTarget): void;
  94090. /**
  94091. * Clone the current manager
  94092. * @returns a new MorphTargetManager
  94093. */
  94094. clone(): MorphTargetManager;
  94095. /**
  94096. * Serializes the current manager into a Serialization object
  94097. * @returns the serialized object
  94098. */
  94099. serialize(): any;
  94100. private _syncActiveTargets;
  94101. /**
  94102. * Syncrhonize the targets with all the meshes using this morph target manager
  94103. */
  94104. synchronize(): void;
  94105. /**
  94106. * Creates a new MorphTargetManager from serialized data
  94107. * @param serializationObject defines the serialized data
  94108. * @param scene defines the hosting scene
  94109. * @returns the new MorphTargetManager
  94110. */
  94111. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  94112. }
  94113. }
  94114. declare module BABYLON {
  94115. /**
  94116. * Class used to represent a specific level of detail of a mesh
  94117. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  94118. */
  94119. export class MeshLODLevel {
  94120. /** Defines the distance where this level should start being displayed */
  94121. distance: number;
  94122. /** Defines the mesh to use to render this level */
  94123. mesh: Nullable<Mesh>;
  94124. /**
  94125. * Creates a new LOD level
  94126. * @param distance defines the distance where this level should star being displayed
  94127. * @param mesh defines the mesh to use to render this level
  94128. */
  94129. constructor(
  94130. /** Defines the distance where this level should start being displayed */
  94131. distance: number,
  94132. /** Defines the mesh to use to render this level */
  94133. mesh: Nullable<Mesh>);
  94134. }
  94135. }
  94136. declare module BABYLON {
  94137. /**
  94138. * Mesh representing the gorund
  94139. */
  94140. export class GroundMesh extends Mesh {
  94141. /** If octree should be generated */
  94142. generateOctree: boolean;
  94143. private _heightQuads;
  94144. /** @hidden */
  94145. _subdivisionsX: number;
  94146. /** @hidden */
  94147. _subdivisionsY: number;
  94148. /** @hidden */
  94149. _width: number;
  94150. /** @hidden */
  94151. _height: number;
  94152. /** @hidden */
  94153. _minX: number;
  94154. /** @hidden */
  94155. _maxX: number;
  94156. /** @hidden */
  94157. _minZ: number;
  94158. /** @hidden */
  94159. _maxZ: number;
  94160. constructor(name: string, scene: Scene);
  94161. /**
  94162. * "GroundMesh"
  94163. * @returns "GroundMesh"
  94164. */
  94165. getClassName(): string;
  94166. /**
  94167. * The minimum of x and y subdivisions
  94168. */
  94169. get subdivisions(): number;
  94170. /**
  94171. * X subdivisions
  94172. */
  94173. get subdivisionsX(): number;
  94174. /**
  94175. * Y subdivisions
  94176. */
  94177. get subdivisionsY(): number;
  94178. /**
  94179. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  94180. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  94181. * @param chunksCount the number of subdivisions for x and y
  94182. * @param octreeBlocksSize (Default: 32)
  94183. */
  94184. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  94185. /**
  94186. * Returns a height (y) value in the Worl system :
  94187. * the ground altitude at the coordinates (x, z) expressed in the World system.
  94188. * @param x x coordinate
  94189. * @param z z coordinate
  94190. * @returns the ground y position if (x, z) are outside the ground surface.
  94191. */
  94192. getHeightAtCoordinates(x: number, z: number): number;
  94193. /**
  94194. * Returns a normalized vector (Vector3) orthogonal to the ground
  94195. * at the ground coordinates (x, z) expressed in the World system.
  94196. * @param x x coordinate
  94197. * @param z z coordinate
  94198. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  94199. */
  94200. getNormalAtCoordinates(x: number, z: number): Vector3;
  94201. /**
  94202. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  94203. * at the ground coordinates (x, z) expressed in the World system.
  94204. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  94205. * @param x x coordinate
  94206. * @param z z coordinate
  94207. * @param ref vector to store the result
  94208. * @returns the GroundMesh.
  94209. */
  94210. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  94211. /**
  94212. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  94213. * if the ground has been updated.
  94214. * This can be used in the render loop.
  94215. * @returns the GroundMesh.
  94216. */
  94217. updateCoordinateHeights(): GroundMesh;
  94218. private _getFacetAt;
  94219. private _initHeightQuads;
  94220. private _computeHeightQuads;
  94221. /**
  94222. * Serializes this ground mesh
  94223. * @param serializationObject object to write serialization to
  94224. */
  94225. serialize(serializationObject: any): void;
  94226. /**
  94227. * Parses a serialized ground mesh
  94228. * @param parsedMesh the serialized mesh
  94229. * @param scene the scene to create the ground mesh in
  94230. * @returns the created ground mesh
  94231. */
  94232. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  94233. }
  94234. }
  94235. declare module BABYLON {
  94236. /**
  94237. * Interface for Physics-Joint data
  94238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94239. */
  94240. export interface PhysicsJointData {
  94241. /**
  94242. * The main pivot of the joint
  94243. */
  94244. mainPivot?: Vector3;
  94245. /**
  94246. * The connected pivot of the joint
  94247. */
  94248. connectedPivot?: Vector3;
  94249. /**
  94250. * The main axis of the joint
  94251. */
  94252. mainAxis?: Vector3;
  94253. /**
  94254. * The connected axis of the joint
  94255. */
  94256. connectedAxis?: Vector3;
  94257. /**
  94258. * The collision of the joint
  94259. */
  94260. collision?: boolean;
  94261. /**
  94262. * Native Oimo/Cannon/Energy data
  94263. */
  94264. nativeParams?: any;
  94265. }
  94266. /**
  94267. * This is a holder class for the physics joint created by the physics plugin
  94268. * It holds a set of functions to control the underlying joint
  94269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94270. */
  94271. export class PhysicsJoint {
  94272. /**
  94273. * The type of the physics joint
  94274. */
  94275. type: number;
  94276. /**
  94277. * The data for the physics joint
  94278. */
  94279. jointData: PhysicsJointData;
  94280. private _physicsJoint;
  94281. protected _physicsPlugin: IPhysicsEnginePlugin;
  94282. /**
  94283. * Initializes the physics joint
  94284. * @param type The type of the physics joint
  94285. * @param jointData The data for the physics joint
  94286. */
  94287. constructor(
  94288. /**
  94289. * The type of the physics joint
  94290. */
  94291. type: number,
  94292. /**
  94293. * The data for the physics joint
  94294. */
  94295. jointData: PhysicsJointData);
  94296. /**
  94297. * Gets the physics joint
  94298. */
  94299. get physicsJoint(): any;
  94300. /**
  94301. * Sets the physics joint
  94302. */
  94303. set physicsJoint(newJoint: any);
  94304. /**
  94305. * Sets the physics plugin
  94306. */
  94307. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  94308. /**
  94309. * Execute a function that is physics-plugin specific.
  94310. * @param {Function} func the function that will be executed.
  94311. * It accepts two parameters: the physics world and the physics joint
  94312. */
  94313. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  94314. /**
  94315. * Distance-Joint type
  94316. */
  94317. static DistanceJoint: number;
  94318. /**
  94319. * Hinge-Joint type
  94320. */
  94321. static HingeJoint: number;
  94322. /**
  94323. * Ball-and-Socket joint type
  94324. */
  94325. static BallAndSocketJoint: number;
  94326. /**
  94327. * Wheel-Joint type
  94328. */
  94329. static WheelJoint: number;
  94330. /**
  94331. * Slider-Joint type
  94332. */
  94333. static SliderJoint: number;
  94334. /**
  94335. * Prismatic-Joint type
  94336. */
  94337. static PrismaticJoint: number;
  94338. /**
  94339. * Universal-Joint type
  94340. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  94341. */
  94342. static UniversalJoint: number;
  94343. /**
  94344. * Hinge-Joint 2 type
  94345. */
  94346. static Hinge2Joint: number;
  94347. /**
  94348. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  94349. */
  94350. static PointToPointJoint: number;
  94351. /**
  94352. * Spring-Joint type
  94353. */
  94354. static SpringJoint: number;
  94355. /**
  94356. * Lock-Joint type
  94357. */
  94358. static LockJoint: number;
  94359. }
  94360. /**
  94361. * A class representing a physics distance joint
  94362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94363. */
  94364. export class DistanceJoint extends PhysicsJoint {
  94365. /**
  94366. *
  94367. * @param jointData The data for the Distance-Joint
  94368. */
  94369. constructor(jointData: DistanceJointData);
  94370. /**
  94371. * Update the predefined distance.
  94372. * @param maxDistance The maximum preferred distance
  94373. * @param minDistance The minimum preferred distance
  94374. */
  94375. updateDistance(maxDistance: number, minDistance?: number): void;
  94376. }
  94377. /**
  94378. * Represents a Motor-Enabled Joint
  94379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94380. */
  94381. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  94382. /**
  94383. * Initializes the Motor-Enabled Joint
  94384. * @param type The type of the joint
  94385. * @param jointData The physica joint data for the joint
  94386. */
  94387. constructor(type: number, jointData: PhysicsJointData);
  94388. /**
  94389. * Set the motor values.
  94390. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94391. * @param force the force to apply
  94392. * @param 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 single physics Hinge-Joint
  94405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94406. */
  94407. export class HingeJoint extends MotorEnabledJoint {
  94408. /**
  94409. * Initializes the Hinge-Joint
  94410. * @param jointData The joint data for the Hinge-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} force the force to apply
  94417. * @param {number} maxForce max force for this motor.
  94418. */
  94419. setMotor(force?: number, maxForce?: number): void;
  94420. /**
  94421. * Set the motor's limits.
  94422. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94423. * @param upperLimit The upper limit of the motor
  94424. * @param lowerLimit The lower limit of the motor
  94425. */
  94426. setLimit(upperLimit: number, lowerLimit?: number): void;
  94427. }
  94428. /**
  94429. * This class represents a dual hinge physics joint (same as wheel joint)
  94430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94431. */
  94432. export class Hinge2Joint extends MotorEnabledJoint {
  94433. /**
  94434. * Initializes the Hinge2-Joint
  94435. * @param jointData The joint data for the Hinge2-Joint
  94436. */
  94437. constructor(jointData: PhysicsJointData);
  94438. /**
  94439. * Set the motor values.
  94440. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94441. * @param {number} targetSpeed the speed the motor is to reach
  94442. * @param {number} maxForce max force for this motor.
  94443. * @param {motorIndex} the motor's index, 0 or 1.
  94444. */
  94445. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  94446. /**
  94447. * Set the motor limits.
  94448. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94449. * @param {number} upperLimit the upper limit
  94450. * @param {number} lowerLimit lower limit
  94451. * @param {motorIndex} the motor's index, 0 or 1.
  94452. */
  94453. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  94454. }
  94455. /**
  94456. * Interface for a motor enabled joint
  94457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94458. */
  94459. export interface IMotorEnabledJoint {
  94460. /**
  94461. * Physics joint
  94462. */
  94463. physicsJoint: any;
  94464. /**
  94465. * Sets the motor of the motor-enabled joint
  94466. * @param force The force of the motor
  94467. * @param maxForce The maximum force of the motor
  94468. * @param motorIndex The index of the motor
  94469. */
  94470. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  94471. /**
  94472. * Sets the limit of the motor
  94473. * @param upperLimit The upper limit of the motor
  94474. * @param lowerLimit The lower limit of the motor
  94475. * @param motorIndex The index of the motor
  94476. */
  94477. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  94478. }
  94479. /**
  94480. * Joint data for a Distance-Joint
  94481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94482. */
  94483. export interface DistanceJointData extends PhysicsJointData {
  94484. /**
  94485. * Max distance the 2 joint objects can be apart
  94486. */
  94487. maxDistance: number;
  94488. }
  94489. /**
  94490. * Joint data from a spring joint
  94491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94492. */
  94493. export interface SpringJointData extends PhysicsJointData {
  94494. /**
  94495. * Length of the spring
  94496. */
  94497. length: number;
  94498. /**
  94499. * Stiffness of the spring
  94500. */
  94501. stiffness: number;
  94502. /**
  94503. * Damping of the spring
  94504. */
  94505. damping: number;
  94506. /** this callback will be called when applying the force to the impostors. */
  94507. forceApplicationCallback: () => void;
  94508. }
  94509. }
  94510. declare module BABYLON {
  94511. /**
  94512. * Holds the data for the raycast result
  94513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94514. */
  94515. export class PhysicsRaycastResult {
  94516. private _hasHit;
  94517. private _hitDistance;
  94518. private _hitNormalWorld;
  94519. private _hitPointWorld;
  94520. private _rayFromWorld;
  94521. private _rayToWorld;
  94522. /**
  94523. * Gets if there was a hit
  94524. */
  94525. get hasHit(): boolean;
  94526. /**
  94527. * Gets the distance from the hit
  94528. */
  94529. get hitDistance(): number;
  94530. /**
  94531. * Gets the hit normal/direction in the world
  94532. */
  94533. get hitNormalWorld(): Vector3;
  94534. /**
  94535. * Gets the hit point in the world
  94536. */
  94537. get hitPointWorld(): Vector3;
  94538. /**
  94539. * Gets the ray "start point" of the ray in the world
  94540. */
  94541. get rayFromWorld(): Vector3;
  94542. /**
  94543. * Gets the ray "end point" of the ray in the world
  94544. */
  94545. get rayToWorld(): Vector3;
  94546. /**
  94547. * Sets the hit data (normal & point in world space)
  94548. * @param hitNormalWorld defines the normal in world space
  94549. * @param hitPointWorld defines the point in world space
  94550. */
  94551. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  94552. /**
  94553. * Sets the distance from the start point to the hit point
  94554. * @param distance
  94555. */
  94556. setHitDistance(distance: number): void;
  94557. /**
  94558. * Calculates the distance manually
  94559. */
  94560. calculateHitDistance(): void;
  94561. /**
  94562. * Resets all the values to default
  94563. * @param from The from point on world space
  94564. * @param to The to point on world space
  94565. */
  94566. reset(from?: Vector3, to?: Vector3): void;
  94567. }
  94568. /**
  94569. * Interface for the size containing width and height
  94570. */
  94571. interface IXYZ {
  94572. /**
  94573. * X
  94574. */
  94575. x: number;
  94576. /**
  94577. * Y
  94578. */
  94579. y: number;
  94580. /**
  94581. * Z
  94582. */
  94583. z: number;
  94584. }
  94585. }
  94586. declare module BABYLON {
  94587. /**
  94588. * Interface used to describe a physics joint
  94589. */
  94590. export interface PhysicsImpostorJoint {
  94591. /** Defines the main impostor to which the joint is linked */
  94592. mainImpostor: PhysicsImpostor;
  94593. /** Defines the impostor that is connected to the main impostor using this joint */
  94594. connectedImpostor: PhysicsImpostor;
  94595. /** Defines the joint itself */
  94596. joint: PhysicsJoint;
  94597. }
  94598. /** @hidden */
  94599. export interface IPhysicsEnginePlugin {
  94600. world: any;
  94601. name: string;
  94602. setGravity(gravity: Vector3): void;
  94603. setTimeStep(timeStep: number): void;
  94604. getTimeStep(): number;
  94605. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  94606. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  94607. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  94608. generatePhysicsBody(impostor: PhysicsImpostor): void;
  94609. removePhysicsBody(impostor: PhysicsImpostor): void;
  94610. generateJoint(joint: PhysicsImpostorJoint): void;
  94611. removeJoint(joint: PhysicsImpostorJoint): void;
  94612. isSupported(): boolean;
  94613. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  94614. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  94615. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  94616. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  94617. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  94618. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  94619. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  94620. getBodyMass(impostor: PhysicsImpostor): number;
  94621. getBodyFriction(impostor: PhysicsImpostor): number;
  94622. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  94623. getBodyRestitution(impostor: PhysicsImpostor): number;
  94624. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  94625. getBodyPressure?(impostor: PhysicsImpostor): number;
  94626. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  94627. getBodyStiffness?(impostor: PhysicsImpostor): number;
  94628. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  94629. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  94630. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  94631. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  94632. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  94633. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  94634. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  94635. sleepBody(impostor: PhysicsImpostor): void;
  94636. wakeUpBody(impostor: PhysicsImpostor): void;
  94637. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  94638. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  94639. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  94640. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  94641. getRadius(impostor: PhysicsImpostor): number;
  94642. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  94643. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  94644. dispose(): void;
  94645. }
  94646. /**
  94647. * Interface used to define a physics engine
  94648. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  94649. */
  94650. export interface IPhysicsEngine {
  94651. /**
  94652. * Gets the gravity vector used by the simulation
  94653. */
  94654. gravity: Vector3;
  94655. /**
  94656. * Sets the gravity vector used by the simulation
  94657. * @param gravity defines the gravity vector to use
  94658. */
  94659. setGravity(gravity: Vector3): void;
  94660. /**
  94661. * Set the time step of the physics engine.
  94662. * Default is 1/60.
  94663. * To slow it down, enter 1/600 for example.
  94664. * To speed it up, 1/30
  94665. * @param newTimeStep the new timestep to apply to this world.
  94666. */
  94667. setTimeStep(newTimeStep: number): void;
  94668. /**
  94669. * Get the time step of the physics engine.
  94670. * @returns the current time step
  94671. */
  94672. getTimeStep(): number;
  94673. /**
  94674. * Set the sub time step of the physics engine.
  94675. * Default is 0 meaning there is no sub steps
  94676. * To increase physics resolution precision, set a small value (like 1 ms)
  94677. * @param subTimeStep defines the new sub timestep used for physics resolution.
  94678. */
  94679. setSubTimeStep(subTimeStep: number): void;
  94680. /**
  94681. * Get the sub time step of the physics engine.
  94682. * @returns the current sub time step
  94683. */
  94684. getSubTimeStep(): number;
  94685. /**
  94686. * Release all resources
  94687. */
  94688. dispose(): void;
  94689. /**
  94690. * Gets the name of the current physics plugin
  94691. * @returns the name of the plugin
  94692. */
  94693. getPhysicsPluginName(): string;
  94694. /**
  94695. * Adding a new impostor for the impostor tracking.
  94696. * This will be done by the impostor itself.
  94697. * @param impostor the impostor to add
  94698. */
  94699. addImpostor(impostor: PhysicsImpostor): void;
  94700. /**
  94701. * Remove an impostor from the engine.
  94702. * This impostor and its mesh will not longer be updated by the physics engine.
  94703. * @param impostor the impostor to remove
  94704. */
  94705. removeImpostor(impostor: PhysicsImpostor): void;
  94706. /**
  94707. * Add a joint to the physics engine
  94708. * @param mainImpostor defines the main impostor to which the joint is added.
  94709. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  94710. * @param joint defines the joint that will connect both impostors.
  94711. */
  94712. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  94713. /**
  94714. * Removes a joint from the simulation
  94715. * @param mainImpostor defines the impostor used with the joint
  94716. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  94717. * @param joint defines the joint to remove
  94718. */
  94719. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  94720. /**
  94721. * Gets the current plugin used to run the simulation
  94722. * @returns current plugin
  94723. */
  94724. getPhysicsPlugin(): IPhysicsEnginePlugin;
  94725. /**
  94726. * Gets the list of physic impostors
  94727. * @returns an array of PhysicsImpostor
  94728. */
  94729. getImpostors(): Array<PhysicsImpostor>;
  94730. /**
  94731. * Gets the impostor for a physics enabled object
  94732. * @param object defines the object impersonated by the impostor
  94733. * @returns the PhysicsImpostor or null if not found
  94734. */
  94735. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94736. /**
  94737. * Gets the impostor for a physics body object
  94738. * @param body defines physics body used by the impostor
  94739. * @returns the PhysicsImpostor or null if not found
  94740. */
  94741. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  94742. /**
  94743. * Does a raycast in the physics world
  94744. * @param from when should the ray start?
  94745. * @param to when should the ray end?
  94746. * @returns PhysicsRaycastResult
  94747. */
  94748. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  94749. /**
  94750. * Called by the scene. No need to call it.
  94751. * @param delta defines the timespam between frames
  94752. */
  94753. _step(delta: number): void;
  94754. }
  94755. }
  94756. declare module BABYLON {
  94757. /**
  94758. * The interface for the physics imposter parameters
  94759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94760. */
  94761. export interface PhysicsImpostorParameters {
  94762. /**
  94763. * The mass of the physics imposter
  94764. */
  94765. mass: number;
  94766. /**
  94767. * The friction of the physics imposter
  94768. */
  94769. friction?: number;
  94770. /**
  94771. * The coefficient of restitution of the physics imposter
  94772. */
  94773. restitution?: number;
  94774. /**
  94775. * The native options of the physics imposter
  94776. */
  94777. nativeOptions?: any;
  94778. /**
  94779. * Specifies if the parent should be ignored
  94780. */
  94781. ignoreParent?: boolean;
  94782. /**
  94783. * Specifies if bi-directional transformations should be disabled
  94784. */
  94785. disableBidirectionalTransformation?: boolean;
  94786. /**
  94787. * The pressure inside the physics imposter, soft object only
  94788. */
  94789. pressure?: number;
  94790. /**
  94791. * The stiffness the physics imposter, soft object only
  94792. */
  94793. stiffness?: number;
  94794. /**
  94795. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  94796. */
  94797. velocityIterations?: number;
  94798. /**
  94799. * The number of iterations used in maintaining consistent vertex positions, soft object only
  94800. */
  94801. positionIterations?: number;
  94802. /**
  94803. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  94804. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  94805. * Add to fix multiple points
  94806. */
  94807. fixedPoints?: number;
  94808. /**
  94809. * The collision margin around a soft object
  94810. */
  94811. margin?: number;
  94812. /**
  94813. * The collision margin around a soft object
  94814. */
  94815. damping?: number;
  94816. /**
  94817. * The path for a rope based on an extrusion
  94818. */
  94819. path?: any;
  94820. /**
  94821. * The shape of an extrusion used for a rope based on an extrusion
  94822. */
  94823. shape?: any;
  94824. }
  94825. /**
  94826. * Interface for a physics-enabled object
  94827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94828. */
  94829. export interface IPhysicsEnabledObject {
  94830. /**
  94831. * The position of the physics-enabled object
  94832. */
  94833. position: Vector3;
  94834. /**
  94835. * The rotation of the physics-enabled object
  94836. */
  94837. rotationQuaternion: Nullable<Quaternion>;
  94838. /**
  94839. * The scale of the physics-enabled object
  94840. */
  94841. scaling: Vector3;
  94842. /**
  94843. * The rotation of the physics-enabled object
  94844. */
  94845. rotation?: Vector3;
  94846. /**
  94847. * The parent of the physics-enabled object
  94848. */
  94849. parent?: any;
  94850. /**
  94851. * The bounding info of the physics-enabled object
  94852. * @returns The bounding info of the physics-enabled object
  94853. */
  94854. getBoundingInfo(): BoundingInfo;
  94855. /**
  94856. * Computes the world matrix
  94857. * @param force Specifies if the world matrix should be computed by force
  94858. * @returns A world matrix
  94859. */
  94860. computeWorldMatrix(force: boolean): Matrix;
  94861. /**
  94862. * Gets the world matrix
  94863. * @returns A world matrix
  94864. */
  94865. getWorldMatrix?(): Matrix;
  94866. /**
  94867. * Gets the child meshes
  94868. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  94869. * @returns An array of abstract meshes
  94870. */
  94871. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  94872. /**
  94873. * Gets the vertex data
  94874. * @param kind The type of vertex data
  94875. * @returns A nullable array of numbers, or a float32 array
  94876. */
  94877. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  94878. /**
  94879. * Gets the indices from the mesh
  94880. * @returns A nullable array of index arrays
  94881. */
  94882. getIndices?(): Nullable<IndicesArray>;
  94883. /**
  94884. * Gets the scene from the mesh
  94885. * @returns the indices array or null
  94886. */
  94887. getScene?(): Scene;
  94888. /**
  94889. * Gets the absolute position from the mesh
  94890. * @returns the absolute position
  94891. */
  94892. getAbsolutePosition(): Vector3;
  94893. /**
  94894. * Gets the absolute pivot point from the mesh
  94895. * @returns the absolute pivot point
  94896. */
  94897. getAbsolutePivotPoint(): Vector3;
  94898. /**
  94899. * Rotates the mesh
  94900. * @param axis The axis of rotation
  94901. * @param amount The amount of rotation
  94902. * @param space The space of the rotation
  94903. * @returns The rotation transform node
  94904. */
  94905. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94906. /**
  94907. * Translates the mesh
  94908. * @param axis The axis of translation
  94909. * @param distance The distance of translation
  94910. * @param space The space of the translation
  94911. * @returns The transform node
  94912. */
  94913. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94914. /**
  94915. * Sets the absolute position of the mesh
  94916. * @param absolutePosition The absolute position of the mesh
  94917. * @returns The transform node
  94918. */
  94919. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94920. /**
  94921. * Gets the class name of the mesh
  94922. * @returns The class name
  94923. */
  94924. getClassName(): string;
  94925. }
  94926. /**
  94927. * Represents a physics imposter
  94928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94929. */
  94930. export class PhysicsImpostor {
  94931. /**
  94932. * The physics-enabled object used as the physics imposter
  94933. */
  94934. object: IPhysicsEnabledObject;
  94935. /**
  94936. * The type of the physics imposter
  94937. */
  94938. type: number;
  94939. private _options;
  94940. private _scene?;
  94941. /**
  94942. * The default object size of the imposter
  94943. */
  94944. static DEFAULT_OBJECT_SIZE: Vector3;
  94945. /**
  94946. * The identity quaternion of the imposter
  94947. */
  94948. static IDENTITY_QUATERNION: Quaternion;
  94949. /** @hidden */
  94950. _pluginData: any;
  94951. private _physicsEngine;
  94952. private _physicsBody;
  94953. private _bodyUpdateRequired;
  94954. private _onBeforePhysicsStepCallbacks;
  94955. private _onAfterPhysicsStepCallbacks;
  94956. /** @hidden */
  94957. _onPhysicsCollideCallbacks: Array<{
  94958. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  94959. otherImpostors: Array<PhysicsImpostor>;
  94960. }>;
  94961. private _deltaPosition;
  94962. private _deltaRotation;
  94963. private _deltaRotationConjugated;
  94964. /** @hidden */
  94965. _isFromLine: boolean;
  94966. private _parent;
  94967. private _isDisposed;
  94968. private static _tmpVecs;
  94969. private static _tmpQuat;
  94970. /**
  94971. * Specifies if the physics imposter is disposed
  94972. */
  94973. get isDisposed(): boolean;
  94974. /**
  94975. * Gets the mass of the physics imposter
  94976. */
  94977. get mass(): number;
  94978. set mass(value: number);
  94979. /**
  94980. * Gets the coefficient of friction
  94981. */
  94982. get friction(): number;
  94983. /**
  94984. * Sets the coefficient of friction
  94985. */
  94986. set friction(value: number);
  94987. /**
  94988. * Gets the coefficient of restitution
  94989. */
  94990. get restitution(): number;
  94991. /**
  94992. * Sets the coefficient of restitution
  94993. */
  94994. set restitution(value: number);
  94995. /**
  94996. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  94997. */
  94998. get pressure(): number;
  94999. /**
  95000. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  95001. */
  95002. set pressure(value: number);
  95003. /**
  95004. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  95005. */
  95006. get stiffness(): number;
  95007. /**
  95008. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  95009. */
  95010. set stiffness(value: number);
  95011. /**
  95012. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  95013. */
  95014. get velocityIterations(): number;
  95015. /**
  95016. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  95017. */
  95018. set velocityIterations(value: number);
  95019. /**
  95020. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  95021. */
  95022. get positionIterations(): number;
  95023. /**
  95024. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  95025. */
  95026. set positionIterations(value: number);
  95027. /**
  95028. * The unique id of the physics imposter
  95029. * set by the physics engine when adding this impostor to the array
  95030. */
  95031. uniqueId: number;
  95032. /**
  95033. * @hidden
  95034. */
  95035. soft: boolean;
  95036. /**
  95037. * @hidden
  95038. */
  95039. segments: number;
  95040. private _joints;
  95041. /**
  95042. * Initializes the physics imposter
  95043. * @param object The physics-enabled object used as the physics imposter
  95044. * @param type The type of the physics imposter
  95045. * @param _options The options for the physics imposter
  95046. * @param _scene The Babylon scene
  95047. */
  95048. constructor(
  95049. /**
  95050. * The physics-enabled object used as the physics imposter
  95051. */
  95052. object: IPhysicsEnabledObject,
  95053. /**
  95054. * The type of the physics imposter
  95055. */
  95056. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  95057. /**
  95058. * This function will completly initialize this impostor.
  95059. * It will create a new body - but only if this mesh has no parent.
  95060. * If it has, this impostor will not be used other than to define the impostor
  95061. * of the child mesh.
  95062. * @hidden
  95063. */
  95064. _init(): void;
  95065. private _getPhysicsParent;
  95066. /**
  95067. * Should a new body be generated.
  95068. * @returns boolean specifying if body initialization is required
  95069. */
  95070. isBodyInitRequired(): boolean;
  95071. /**
  95072. * Sets the updated scaling
  95073. * @param updated Specifies if the scaling is updated
  95074. */
  95075. setScalingUpdated(): void;
  95076. /**
  95077. * Force a regeneration of this or the parent's impostor's body.
  95078. * Use under cautious - This will remove all joints already implemented.
  95079. */
  95080. forceUpdate(): void;
  95081. /**
  95082. * Gets the body that holds this impostor. Either its own, or its parent.
  95083. */
  95084. get physicsBody(): any;
  95085. /**
  95086. * Get the parent of the physics imposter
  95087. * @returns Physics imposter or null
  95088. */
  95089. get parent(): Nullable<PhysicsImpostor>;
  95090. /**
  95091. * Sets the parent of the physics imposter
  95092. */
  95093. set parent(value: Nullable<PhysicsImpostor>);
  95094. /**
  95095. * Set the physics body. Used mainly by the physics engine/plugin
  95096. */
  95097. set physicsBody(physicsBody: any);
  95098. /**
  95099. * Resets the update flags
  95100. */
  95101. resetUpdateFlags(): void;
  95102. /**
  95103. * Gets the object extend size
  95104. * @returns the object extend size
  95105. */
  95106. getObjectExtendSize(): Vector3;
  95107. /**
  95108. * Gets the object center
  95109. * @returns The object center
  95110. */
  95111. getObjectCenter(): Vector3;
  95112. /**
  95113. * Get a specific parametes from the options parameter
  95114. * @param paramName The object parameter name
  95115. * @returns The object parameter
  95116. */
  95117. getParam(paramName: string): any;
  95118. /**
  95119. * Sets a specific parameter in the options given to the physics plugin
  95120. * @param paramName The parameter name
  95121. * @param value The value of the parameter
  95122. */
  95123. setParam(paramName: string, value: number): void;
  95124. /**
  95125. * Specifically change the body's mass option. Won't recreate the physics body object
  95126. * @param mass The mass of the physics imposter
  95127. */
  95128. setMass(mass: number): void;
  95129. /**
  95130. * Gets the linear velocity
  95131. * @returns linear velocity or null
  95132. */
  95133. getLinearVelocity(): Nullable<Vector3>;
  95134. /**
  95135. * Sets the linear velocity
  95136. * @param velocity linear velocity or null
  95137. */
  95138. setLinearVelocity(velocity: Nullable<Vector3>): void;
  95139. /**
  95140. * Gets the angular velocity
  95141. * @returns angular velocity or null
  95142. */
  95143. getAngularVelocity(): Nullable<Vector3>;
  95144. /**
  95145. * Sets the angular velocity
  95146. * @param velocity The velocity or null
  95147. */
  95148. setAngularVelocity(velocity: Nullable<Vector3>): void;
  95149. /**
  95150. * Execute a function with the physics plugin native code
  95151. * Provide a function the will have two variables - the world object and the physics body object
  95152. * @param func The function to execute with the physics plugin native code
  95153. */
  95154. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  95155. /**
  95156. * Register a function that will be executed before the physics world is stepping forward
  95157. * @param func The function to execute before the physics world is stepped forward
  95158. */
  95159. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  95160. /**
  95161. * Unregister a function that will be executed before the physics world is stepping forward
  95162. * @param func The function to execute before the physics world is stepped forward
  95163. */
  95164. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  95165. /**
  95166. * Register a function that will be executed after the physics step
  95167. * @param func The function to execute after physics step
  95168. */
  95169. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  95170. /**
  95171. * Unregisters a function that will be executed after the physics step
  95172. * @param func The function to execute after physics step
  95173. */
  95174. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  95175. /**
  95176. * register a function that will be executed when this impostor collides against a different body
  95177. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  95178. * @param func Callback that is executed on collision
  95179. */
  95180. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  95181. /**
  95182. * Unregisters the physics imposter on contact
  95183. * @param collideAgainst The physics object to collide against
  95184. * @param func Callback to execute on collision
  95185. */
  95186. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  95187. private _tmpQuat;
  95188. private _tmpQuat2;
  95189. /**
  95190. * Get the parent rotation
  95191. * @returns The parent rotation
  95192. */
  95193. getParentsRotation(): Quaternion;
  95194. /**
  95195. * this function is executed by the physics engine.
  95196. */
  95197. beforeStep: () => void;
  95198. /**
  95199. * this function is executed by the physics engine
  95200. */
  95201. afterStep: () => void;
  95202. /**
  95203. * Legacy collision detection event support
  95204. */
  95205. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  95206. /**
  95207. * event and body object due to cannon's event-based architecture.
  95208. */
  95209. onCollide: (e: {
  95210. body: any;
  95211. }) => void;
  95212. /**
  95213. * Apply a force
  95214. * @param force The force to apply
  95215. * @param contactPoint The contact point for the force
  95216. * @returns The physics imposter
  95217. */
  95218. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  95219. /**
  95220. * Apply an impulse
  95221. * @param force The impulse force
  95222. * @param contactPoint The contact point for the impulse force
  95223. * @returns The physics imposter
  95224. */
  95225. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  95226. /**
  95227. * A help function to create a joint
  95228. * @param otherImpostor A physics imposter used to create a joint
  95229. * @param jointType The type of joint
  95230. * @param jointData The data for the joint
  95231. * @returns The physics imposter
  95232. */
  95233. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  95234. /**
  95235. * Add a joint to this impostor with a different impostor
  95236. * @param otherImpostor A physics imposter used to add a joint
  95237. * @param joint The joint to add
  95238. * @returns The physics imposter
  95239. */
  95240. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  95241. /**
  95242. * Add an anchor to a cloth impostor
  95243. * @param otherImpostor rigid impostor to anchor to
  95244. * @param width ratio across width from 0 to 1
  95245. * @param height ratio up height from 0 to 1
  95246. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  95247. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  95248. * @returns impostor the soft imposter
  95249. */
  95250. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  95251. /**
  95252. * Add a hook to a rope impostor
  95253. * @param otherImpostor rigid impostor to anchor to
  95254. * @param length ratio across rope from 0 to 1
  95255. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  95256. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  95257. * @returns impostor the rope imposter
  95258. */
  95259. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  95260. /**
  95261. * Will keep this body still, in a sleep mode.
  95262. * @returns the physics imposter
  95263. */
  95264. sleep(): PhysicsImpostor;
  95265. /**
  95266. * Wake the body up.
  95267. * @returns The physics imposter
  95268. */
  95269. wakeUp(): PhysicsImpostor;
  95270. /**
  95271. * Clones the physics imposter
  95272. * @param newObject The physics imposter clones to this physics-enabled object
  95273. * @returns A nullable physics imposter
  95274. */
  95275. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  95276. /**
  95277. * Disposes the physics imposter
  95278. */
  95279. dispose(): void;
  95280. /**
  95281. * Sets the delta position
  95282. * @param position The delta position amount
  95283. */
  95284. setDeltaPosition(position: Vector3): void;
  95285. /**
  95286. * Sets the delta rotation
  95287. * @param rotation The delta rotation amount
  95288. */
  95289. setDeltaRotation(rotation: Quaternion): void;
  95290. /**
  95291. * Gets the box size of the physics imposter and stores the result in the input parameter
  95292. * @param result Stores the box size
  95293. * @returns The physics imposter
  95294. */
  95295. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  95296. /**
  95297. * Gets the radius of the physics imposter
  95298. * @returns Radius of the physics imposter
  95299. */
  95300. getRadius(): number;
  95301. /**
  95302. * Sync a bone with this impostor
  95303. * @param bone The bone to sync to the impostor.
  95304. * @param boneMesh The mesh that the bone is influencing.
  95305. * @param jointPivot The pivot of the joint / bone in local space.
  95306. * @param distToJoint Optional distance from the impostor to the joint.
  95307. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  95308. */
  95309. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  95310. /**
  95311. * Sync impostor to a bone
  95312. * @param bone The bone that the impostor will be synced to.
  95313. * @param boneMesh The mesh that the bone is influencing.
  95314. * @param jointPivot The pivot of the joint / bone in local space.
  95315. * @param distToJoint Optional distance from the impostor to the joint.
  95316. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  95317. * @param boneAxis Optional vector3 axis the bone is aligned with
  95318. */
  95319. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  95320. /**
  95321. * No-Imposter type
  95322. */
  95323. static NoImpostor: number;
  95324. /**
  95325. * Sphere-Imposter type
  95326. */
  95327. static SphereImpostor: number;
  95328. /**
  95329. * Box-Imposter type
  95330. */
  95331. static BoxImpostor: number;
  95332. /**
  95333. * Plane-Imposter type
  95334. */
  95335. static PlaneImpostor: number;
  95336. /**
  95337. * Mesh-imposter type
  95338. */
  95339. static MeshImpostor: number;
  95340. /**
  95341. * Capsule-Impostor type (Ammo.js plugin only)
  95342. */
  95343. static CapsuleImpostor: number;
  95344. /**
  95345. * Cylinder-Imposter type
  95346. */
  95347. static CylinderImpostor: number;
  95348. /**
  95349. * Particle-Imposter type
  95350. */
  95351. static ParticleImpostor: number;
  95352. /**
  95353. * Heightmap-Imposter type
  95354. */
  95355. static HeightmapImpostor: number;
  95356. /**
  95357. * ConvexHull-Impostor type (Ammo.js plugin only)
  95358. */
  95359. static ConvexHullImpostor: number;
  95360. /**
  95361. * Custom-Imposter type (Ammo.js plugin only)
  95362. */
  95363. static CustomImpostor: number;
  95364. /**
  95365. * Rope-Imposter type
  95366. */
  95367. static RopeImpostor: number;
  95368. /**
  95369. * Cloth-Imposter type
  95370. */
  95371. static ClothImpostor: number;
  95372. /**
  95373. * Softbody-Imposter type
  95374. */
  95375. static SoftbodyImpostor: number;
  95376. }
  95377. }
  95378. declare module BABYLON {
  95379. /**
  95380. * @hidden
  95381. **/
  95382. export class _CreationDataStorage {
  95383. closePath?: boolean;
  95384. closeArray?: boolean;
  95385. idx: number[];
  95386. dashSize: number;
  95387. gapSize: number;
  95388. path3D: Path3D;
  95389. pathArray: Vector3[][];
  95390. arc: number;
  95391. radius: number;
  95392. cap: number;
  95393. tessellation: number;
  95394. }
  95395. /**
  95396. * @hidden
  95397. **/
  95398. class _InstanceDataStorage {
  95399. visibleInstances: any;
  95400. batchCache: _InstancesBatch;
  95401. instancesBufferSize: number;
  95402. instancesBuffer: Nullable<Buffer>;
  95403. instancesData: Float32Array;
  95404. overridenInstanceCount: number;
  95405. isFrozen: boolean;
  95406. previousBatch: Nullable<_InstancesBatch>;
  95407. hardwareInstancedRendering: boolean;
  95408. sideOrientation: number;
  95409. manualUpdate: boolean;
  95410. }
  95411. /**
  95412. * @hidden
  95413. **/
  95414. export class _InstancesBatch {
  95415. mustReturn: boolean;
  95416. visibleInstances: Nullable<InstancedMesh[]>[];
  95417. renderSelf: boolean[];
  95418. hardwareInstancedRendering: boolean[];
  95419. }
  95420. /**
  95421. * Class used to represent renderable models
  95422. */
  95423. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  95424. /**
  95425. * Mesh side orientation : usually the external or front surface
  95426. */
  95427. static readonly FRONTSIDE: number;
  95428. /**
  95429. * Mesh side orientation : usually the internal or back surface
  95430. */
  95431. static readonly BACKSIDE: number;
  95432. /**
  95433. * Mesh side orientation : both internal and external or front and back surfaces
  95434. */
  95435. static readonly DOUBLESIDE: number;
  95436. /**
  95437. * Mesh side orientation : by default, `FRONTSIDE`
  95438. */
  95439. static readonly DEFAULTSIDE: number;
  95440. /**
  95441. * Mesh cap setting : no cap
  95442. */
  95443. static readonly NO_CAP: number;
  95444. /**
  95445. * Mesh cap setting : one cap at the beginning of the mesh
  95446. */
  95447. static readonly CAP_START: number;
  95448. /**
  95449. * Mesh cap setting : one cap at the end of the mesh
  95450. */
  95451. static readonly CAP_END: number;
  95452. /**
  95453. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  95454. */
  95455. static readonly CAP_ALL: number;
  95456. /**
  95457. * Mesh pattern setting : no flip or rotate
  95458. */
  95459. static readonly NO_FLIP: number;
  95460. /**
  95461. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  95462. */
  95463. static readonly FLIP_TILE: number;
  95464. /**
  95465. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  95466. */
  95467. static readonly ROTATE_TILE: number;
  95468. /**
  95469. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  95470. */
  95471. static readonly FLIP_ROW: number;
  95472. /**
  95473. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  95474. */
  95475. static readonly ROTATE_ROW: number;
  95476. /**
  95477. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  95478. */
  95479. static readonly FLIP_N_ROTATE_TILE: number;
  95480. /**
  95481. * Mesh pattern setting : rotate pattern and rotate
  95482. */
  95483. static readonly FLIP_N_ROTATE_ROW: number;
  95484. /**
  95485. * Mesh tile positioning : part tiles same on left/right or top/bottom
  95486. */
  95487. static readonly CENTER: number;
  95488. /**
  95489. * Mesh tile positioning : part tiles on left
  95490. */
  95491. static readonly LEFT: number;
  95492. /**
  95493. * Mesh tile positioning : part tiles on right
  95494. */
  95495. static readonly RIGHT: number;
  95496. /**
  95497. * Mesh tile positioning : part tiles on top
  95498. */
  95499. static readonly TOP: number;
  95500. /**
  95501. * Mesh tile positioning : part tiles on bottom
  95502. */
  95503. static readonly BOTTOM: number;
  95504. /**
  95505. * Gets the default side orientation.
  95506. * @param orientation the orientation to value to attempt to get
  95507. * @returns the default orientation
  95508. * @hidden
  95509. */
  95510. static _GetDefaultSideOrientation(orientation?: number): number;
  95511. private _internalMeshDataInfo;
  95512. /**
  95513. * An event triggered before rendering the mesh
  95514. */
  95515. get onBeforeRenderObservable(): Observable<Mesh>;
  95516. /**
  95517. * An event triggered before binding the mesh
  95518. */
  95519. get onBeforeBindObservable(): Observable<Mesh>;
  95520. /**
  95521. * An event triggered after rendering the mesh
  95522. */
  95523. get onAfterRenderObservable(): Observable<Mesh>;
  95524. /**
  95525. * An event triggered before drawing the mesh
  95526. */
  95527. get onBeforeDrawObservable(): Observable<Mesh>;
  95528. private _onBeforeDrawObserver;
  95529. /**
  95530. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  95531. */
  95532. set onBeforeDraw(callback: () => void);
  95533. get hasInstances(): boolean;
  95534. /**
  95535. * Gets the delay loading state of the mesh (when delay loading is turned on)
  95536. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  95537. */
  95538. delayLoadState: number;
  95539. /**
  95540. * Gets the list of instances created from this mesh
  95541. * it is not supposed to be modified manually.
  95542. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  95543. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  95544. */
  95545. instances: InstancedMesh[];
  95546. /**
  95547. * Gets the file containing delay loading data for this mesh
  95548. */
  95549. delayLoadingFile: string;
  95550. /** @hidden */
  95551. _binaryInfo: any;
  95552. /**
  95553. * User defined function used to change how LOD level selection is done
  95554. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  95555. */
  95556. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  95557. /**
  95558. * Gets or sets the morph target manager
  95559. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95560. */
  95561. get morphTargetManager(): Nullable<MorphTargetManager>;
  95562. set morphTargetManager(value: Nullable<MorphTargetManager>);
  95563. /** @hidden */
  95564. _creationDataStorage: Nullable<_CreationDataStorage>;
  95565. /** @hidden */
  95566. _geometry: Nullable<Geometry>;
  95567. /** @hidden */
  95568. _delayInfo: Array<string>;
  95569. /** @hidden */
  95570. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  95571. /** @hidden */
  95572. _instanceDataStorage: _InstanceDataStorage;
  95573. private _effectiveMaterial;
  95574. /** @hidden */
  95575. _shouldGenerateFlatShading: boolean;
  95576. /** @hidden */
  95577. _originalBuilderSideOrientation: number;
  95578. /**
  95579. * Use this property to change the original side orientation defined at construction time
  95580. */
  95581. overrideMaterialSideOrientation: Nullable<number>;
  95582. /**
  95583. * Gets the source mesh (the one used to clone this one from)
  95584. */
  95585. get source(): Nullable<Mesh>;
  95586. /**
  95587. * Gets or sets a boolean indicating that this mesh does not use index buffer
  95588. */
  95589. get isUnIndexed(): boolean;
  95590. set isUnIndexed(value: boolean);
  95591. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  95592. get worldMatrixInstancedBuffer(): Float32Array;
  95593. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  95594. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  95595. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  95596. /**
  95597. * @constructor
  95598. * @param name The value used by scene.getMeshByName() to do a lookup.
  95599. * @param scene The scene to add this mesh to.
  95600. * @param parent The parent of this mesh, if it has one
  95601. * @param source An optional Mesh from which geometry is shared, cloned.
  95602. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  95603. * When false, achieved by calling a clone(), also passing False.
  95604. * This will make creation of children, recursive.
  95605. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  95606. */
  95607. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  95608. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95609. doNotInstantiate: boolean;
  95610. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95611. /**
  95612. * Gets the class name
  95613. * @returns the string "Mesh".
  95614. */
  95615. getClassName(): string;
  95616. /** @hidden */
  95617. get _isMesh(): boolean;
  95618. /**
  95619. * Returns a description of this mesh
  95620. * @param fullDetails define if full details about this mesh must be used
  95621. * @returns a descriptive string representing this mesh
  95622. */
  95623. toString(fullDetails?: boolean): string;
  95624. /** @hidden */
  95625. _unBindEffect(): void;
  95626. /**
  95627. * Gets a boolean indicating if this mesh has LOD
  95628. */
  95629. get hasLODLevels(): boolean;
  95630. /**
  95631. * Gets the list of MeshLODLevel associated with the current mesh
  95632. * @returns an array of MeshLODLevel
  95633. */
  95634. getLODLevels(): MeshLODLevel[];
  95635. private _sortLODLevels;
  95636. /**
  95637. * Add a mesh as LOD level triggered at the given distance.
  95638. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  95639. * @param distance The distance from the center of the object to show this level
  95640. * @param mesh The mesh to be added as LOD level (can be null)
  95641. * @return This mesh (for chaining)
  95642. */
  95643. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  95644. /**
  95645. * Returns the LOD level mesh at the passed distance or null if not found.
  95646. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  95647. * @param distance The distance from the center of the object to show this level
  95648. * @returns a Mesh or `null`
  95649. */
  95650. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  95651. /**
  95652. * Remove a mesh from the LOD array
  95653. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  95654. * @param mesh defines the mesh to be removed
  95655. * @return This mesh (for chaining)
  95656. */
  95657. removeLODLevel(mesh: Mesh): Mesh;
  95658. /**
  95659. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  95660. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  95661. * @param camera defines the camera to use to compute distance
  95662. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  95663. * @return This mesh (for chaining)
  95664. */
  95665. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  95666. /**
  95667. * Gets the mesh internal Geometry object
  95668. */
  95669. get geometry(): Nullable<Geometry>;
  95670. /**
  95671. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  95672. * @returns the total number of vertices
  95673. */
  95674. getTotalVertices(): number;
  95675. /**
  95676. * Returns the content of an associated vertex buffer
  95677. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  95678. * - VertexBuffer.PositionKind
  95679. * - VertexBuffer.UVKind
  95680. * - VertexBuffer.UV2Kind
  95681. * - VertexBuffer.UV3Kind
  95682. * - VertexBuffer.UV4Kind
  95683. * - VertexBuffer.UV5Kind
  95684. * - VertexBuffer.UV6Kind
  95685. * - VertexBuffer.ColorKind
  95686. * - VertexBuffer.MatricesIndicesKind
  95687. * - VertexBuffer.MatricesIndicesExtraKind
  95688. * - VertexBuffer.MatricesWeightsKind
  95689. * - VertexBuffer.MatricesWeightsExtraKind
  95690. * @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
  95691. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  95692. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  95693. */
  95694. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95695. /**
  95696. * Returns the mesh VertexBuffer object from the requested `kind`
  95697. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  95698. * - VertexBuffer.PositionKind
  95699. * - VertexBuffer.NormalKind
  95700. * - VertexBuffer.UVKind
  95701. * - VertexBuffer.UV2Kind
  95702. * - VertexBuffer.UV3Kind
  95703. * - VertexBuffer.UV4Kind
  95704. * - VertexBuffer.UV5Kind
  95705. * - VertexBuffer.UV6Kind
  95706. * - VertexBuffer.ColorKind
  95707. * - VertexBuffer.MatricesIndicesKind
  95708. * - VertexBuffer.MatricesIndicesExtraKind
  95709. * - VertexBuffer.MatricesWeightsKind
  95710. * - VertexBuffer.MatricesWeightsExtraKind
  95711. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  95712. */
  95713. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95714. /**
  95715. * Tests if a specific vertex buffer is associated with this mesh
  95716. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  95717. * - VertexBuffer.PositionKind
  95718. * - VertexBuffer.NormalKind
  95719. * - VertexBuffer.UVKind
  95720. * - VertexBuffer.UV2Kind
  95721. * - VertexBuffer.UV3Kind
  95722. * - VertexBuffer.UV4Kind
  95723. * - VertexBuffer.UV5Kind
  95724. * - VertexBuffer.UV6Kind
  95725. * - VertexBuffer.ColorKind
  95726. * - VertexBuffer.MatricesIndicesKind
  95727. * - VertexBuffer.MatricesIndicesExtraKind
  95728. * - VertexBuffer.MatricesWeightsKind
  95729. * - VertexBuffer.MatricesWeightsExtraKind
  95730. * @returns a boolean
  95731. */
  95732. isVerticesDataPresent(kind: string): boolean;
  95733. /**
  95734. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  95735. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  95736. * - VertexBuffer.PositionKind
  95737. * - VertexBuffer.UVKind
  95738. * - VertexBuffer.UV2Kind
  95739. * - VertexBuffer.UV3Kind
  95740. * - VertexBuffer.UV4Kind
  95741. * - VertexBuffer.UV5Kind
  95742. * - VertexBuffer.UV6Kind
  95743. * - VertexBuffer.ColorKind
  95744. * - VertexBuffer.MatricesIndicesKind
  95745. * - VertexBuffer.MatricesIndicesExtraKind
  95746. * - VertexBuffer.MatricesWeightsKind
  95747. * - VertexBuffer.MatricesWeightsExtraKind
  95748. * @returns a boolean
  95749. */
  95750. isVertexBufferUpdatable(kind: string): boolean;
  95751. /**
  95752. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  95753. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  95754. * - VertexBuffer.PositionKind
  95755. * - VertexBuffer.NormalKind
  95756. * - VertexBuffer.UVKind
  95757. * - VertexBuffer.UV2Kind
  95758. * - VertexBuffer.UV3Kind
  95759. * - VertexBuffer.UV4Kind
  95760. * - VertexBuffer.UV5Kind
  95761. * - VertexBuffer.UV6Kind
  95762. * - VertexBuffer.ColorKind
  95763. * - VertexBuffer.MatricesIndicesKind
  95764. * - VertexBuffer.MatricesIndicesExtraKind
  95765. * - VertexBuffer.MatricesWeightsKind
  95766. * - VertexBuffer.MatricesWeightsExtraKind
  95767. * @returns an array of strings
  95768. */
  95769. getVerticesDataKinds(): string[];
  95770. /**
  95771. * Returns a positive integer : the total number of indices in this mesh geometry.
  95772. * @returns the numner of indices or zero if the mesh has no geometry.
  95773. */
  95774. getTotalIndices(): number;
  95775. /**
  95776. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95777. * @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.
  95778. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95779. * @returns the indices array or an empty array if the mesh has no geometry
  95780. */
  95781. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95782. get isBlocked(): boolean;
  95783. /**
  95784. * Determine if the current mesh is ready to be rendered
  95785. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95786. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  95787. * @returns true if all associated assets are ready (material, textures, shaders)
  95788. */
  95789. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  95790. /**
  95791. * 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.
  95792. */
  95793. get areNormalsFrozen(): boolean;
  95794. /**
  95795. * 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.
  95796. * @returns the current mesh
  95797. */
  95798. freezeNormals(): Mesh;
  95799. /**
  95800. * 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
  95801. * @returns the current mesh
  95802. */
  95803. unfreezeNormals(): Mesh;
  95804. /**
  95805. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  95806. */
  95807. set overridenInstanceCount(count: number);
  95808. /** @hidden */
  95809. _preActivate(): Mesh;
  95810. /** @hidden */
  95811. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95812. /** @hidden */
  95813. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  95814. /**
  95815. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95816. * This means the mesh underlying bounding box and sphere are recomputed.
  95817. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95818. * @returns the current mesh
  95819. */
  95820. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  95821. /** @hidden */
  95822. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  95823. /**
  95824. * This function will subdivide the mesh into multiple submeshes
  95825. * @param count defines the expected number of submeshes
  95826. */
  95827. subdivide(count: number): void;
  95828. /**
  95829. * Copy a FloatArray into a specific associated vertex buffer
  95830. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95831. * - VertexBuffer.PositionKind
  95832. * - VertexBuffer.UVKind
  95833. * - VertexBuffer.UV2Kind
  95834. * - VertexBuffer.UV3Kind
  95835. * - VertexBuffer.UV4Kind
  95836. * - VertexBuffer.UV5Kind
  95837. * - VertexBuffer.UV6Kind
  95838. * - VertexBuffer.ColorKind
  95839. * - VertexBuffer.MatricesIndicesKind
  95840. * - VertexBuffer.MatricesIndicesExtraKind
  95841. * - VertexBuffer.MatricesWeightsKind
  95842. * - VertexBuffer.MatricesWeightsExtraKind
  95843. * @param data defines the data source
  95844. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95845. * @param stride defines the data stride size (can be null)
  95846. * @returns the current mesh
  95847. */
  95848. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95849. /**
  95850. * Delete a vertex buffer associated with this mesh
  95851. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  95852. * - VertexBuffer.PositionKind
  95853. * - VertexBuffer.UVKind
  95854. * - VertexBuffer.UV2Kind
  95855. * - VertexBuffer.UV3Kind
  95856. * - VertexBuffer.UV4Kind
  95857. * - VertexBuffer.UV5Kind
  95858. * - VertexBuffer.UV6Kind
  95859. * - VertexBuffer.ColorKind
  95860. * - VertexBuffer.MatricesIndicesKind
  95861. * - VertexBuffer.MatricesIndicesExtraKind
  95862. * - VertexBuffer.MatricesWeightsKind
  95863. * - VertexBuffer.MatricesWeightsExtraKind
  95864. */
  95865. removeVerticesData(kind: string): void;
  95866. /**
  95867. * Flags an associated vertex buffer as updatable
  95868. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  95869. * - VertexBuffer.PositionKind
  95870. * - VertexBuffer.UVKind
  95871. * - VertexBuffer.UV2Kind
  95872. * - VertexBuffer.UV3Kind
  95873. * - VertexBuffer.UV4Kind
  95874. * - VertexBuffer.UV5Kind
  95875. * - VertexBuffer.UV6Kind
  95876. * - VertexBuffer.ColorKind
  95877. * - VertexBuffer.MatricesIndicesKind
  95878. * - VertexBuffer.MatricesIndicesExtraKind
  95879. * - VertexBuffer.MatricesWeightsKind
  95880. * - VertexBuffer.MatricesWeightsExtraKind
  95881. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95882. */
  95883. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  95884. /**
  95885. * Sets the mesh global Vertex Buffer
  95886. * @param buffer defines the buffer to use
  95887. * @returns the current mesh
  95888. */
  95889. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  95890. /**
  95891. * Update a specific associated vertex buffer
  95892. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95893. * - VertexBuffer.PositionKind
  95894. * - VertexBuffer.UVKind
  95895. * - VertexBuffer.UV2Kind
  95896. * - VertexBuffer.UV3Kind
  95897. * - VertexBuffer.UV4Kind
  95898. * - VertexBuffer.UV5Kind
  95899. * - VertexBuffer.UV6Kind
  95900. * - VertexBuffer.ColorKind
  95901. * - VertexBuffer.MatricesIndicesKind
  95902. * - VertexBuffer.MatricesIndicesExtraKind
  95903. * - VertexBuffer.MatricesWeightsKind
  95904. * - VertexBuffer.MatricesWeightsExtraKind
  95905. * @param data defines the data source
  95906. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95907. * @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)
  95908. * @returns the current mesh
  95909. */
  95910. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95911. /**
  95912. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  95913. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  95914. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  95915. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  95916. * @returns the current mesh
  95917. */
  95918. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  95919. /**
  95920. * Creates a un-shared specific occurence of the geometry for the mesh.
  95921. * @returns the current mesh
  95922. */
  95923. makeGeometryUnique(): Mesh;
  95924. /**
  95925. * Set the index buffer of this mesh
  95926. * @param indices defines the source data
  95927. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  95928. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  95929. * @returns the current mesh
  95930. */
  95931. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  95932. /**
  95933. * Update the current index buffer
  95934. * @param indices defines the source data
  95935. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95936. * @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)
  95937. * @returns the current mesh
  95938. */
  95939. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95940. /**
  95941. * Invert the geometry to move from a right handed system to a left handed one.
  95942. * @returns the current mesh
  95943. */
  95944. toLeftHanded(): Mesh;
  95945. /** @hidden */
  95946. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95947. /** @hidden */
  95948. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95949. /**
  95950. * Registers for this mesh a javascript function called just before the rendering process
  95951. * @param func defines the function to call before rendering this mesh
  95952. * @returns the current mesh
  95953. */
  95954. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95955. /**
  95956. * Disposes a previously registered javascript function called before the rendering
  95957. * @param func defines the function to remove
  95958. * @returns the current mesh
  95959. */
  95960. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95961. /**
  95962. * Registers for this mesh a javascript function called just after the rendering is complete
  95963. * @param func defines the function to call after rendering this mesh
  95964. * @returns the current mesh
  95965. */
  95966. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95967. /**
  95968. * Disposes a previously registered javascript function called after the rendering.
  95969. * @param func defines the function to remove
  95970. * @returns the current mesh
  95971. */
  95972. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95973. /** @hidden */
  95974. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  95975. /** @hidden */
  95976. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  95977. /** @hidden */
  95978. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  95979. /** @hidden */
  95980. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  95981. /** @hidden */
  95982. _rebuild(): void;
  95983. /** @hidden */
  95984. _freeze(): void;
  95985. /** @hidden */
  95986. _unFreeze(): void;
  95987. /**
  95988. * 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
  95989. * @param subMesh defines the subMesh to render
  95990. * @param enableAlphaMode defines if alpha mode can be changed
  95991. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  95992. * @returns the current mesh
  95993. */
  95994. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  95995. private _onBeforeDraw;
  95996. /**
  95997. * Renormalize the mesh and patch it up if there are no weights
  95998. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  95999. * However in the case of zero weights then we set just a single influence to 1.
  96000. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  96001. */
  96002. cleanMatrixWeights(): void;
  96003. private normalizeSkinFourWeights;
  96004. private normalizeSkinWeightsAndExtra;
  96005. /**
  96006. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  96007. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  96008. * the user know there was an issue with importing the mesh
  96009. * @returns a validation object with skinned, valid and report string
  96010. */
  96011. validateSkinning(): {
  96012. skinned: boolean;
  96013. valid: boolean;
  96014. report: string;
  96015. };
  96016. /** @hidden */
  96017. _checkDelayState(): Mesh;
  96018. private _queueLoad;
  96019. /**
  96020. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  96021. * A mesh is in the frustum if its bounding box intersects the frustum
  96022. * @param frustumPlanes defines the frustum to test
  96023. * @returns true if the mesh is in the frustum planes
  96024. */
  96025. isInFrustum(frustumPlanes: Plane[]): boolean;
  96026. /**
  96027. * Sets the mesh material by the material or multiMaterial `id` property
  96028. * @param id is a string identifying the material or the multiMaterial
  96029. * @returns the current mesh
  96030. */
  96031. setMaterialByID(id: string): Mesh;
  96032. /**
  96033. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  96034. * @returns an array of IAnimatable
  96035. */
  96036. getAnimatables(): IAnimatable[];
  96037. /**
  96038. * Modifies the mesh geometry according to the passed transformation matrix.
  96039. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  96040. * The mesh normals are modified using the same transformation.
  96041. * Note that, under the hood, this method sets a new VertexBuffer each call.
  96042. * @param transform defines the transform matrix to use
  96043. * @see http://doc.babylonjs.com/resources/baking_transformations
  96044. * @returns the current mesh
  96045. */
  96046. bakeTransformIntoVertices(transform: Matrix): Mesh;
  96047. /**
  96048. * Modifies the mesh geometry according to its own current World Matrix.
  96049. * The mesh World Matrix is then reset.
  96050. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  96051. * Note that, under the hood, this method sets a new VertexBuffer each call.
  96052. * @see http://doc.babylonjs.com/resources/baking_transformations
  96053. * @returns the current mesh
  96054. */
  96055. bakeCurrentTransformIntoVertices(): Mesh;
  96056. /** @hidden */
  96057. get _positions(): Nullable<Vector3[]>;
  96058. /** @hidden */
  96059. _resetPointsArrayCache(): Mesh;
  96060. /** @hidden */
  96061. _generatePointsArray(): boolean;
  96062. /**
  96063. * Returns a new Mesh object generated from the current mesh properties.
  96064. * This method must not get confused with createInstance()
  96065. * @param name is a string, the name given to the new mesh
  96066. * @param newParent can be any Node object (default `null`)
  96067. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  96068. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  96069. * @returns a new mesh
  96070. */
  96071. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  96072. /**
  96073. * Releases resources associated with this mesh.
  96074. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96075. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96076. */
  96077. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96078. /** @hidden */
  96079. _disposeInstanceSpecificData(): void;
  96080. /**
  96081. * Modifies the mesh geometry according to a displacement map.
  96082. * 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.
  96083. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  96084. * @param url is a string, the URL from the image file is to be downloaded.
  96085. * @param minHeight is the lower limit of the displacement.
  96086. * @param maxHeight is the upper limit of the displacement.
  96087. * @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.
  96088. * @param uvOffset is an optional vector2 used to offset UV.
  96089. * @param uvScale is an optional vector2 used to scale UV.
  96090. * @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.
  96091. * @returns the Mesh.
  96092. */
  96093. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  96094. /**
  96095. * Modifies the mesh geometry according to a displacementMap buffer.
  96096. * 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.
  96097. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  96098. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  96099. * @param heightMapWidth is the width of the buffer image.
  96100. * @param heightMapHeight is the height of the buffer image.
  96101. * @param minHeight is the lower limit of the displacement.
  96102. * @param maxHeight is the upper limit of the displacement.
  96103. * @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.
  96104. * @param uvOffset is an optional vector2 used to offset UV.
  96105. * @param uvScale is an optional vector2 used to scale UV.
  96106. * @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.
  96107. * @returns the Mesh.
  96108. */
  96109. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  96110. /**
  96111. * Modify the mesh to get a flat shading rendering.
  96112. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  96113. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  96114. * @returns current mesh
  96115. */
  96116. convertToFlatShadedMesh(): Mesh;
  96117. /**
  96118. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  96119. * In other words, more vertices, no more indices and a single bigger VBO.
  96120. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  96121. * @returns current mesh
  96122. */
  96123. convertToUnIndexedMesh(): Mesh;
  96124. /**
  96125. * Inverses facet orientations.
  96126. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  96127. * @param flipNormals will also inverts the normals
  96128. * @returns current mesh
  96129. */
  96130. flipFaces(flipNormals?: boolean): Mesh;
  96131. /**
  96132. * Increase the number of facets and hence vertices in a mesh
  96133. * Vertex normals are interpolated from existing vertex normals
  96134. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  96135. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  96136. */
  96137. increaseVertices(numberPerEdge: number): void;
  96138. /**
  96139. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  96140. * This will undo any application of covertToFlatShadedMesh
  96141. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  96142. */
  96143. forceSharedVertices(): void;
  96144. /** @hidden */
  96145. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  96146. /** @hidden */
  96147. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  96148. /**
  96149. * Creates a new InstancedMesh object from the mesh model.
  96150. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  96151. * @param name defines the name of the new instance
  96152. * @returns a new InstancedMesh
  96153. */
  96154. createInstance(name: string): InstancedMesh;
  96155. /**
  96156. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  96157. * After this call, all the mesh instances have the same submeshes than the current mesh.
  96158. * @returns the current mesh
  96159. */
  96160. synchronizeInstances(): Mesh;
  96161. /**
  96162. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  96163. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  96164. * This should be used together with the simplification to avoid disappearing triangles.
  96165. * @param successCallback an optional success callback to be called after the optimization finished.
  96166. * @returns the current mesh
  96167. */
  96168. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  96169. /**
  96170. * Serialize current mesh
  96171. * @param serializationObject defines the object which will receive the serialization data
  96172. */
  96173. serialize(serializationObject: any): void;
  96174. /** @hidden */
  96175. _syncGeometryWithMorphTargetManager(): void;
  96176. /** @hidden */
  96177. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  96178. /**
  96179. * Returns a new Mesh object parsed from the source provided.
  96180. * @param parsedMesh is the source
  96181. * @param scene defines the hosting scene
  96182. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  96183. * @returns a new Mesh
  96184. */
  96185. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  96186. /**
  96187. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  96188. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  96189. * @param name defines the name of the mesh to create
  96190. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  96191. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  96192. * @param closePath creates a seam between the first and the last points of each path of the path array
  96193. * @param offset is taken in account only if the `pathArray` is containing a single path
  96194. * @param scene defines the hosting scene
  96195. * @param updatable defines if the mesh must be flagged as updatable
  96196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96197. * @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)
  96198. * @returns a new Mesh
  96199. */
  96200. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  96201. /**
  96202. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  96203. * @param name defines the name of the mesh to create
  96204. * @param radius sets the radius size (float) of the polygon (default 0.5)
  96205. * @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
  96206. * @param scene defines the hosting scene
  96207. * @param updatable defines if the mesh must be flagged as updatable
  96208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96209. * @returns a new Mesh
  96210. */
  96211. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  96212. /**
  96213. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  96214. * @param name defines the name of the mesh to create
  96215. * @param size sets the size (float) of each box side (default 1)
  96216. * @param scene defines the hosting scene
  96217. * @param updatable defines if the mesh must be flagged as updatable
  96218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96219. * @returns a new Mesh
  96220. */
  96221. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  96222. /**
  96223. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  96224. * @param name defines the name of the mesh to create
  96225. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  96226. * @param diameter sets the diameter size (float) of the sphere (default 1)
  96227. * @param scene defines the hosting scene
  96228. * @param updatable defines if the mesh must be flagged as updatable
  96229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96230. * @returns a new Mesh
  96231. */
  96232. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96233. /**
  96234. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  96235. * @param name defines the name of the mesh to create
  96236. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  96237. * @param diameter sets the diameter size (float) of the sphere (default 1)
  96238. * @param scene defines the hosting scene
  96239. * @returns a new Mesh
  96240. */
  96241. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  96242. /**
  96243. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  96244. * @param name defines the name of the mesh to create
  96245. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  96246. * @param diameterTop set the top cap diameter (floats, default 1)
  96247. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  96248. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  96249. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  96250. * @param scene defines the hosting scene
  96251. * @param updatable defines if the mesh must be flagged as updatable
  96252. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96253. * @returns a new Mesh
  96254. */
  96255. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  96256. /**
  96257. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  96258. * @param name defines the name of the mesh to create
  96259. * @param diameter sets the diameter size (float) of the torus (default 1)
  96260. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  96261. * @param tessellation sets the number of torus sides (postive integer, default 16)
  96262. * @param scene defines the hosting scene
  96263. * @param updatable defines if the mesh must be flagged as updatable
  96264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96265. * @returns a new Mesh
  96266. */
  96267. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96268. /**
  96269. * Creates a torus knot 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 radius sets the global radius size (float) of the torus knot (default 2)
  96272. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  96273. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  96274. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  96275. * @param p the number of windings on X axis (positive integers, default 2)
  96276. * @param q the number of windings on Y axis (positive integers, default 3)
  96277. * @param scene defines the hosting scene
  96278. * @param updatable defines if the mesh must be flagged as updatable
  96279. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96280. * @returns a new Mesh
  96281. */
  96282. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96283. /**
  96284. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  96285. * @param name defines the name of the mesh to create
  96286. * @param points is an array successive Vector3
  96287. * @param scene defines the hosting scene
  96288. * @param updatable defines if the mesh must be flagged as updatable
  96289. * @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).
  96290. * @returns a new Mesh
  96291. */
  96292. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  96293. /**
  96294. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  96295. * @param name defines the name of the mesh to create
  96296. * @param points is an array successive Vector3
  96297. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  96298. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  96299. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  96300. * @param scene defines the hosting scene
  96301. * @param updatable defines if the mesh must be flagged as updatable
  96302. * @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)
  96303. * @returns a new Mesh
  96304. */
  96305. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  96306. /**
  96307. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  96308. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  96309. * 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.
  96310. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96311. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96312. * Remember you can only change the shape positions, not their number when updating a polygon.
  96313. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  96314. * @param name defines the name of the mesh to create
  96315. * @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
  96316. * @param scene defines the hosting scene
  96317. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  96318. * @param updatable defines if the mesh must be flagged as updatable
  96319. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96320. * @param earcutInjection can be used to inject your own earcut reference
  96321. * @returns a new Mesh
  96322. */
  96323. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  96324. /**
  96325. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  96326. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  96327. * @param name defines the name of the mesh to create
  96328. * @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
  96329. * @param depth defines the height of extrusion
  96330. * @param scene defines the hosting scene
  96331. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  96332. * @param updatable defines if the mesh must be flagged as updatable
  96333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96334. * @param earcutInjection can be used to inject your own earcut reference
  96335. * @returns a new Mesh
  96336. */
  96337. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  96338. /**
  96339. * Creates an extruded shape mesh.
  96340. * 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
  96341. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  96342. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  96343. * @param name defines the name of the mesh to create
  96344. * @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
  96345. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  96346. * @param scale is the value to scale the shape
  96347. * @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
  96348. * @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
  96349. * @param scene defines the hosting scene
  96350. * @param updatable defines if the mesh must be flagged as updatable
  96351. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96352. * @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)
  96353. * @returns a new Mesh
  96354. */
  96355. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  96356. /**
  96357. * Creates an custom extruded shape mesh.
  96358. * The custom extrusion is a parametric shape.
  96359. * It has no predefined shape. Its final shape will depend on the input parameters.
  96360. * Please consider using the same method from the MeshBuilder class instead
  96361. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  96362. * @param name defines the name of the mesh to create
  96363. * @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
  96364. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  96365. * @param scaleFunction is a custom Javascript function called on each path point
  96366. * @param rotationFunction is a custom Javascript function called on each path point
  96367. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  96368. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  96369. * @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
  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. * @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)
  96374. * @returns a new Mesh
  96375. */
  96376. 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;
  96377. /**
  96378. * Creates lathe mesh.
  96379. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  96380. * Please consider using the same method from the MeshBuilder class instead
  96381. * @param name defines the name of the mesh to create
  96382. * @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
  96383. * @param radius is the radius value of the lathe
  96384. * @param tessellation is the side number of the lathe.
  96385. * @param scene defines the hosting scene
  96386. * @param updatable defines if the mesh must be flagged as updatable
  96387. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96388. * @returns a new Mesh
  96389. */
  96390. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96391. /**
  96392. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  96393. * @param name defines the name of the mesh to create
  96394. * @param size sets the size (float) of both sides of the plane at once (default 1)
  96395. * @param scene defines the hosting scene
  96396. * @param updatable defines if the mesh must be flagged as updatable
  96397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96398. * @returns a new Mesh
  96399. */
  96400. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96401. /**
  96402. * Creates a ground mesh.
  96403. * Please consider using the same method from the MeshBuilder class instead
  96404. * @param name defines the name of the mesh to create
  96405. * @param width set the width of the ground
  96406. * @param height set the height of the ground
  96407. * @param subdivisions sets the number of subdivisions per side
  96408. * @param scene defines the hosting scene
  96409. * @param updatable defines if the mesh must be flagged as updatable
  96410. * @returns a new Mesh
  96411. */
  96412. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  96413. /**
  96414. * Creates a tiled ground mesh.
  96415. * Please consider using the same method from the MeshBuilder class instead
  96416. * @param name defines the name of the mesh to create
  96417. * @param xmin set the ground minimum X coordinate
  96418. * @param zmin set the ground minimum Y coordinate
  96419. * @param xmax set the ground maximum X coordinate
  96420. * @param zmax set the ground maximum Z coordinate
  96421. * @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
  96422. * @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
  96423. * @param scene defines the hosting scene
  96424. * @param updatable defines if the mesh must be flagged as updatable
  96425. * @returns a new Mesh
  96426. */
  96427. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  96428. w: number;
  96429. h: number;
  96430. }, precision: {
  96431. w: number;
  96432. h: number;
  96433. }, scene: Scene, updatable?: boolean): Mesh;
  96434. /**
  96435. * Creates a ground mesh from a height map.
  96436. * Please consider using the same method from the MeshBuilder class instead
  96437. * @see http://doc.babylonjs.com/babylon101/height_map
  96438. * @param name defines the name of the mesh to create
  96439. * @param url sets the URL of the height map image resource
  96440. * @param width set the ground width size
  96441. * @param height set the ground height size
  96442. * @param subdivisions sets the number of subdivision per side
  96443. * @param minHeight is the minimum altitude on the ground
  96444. * @param maxHeight is the maximum altitude on the ground
  96445. * @param scene defines the hosting scene
  96446. * @param updatable defines if the mesh must be flagged as updatable
  96447. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  96448. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  96449. * @returns a new Mesh
  96450. */
  96451. 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;
  96452. /**
  96453. * Creates a tube mesh.
  96454. * The tube is a parametric shape.
  96455. * It has no predefined shape. Its final shape will depend on the input parameters.
  96456. * Please consider using the same method from the MeshBuilder class instead
  96457. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  96458. * @param name defines the name of the mesh to create
  96459. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  96460. * @param radius sets the tube radius size
  96461. * @param tessellation is the number of sides on the tubular surface
  96462. * @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
  96463. * @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
  96464. * @param scene defines the hosting scene
  96465. * @param updatable defines if the mesh must be flagged as updatable
  96466. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96467. * @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)
  96468. * @returns a new Mesh
  96469. */
  96470. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  96471. (i: number, distance: number): number;
  96472. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  96473. /**
  96474. * Creates a polyhedron mesh.
  96475. * Please consider using the same method from the MeshBuilder class instead.
  96476. * * 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
  96477. * * The parameter `size` (positive float, default 1) sets the polygon size
  96478. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  96479. * * 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`
  96480. * * 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
  96481. * * 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)`)
  96482. * * 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
  96483. * * 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
  96484. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96485. * * If you create a double-sided mesh, you can choose what parts of 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
  96486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96487. * @param name defines the name of the mesh to create
  96488. * @param options defines the options used to create the mesh
  96489. * @param scene defines the hosting scene
  96490. * @returns a new Mesh
  96491. */
  96492. static CreatePolyhedron(name: string, options: {
  96493. type?: number;
  96494. size?: number;
  96495. sizeX?: number;
  96496. sizeY?: number;
  96497. sizeZ?: number;
  96498. custom?: any;
  96499. faceUV?: Vector4[];
  96500. faceColors?: Color4[];
  96501. updatable?: boolean;
  96502. sideOrientation?: number;
  96503. }, scene: Scene): Mesh;
  96504. /**
  96505. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  96506. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  96507. * * 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`)
  96508. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  96509. * * 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
  96510. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96511. * * If you create a double-sided mesh, you can choose what parts of 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
  96512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96513. * @param name defines the name of the mesh
  96514. * @param options defines the options used to create the mesh
  96515. * @param scene defines the hosting scene
  96516. * @returns a new Mesh
  96517. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  96518. */
  96519. static CreateIcoSphere(name: string, options: {
  96520. radius?: number;
  96521. flat?: boolean;
  96522. subdivisions?: number;
  96523. sideOrientation?: number;
  96524. updatable?: boolean;
  96525. }, scene: Scene): Mesh;
  96526. /**
  96527. * Creates a decal mesh.
  96528. * Please consider using the same method from the MeshBuilder class instead.
  96529. * A decal is a mesh usually applied as a model onto the surface of another mesh
  96530. * @param name defines the name of the mesh
  96531. * @param sourceMesh defines the mesh receiving the decal
  96532. * @param position sets the position of the decal in world coordinates
  96533. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  96534. * @param size sets the decal scaling
  96535. * @param angle sets the angle to rotate the decal
  96536. * @returns a new Mesh
  96537. */
  96538. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  96539. /**
  96540. * Prepare internal position array for software CPU skinning
  96541. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  96542. */
  96543. setPositionsForCPUSkinning(): Float32Array;
  96544. /**
  96545. * Prepare internal normal array for software CPU skinning
  96546. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  96547. */
  96548. setNormalsForCPUSkinning(): Float32Array;
  96549. /**
  96550. * Updates the vertex buffer by applying transformation from the bones
  96551. * @param skeleton defines the skeleton to apply to current mesh
  96552. * @returns the current mesh
  96553. */
  96554. applySkeleton(skeleton: Skeleton): Mesh;
  96555. /**
  96556. * 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
  96557. * @param meshes defines the list of meshes to scan
  96558. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  96559. */
  96560. static MinMax(meshes: AbstractMesh[]): {
  96561. min: Vector3;
  96562. max: Vector3;
  96563. };
  96564. /**
  96565. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  96566. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  96567. * @returns a vector3
  96568. */
  96569. static Center(meshesOrMinMaxVector: {
  96570. min: Vector3;
  96571. max: Vector3;
  96572. } | AbstractMesh[]): Vector3;
  96573. /**
  96574. * Merge the array of meshes into a single mesh for performance reasons.
  96575. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  96576. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  96577. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  96578. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  96579. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  96580. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  96581. * @returns a new mesh
  96582. */
  96583. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  96584. /** @hidden */
  96585. addInstance(instance: InstancedMesh): void;
  96586. /** @hidden */
  96587. removeInstance(instance: InstancedMesh): void;
  96588. }
  96589. }
  96590. declare module BABYLON {
  96591. /**
  96592. * This is the base class of all the camera used in the application.
  96593. * @see http://doc.babylonjs.com/features/cameras
  96594. */
  96595. export class Camera extends Node {
  96596. /** @hidden */
  96597. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  96598. /**
  96599. * This is the default projection mode used by the cameras.
  96600. * It helps recreating a feeling of perspective and better appreciate depth.
  96601. * This is the best way to simulate real life cameras.
  96602. */
  96603. static readonly PERSPECTIVE_CAMERA: number;
  96604. /**
  96605. * This helps creating camera with an orthographic mode.
  96606. * 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.
  96607. */
  96608. static readonly ORTHOGRAPHIC_CAMERA: number;
  96609. /**
  96610. * This is the default FOV mode for perspective cameras.
  96611. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  96612. */
  96613. static readonly FOVMODE_VERTICAL_FIXED: number;
  96614. /**
  96615. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  96616. */
  96617. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  96618. /**
  96619. * This specifies ther is no need for a camera rig.
  96620. * Basically only one eye is rendered corresponding to the camera.
  96621. */
  96622. static readonly RIG_MODE_NONE: number;
  96623. /**
  96624. * Simulates a camera Rig with one blue eye and one red eye.
  96625. * This can be use with 3d blue and red glasses.
  96626. */
  96627. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  96628. /**
  96629. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  96630. */
  96631. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  96632. /**
  96633. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  96634. */
  96635. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  96636. /**
  96637. * Defines that both eyes of the camera will be rendered over under each other.
  96638. */
  96639. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  96640. /**
  96641. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  96642. */
  96643. static readonly RIG_MODE_VR: number;
  96644. /**
  96645. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  96646. */
  96647. static readonly RIG_MODE_WEBVR: number;
  96648. /**
  96649. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  96650. */
  96651. static readonly RIG_MODE_CUSTOM: number;
  96652. /**
  96653. * Defines if by default attaching controls should prevent the default javascript event to continue.
  96654. */
  96655. static ForceAttachControlToAlwaysPreventDefault: boolean;
  96656. /**
  96657. * Define the input manager associated with the camera.
  96658. */
  96659. inputs: CameraInputsManager<Camera>;
  96660. /** @hidden */
  96661. _position: Vector3;
  96662. /**
  96663. * Define the current local position of the camera in the scene
  96664. */
  96665. get position(): Vector3;
  96666. set position(newPosition: Vector3);
  96667. /**
  96668. * The vector the camera should consider as up.
  96669. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  96670. */
  96671. upVector: Vector3;
  96672. /**
  96673. * Define the current limit on the left side for an orthographic camera
  96674. * In scene unit
  96675. */
  96676. orthoLeft: Nullable<number>;
  96677. /**
  96678. * Define the current limit on the right side for an orthographic camera
  96679. * In scene unit
  96680. */
  96681. orthoRight: Nullable<number>;
  96682. /**
  96683. * Define the current limit on the bottom side for an orthographic camera
  96684. * In scene unit
  96685. */
  96686. orthoBottom: Nullable<number>;
  96687. /**
  96688. * Define the current limit on the top side for an orthographic camera
  96689. * In scene unit
  96690. */
  96691. orthoTop: Nullable<number>;
  96692. /**
  96693. * Field Of View is set in Radians. (default is 0.8)
  96694. */
  96695. fov: number;
  96696. /**
  96697. * Define the minimum distance the camera can see from.
  96698. * This is important to note that the depth buffer are not infinite and the closer it starts
  96699. * the more your scene might encounter depth fighting issue.
  96700. */
  96701. minZ: number;
  96702. /**
  96703. * Define the maximum distance the camera can see to.
  96704. * This is important to note that the depth buffer are not infinite and the further it end
  96705. * the more your scene might encounter depth fighting issue.
  96706. */
  96707. maxZ: number;
  96708. /**
  96709. * Define the default inertia of the camera.
  96710. * This helps giving a smooth feeling to the camera movement.
  96711. */
  96712. inertia: number;
  96713. /**
  96714. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  96715. */
  96716. mode: number;
  96717. /**
  96718. * Define wether the camera is intermediate.
  96719. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  96720. */
  96721. isIntermediate: boolean;
  96722. /**
  96723. * Define the viewport of the camera.
  96724. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  96725. */
  96726. viewport: Viewport;
  96727. /**
  96728. * Restricts the camera to viewing objects with the same layerMask.
  96729. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  96730. */
  96731. layerMask: number;
  96732. /**
  96733. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  96734. */
  96735. fovMode: number;
  96736. /**
  96737. * Rig mode of the camera.
  96738. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  96739. * This is normally controlled byt the camera themselves as internal use.
  96740. */
  96741. cameraRigMode: number;
  96742. /**
  96743. * Defines the distance between both "eyes" in case of a RIG
  96744. */
  96745. interaxialDistance: number;
  96746. /**
  96747. * Defines if stereoscopic rendering is done side by side or over under.
  96748. */
  96749. isStereoscopicSideBySide: boolean;
  96750. /**
  96751. * 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
  96752. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  96753. * else in the scene. (Eg. security camera)
  96754. *
  96755. * 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)
  96756. */
  96757. customRenderTargets: RenderTargetTexture[];
  96758. /**
  96759. * When set, the camera will render to this render target instead of the default canvas
  96760. *
  96761. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  96762. */
  96763. outputRenderTarget: Nullable<RenderTargetTexture>;
  96764. /**
  96765. * Observable triggered when the camera view matrix has changed.
  96766. */
  96767. onViewMatrixChangedObservable: Observable<Camera>;
  96768. /**
  96769. * Observable triggered when the camera Projection matrix has changed.
  96770. */
  96771. onProjectionMatrixChangedObservable: Observable<Camera>;
  96772. /**
  96773. * Observable triggered when the inputs have been processed.
  96774. */
  96775. onAfterCheckInputsObservable: Observable<Camera>;
  96776. /**
  96777. * Observable triggered when reset has been called and applied to the camera.
  96778. */
  96779. onRestoreStateObservable: Observable<Camera>;
  96780. /** @hidden */
  96781. _cameraRigParams: any;
  96782. /** @hidden */
  96783. _rigCameras: Camera[];
  96784. /** @hidden */
  96785. _rigPostProcess: Nullable<PostProcess>;
  96786. protected _webvrViewMatrix: Matrix;
  96787. /** @hidden */
  96788. _skipRendering: boolean;
  96789. /** @hidden */
  96790. _projectionMatrix: Matrix;
  96791. /** @hidden */
  96792. _postProcesses: Nullable<PostProcess>[];
  96793. /** @hidden */
  96794. _activeMeshes: SmartArray<AbstractMesh>;
  96795. protected _globalPosition: Vector3;
  96796. /** @hidden */
  96797. _computedViewMatrix: Matrix;
  96798. private _doNotComputeProjectionMatrix;
  96799. private _transformMatrix;
  96800. private _frustumPlanes;
  96801. private _refreshFrustumPlanes;
  96802. private _storedFov;
  96803. private _stateStored;
  96804. /**
  96805. * Instantiates a new camera object.
  96806. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  96807. * @see http://doc.babylonjs.com/features/cameras
  96808. * @param name Defines the name of the camera in the scene
  96809. * @param position Defines the position of the camera
  96810. * @param scene Defines the scene the camera belongs too
  96811. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  96812. */
  96813. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96814. /**
  96815. * Store current camera state (fov, position, etc..)
  96816. * @returns the camera
  96817. */
  96818. storeState(): Camera;
  96819. /**
  96820. * Restores the camera state values if it has been stored. You must call storeState() first
  96821. */
  96822. protected _restoreStateValues(): boolean;
  96823. /**
  96824. * Restored camera state. You must call storeState() first.
  96825. * @returns true if restored and false otherwise
  96826. */
  96827. restoreState(): boolean;
  96828. /**
  96829. * Gets the class name of the camera.
  96830. * @returns the class name
  96831. */
  96832. getClassName(): string;
  96833. /** @hidden */
  96834. readonly _isCamera: boolean;
  96835. /**
  96836. * Gets a string representation of the camera useful for debug purpose.
  96837. * @param fullDetails Defines that a more verboe level of logging is required
  96838. * @returns the string representation
  96839. */
  96840. toString(fullDetails?: boolean): string;
  96841. /**
  96842. * Gets the current world space position of the camera.
  96843. */
  96844. get globalPosition(): Vector3;
  96845. /**
  96846. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  96847. * @returns the active meshe list
  96848. */
  96849. getActiveMeshes(): SmartArray<AbstractMesh>;
  96850. /**
  96851. * Check wether a mesh is part of the current active mesh list of the camera
  96852. * @param mesh Defines the mesh to check
  96853. * @returns true if active, false otherwise
  96854. */
  96855. isActiveMesh(mesh: Mesh): boolean;
  96856. /**
  96857. * Is this camera ready to be used/rendered
  96858. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  96859. * @return true if the camera is ready
  96860. */
  96861. isReady(completeCheck?: boolean): boolean;
  96862. /** @hidden */
  96863. _initCache(): void;
  96864. /** @hidden */
  96865. _updateCache(ignoreParentClass?: boolean): void;
  96866. /** @hidden */
  96867. _isSynchronized(): boolean;
  96868. /** @hidden */
  96869. _isSynchronizedViewMatrix(): boolean;
  96870. /** @hidden */
  96871. _isSynchronizedProjectionMatrix(): boolean;
  96872. /**
  96873. * Attach the input controls to a specific dom element to get the input from.
  96874. * @param element Defines the element the controls should be listened from
  96875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96876. */
  96877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96878. /**
  96879. * Detach the current controls from the specified dom element.
  96880. * @param element Defines the element to stop listening the inputs from
  96881. */
  96882. detachControl(element: HTMLElement): void;
  96883. /**
  96884. * Update the camera state according to the different inputs gathered during the frame.
  96885. */
  96886. update(): void;
  96887. /** @hidden */
  96888. _checkInputs(): void;
  96889. /** @hidden */
  96890. get rigCameras(): Camera[];
  96891. /**
  96892. * Gets the post process used by the rig cameras
  96893. */
  96894. get rigPostProcess(): Nullable<PostProcess>;
  96895. /**
  96896. * Internal, gets the first post proces.
  96897. * @returns the first post process to be run on this camera.
  96898. */
  96899. _getFirstPostProcess(): Nullable<PostProcess>;
  96900. private _cascadePostProcessesToRigCams;
  96901. /**
  96902. * Attach a post process to the camera.
  96903. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96904. * @param postProcess The post process to attach to the camera
  96905. * @param insertAt The position of the post process in case several of them are in use in the scene
  96906. * @returns the position the post process has been inserted at
  96907. */
  96908. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  96909. /**
  96910. * Detach a post process to the camera.
  96911. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96912. * @param postProcess The post process to detach from the camera
  96913. */
  96914. detachPostProcess(postProcess: PostProcess): void;
  96915. /**
  96916. * Gets the current world matrix of the camera
  96917. */
  96918. getWorldMatrix(): Matrix;
  96919. /** @hidden */
  96920. _getViewMatrix(): Matrix;
  96921. /**
  96922. * Gets the current view matrix of the camera.
  96923. * @param force forces the camera to recompute the matrix without looking at the cached state
  96924. * @returns the view matrix
  96925. */
  96926. getViewMatrix(force?: boolean): Matrix;
  96927. /**
  96928. * Freeze the projection matrix.
  96929. * It will prevent the cache check of the camera projection compute and can speed up perf
  96930. * if no parameter of the camera are meant to change
  96931. * @param projection Defines manually a projection if necessary
  96932. */
  96933. freezeProjectionMatrix(projection?: Matrix): void;
  96934. /**
  96935. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  96936. */
  96937. unfreezeProjectionMatrix(): void;
  96938. /**
  96939. * Gets the current projection matrix of the camera.
  96940. * @param force forces the camera to recompute the matrix without looking at the cached state
  96941. * @returns the projection matrix
  96942. */
  96943. getProjectionMatrix(force?: boolean): Matrix;
  96944. /**
  96945. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  96946. * @returns a Matrix
  96947. */
  96948. getTransformationMatrix(): Matrix;
  96949. private _updateFrustumPlanes;
  96950. /**
  96951. * Checks if a cullable object (mesh...) is in the camera frustum
  96952. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  96953. * @param target The object to check
  96954. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  96955. * @returns true if the object is in frustum otherwise false
  96956. */
  96957. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  96958. /**
  96959. * Checks if a cullable object (mesh...) is in the camera frustum
  96960. * Unlike isInFrustum this cheks the full bounding box
  96961. * @param target The object to check
  96962. * @returns true if the object is in frustum otherwise false
  96963. */
  96964. isCompletelyInFrustum(target: ICullable): boolean;
  96965. /**
  96966. * Gets a ray in the forward direction from the camera.
  96967. * @param length Defines the length of the ray to create
  96968. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  96969. * @param origin Defines the start point of the ray which defaults to the camera position
  96970. * @returns the forward ray
  96971. */
  96972. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  96973. /**
  96974. * Releases resources associated with this node.
  96975. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96976. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96977. */
  96978. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96979. /** @hidden */
  96980. _isLeftCamera: boolean;
  96981. /**
  96982. * Gets the left camera of a rig setup in case of Rigged Camera
  96983. */
  96984. get isLeftCamera(): boolean;
  96985. /** @hidden */
  96986. _isRightCamera: boolean;
  96987. /**
  96988. * Gets the right camera of a rig setup in case of Rigged Camera
  96989. */
  96990. get isRightCamera(): boolean;
  96991. /**
  96992. * Gets the left camera of a rig setup in case of Rigged Camera
  96993. */
  96994. get leftCamera(): Nullable<FreeCamera>;
  96995. /**
  96996. * Gets the right camera of a rig setup in case of Rigged Camera
  96997. */
  96998. get rightCamera(): Nullable<FreeCamera>;
  96999. /**
  97000. * Gets the left camera target of a rig setup in case of Rigged Camera
  97001. * @returns the target position
  97002. */
  97003. getLeftTarget(): Nullable<Vector3>;
  97004. /**
  97005. * Gets the right camera target of a rig setup in case of Rigged Camera
  97006. * @returns the target position
  97007. */
  97008. getRightTarget(): Nullable<Vector3>;
  97009. /**
  97010. * @hidden
  97011. */
  97012. setCameraRigMode(mode: number, rigParams: any): void;
  97013. /** @hidden */
  97014. static _setStereoscopicRigMode(camera: Camera): void;
  97015. /** @hidden */
  97016. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  97017. /** @hidden */
  97018. static _setVRRigMode(camera: Camera, rigParams: any): void;
  97019. /** @hidden */
  97020. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  97021. /** @hidden */
  97022. _getVRProjectionMatrix(): Matrix;
  97023. protected _updateCameraRotationMatrix(): void;
  97024. protected _updateWebVRCameraRotationMatrix(): void;
  97025. /**
  97026. * This function MUST be overwritten by the different WebVR cameras available.
  97027. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  97028. * @hidden
  97029. */
  97030. _getWebVRProjectionMatrix(): Matrix;
  97031. /**
  97032. * This function MUST be overwritten by the different WebVR cameras available.
  97033. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  97034. * @hidden
  97035. */
  97036. _getWebVRViewMatrix(): Matrix;
  97037. /** @hidden */
  97038. setCameraRigParameter(name: string, value: any): void;
  97039. /**
  97040. * needs to be overridden by children so sub has required properties to be copied
  97041. * @hidden
  97042. */
  97043. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  97044. /**
  97045. * May need to be overridden by children
  97046. * @hidden
  97047. */
  97048. _updateRigCameras(): void;
  97049. /** @hidden */
  97050. _setupInputs(): void;
  97051. /**
  97052. * Serialiaze the camera setup to a json represention
  97053. * @returns the JSON representation
  97054. */
  97055. serialize(): any;
  97056. /**
  97057. * Clones the current camera.
  97058. * @param name The cloned camera name
  97059. * @returns the cloned camera
  97060. */
  97061. clone(name: string): Camera;
  97062. /**
  97063. * Gets the direction of the camera relative to a given local axis.
  97064. * @param localAxis Defines the reference axis to provide a relative direction.
  97065. * @return the direction
  97066. */
  97067. getDirection(localAxis: Vector3): Vector3;
  97068. /**
  97069. * Returns the current camera absolute rotation
  97070. */
  97071. get absoluteRotation(): Quaternion;
  97072. /**
  97073. * Gets the direction of the camera relative to a given local axis into a passed vector.
  97074. * @param localAxis Defines the reference axis to provide a relative direction.
  97075. * @param result Defines the vector to store the result in
  97076. */
  97077. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  97078. /**
  97079. * Gets a camera constructor for a given camera type
  97080. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  97081. * @param name The name of the camera the result will be able to instantiate
  97082. * @param scene The scene the result will construct the camera in
  97083. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  97084. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  97085. * @returns a factory method to construc the camera
  97086. */
  97087. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  97088. /**
  97089. * Compute the world matrix of the camera.
  97090. * @returns the camera world matrix
  97091. */
  97092. computeWorldMatrix(): Matrix;
  97093. /**
  97094. * Parse a JSON and creates the camera from the parsed information
  97095. * @param parsedCamera The JSON to parse
  97096. * @param scene The scene to instantiate the camera in
  97097. * @returns the newly constructed camera
  97098. */
  97099. static Parse(parsedCamera: any, scene: Scene): Camera;
  97100. }
  97101. }
  97102. declare module BABYLON {
  97103. /**
  97104. * Class containing static functions to help procedurally build meshes
  97105. */
  97106. export class DiscBuilder {
  97107. /**
  97108. * Creates a plane polygonal mesh. By default, this is a disc
  97109. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  97110. * * 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
  97111. * * 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
  97112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97115. * @param name defines the name of the mesh
  97116. * @param options defines the options used to create the mesh
  97117. * @param scene defines the hosting scene
  97118. * @returns the plane polygonal mesh
  97119. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  97120. */
  97121. static CreateDisc(name: string, options: {
  97122. radius?: number;
  97123. tessellation?: number;
  97124. arc?: number;
  97125. updatable?: boolean;
  97126. sideOrientation?: number;
  97127. frontUVs?: Vector4;
  97128. backUVs?: Vector4;
  97129. }, scene?: Nullable<Scene>): Mesh;
  97130. }
  97131. }
  97132. declare module BABYLON {
  97133. /**
  97134. * This represents all the required information to add a fresnel effect on a material:
  97135. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97136. */
  97137. export class FresnelParameters {
  97138. private _isEnabled;
  97139. /**
  97140. * Define if the fresnel effect is enable or not.
  97141. */
  97142. get isEnabled(): boolean;
  97143. set isEnabled(value: boolean);
  97144. /**
  97145. * Define the color used on edges (grazing angle)
  97146. */
  97147. leftColor: Color3;
  97148. /**
  97149. * Define the color used on center
  97150. */
  97151. rightColor: Color3;
  97152. /**
  97153. * Define bias applied to computed fresnel term
  97154. */
  97155. bias: number;
  97156. /**
  97157. * Defined the power exponent applied to fresnel term
  97158. */
  97159. power: number;
  97160. /**
  97161. * Clones the current fresnel and its valuues
  97162. * @returns a clone fresnel configuration
  97163. */
  97164. clone(): FresnelParameters;
  97165. /**
  97166. * Serializes the current fresnel parameters to a JSON representation.
  97167. * @return the JSON serialization
  97168. */
  97169. serialize(): any;
  97170. /**
  97171. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  97172. * @param parsedFresnelParameters Define the JSON representation
  97173. * @returns the parsed parameters
  97174. */
  97175. static Parse(parsedFresnelParameters: any): FresnelParameters;
  97176. }
  97177. }
  97178. declare module BABYLON {
  97179. /**
  97180. * Base class of materials working in push mode in babylon JS
  97181. * @hidden
  97182. */
  97183. export class PushMaterial extends Material {
  97184. protected _activeEffect: Effect;
  97185. protected _normalMatrix: Matrix;
  97186. /**
  97187. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97188. * This means that the material can keep using a previous shader while a new one is being compiled.
  97189. * This is mostly used when shader parallel compilation is supported (true by default)
  97190. */
  97191. allowShaderHotSwapping: boolean;
  97192. constructor(name: string, scene: Scene);
  97193. getEffect(): Effect;
  97194. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97195. /**
  97196. * Binds the given world matrix to the active effect
  97197. *
  97198. * @param world the matrix to bind
  97199. */
  97200. bindOnlyWorldMatrix(world: Matrix): void;
  97201. /**
  97202. * Binds the given normal matrix to the active effect
  97203. *
  97204. * @param normalMatrix the matrix to bind
  97205. */
  97206. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97207. bind(world: Matrix, mesh?: Mesh): void;
  97208. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97209. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97210. }
  97211. }
  97212. declare module BABYLON {
  97213. /**
  97214. * This groups all the flags used to control the materials channel.
  97215. */
  97216. export class MaterialFlags {
  97217. private static _DiffuseTextureEnabled;
  97218. /**
  97219. * Are diffuse textures enabled in the application.
  97220. */
  97221. static get DiffuseTextureEnabled(): boolean;
  97222. static set DiffuseTextureEnabled(value: boolean);
  97223. private static _AmbientTextureEnabled;
  97224. /**
  97225. * Are ambient textures enabled in the application.
  97226. */
  97227. static get AmbientTextureEnabled(): boolean;
  97228. static set AmbientTextureEnabled(value: boolean);
  97229. private static _OpacityTextureEnabled;
  97230. /**
  97231. * Are opacity textures enabled in the application.
  97232. */
  97233. static get OpacityTextureEnabled(): boolean;
  97234. static set OpacityTextureEnabled(value: boolean);
  97235. private static _ReflectionTextureEnabled;
  97236. /**
  97237. * Are reflection textures enabled in the application.
  97238. */
  97239. static get ReflectionTextureEnabled(): boolean;
  97240. static set ReflectionTextureEnabled(value: boolean);
  97241. private static _EmissiveTextureEnabled;
  97242. /**
  97243. * Are emissive textures enabled in the application.
  97244. */
  97245. static get EmissiveTextureEnabled(): boolean;
  97246. static set EmissiveTextureEnabled(value: boolean);
  97247. private static _SpecularTextureEnabled;
  97248. /**
  97249. * Are specular textures enabled in the application.
  97250. */
  97251. static get SpecularTextureEnabled(): boolean;
  97252. static set SpecularTextureEnabled(value: boolean);
  97253. private static _BumpTextureEnabled;
  97254. /**
  97255. * Are bump textures enabled in the application.
  97256. */
  97257. static get BumpTextureEnabled(): boolean;
  97258. static set BumpTextureEnabled(value: boolean);
  97259. private static _LightmapTextureEnabled;
  97260. /**
  97261. * Are lightmap textures enabled in the application.
  97262. */
  97263. static get LightmapTextureEnabled(): boolean;
  97264. static set LightmapTextureEnabled(value: boolean);
  97265. private static _RefractionTextureEnabled;
  97266. /**
  97267. * Are refraction textures enabled in the application.
  97268. */
  97269. static get RefractionTextureEnabled(): boolean;
  97270. static set RefractionTextureEnabled(value: boolean);
  97271. private static _ColorGradingTextureEnabled;
  97272. /**
  97273. * Are color grading textures enabled in the application.
  97274. */
  97275. static get ColorGradingTextureEnabled(): boolean;
  97276. static set ColorGradingTextureEnabled(value: boolean);
  97277. private static _FresnelEnabled;
  97278. /**
  97279. * Are fresnels enabled in the application.
  97280. */
  97281. static get FresnelEnabled(): boolean;
  97282. static set FresnelEnabled(value: boolean);
  97283. private static _ClearCoatTextureEnabled;
  97284. /**
  97285. * Are clear coat textures enabled in the application.
  97286. */
  97287. static get ClearCoatTextureEnabled(): boolean;
  97288. static set ClearCoatTextureEnabled(value: boolean);
  97289. private static _ClearCoatBumpTextureEnabled;
  97290. /**
  97291. * Are clear coat bump textures enabled in the application.
  97292. */
  97293. static get ClearCoatBumpTextureEnabled(): boolean;
  97294. static set ClearCoatBumpTextureEnabled(value: boolean);
  97295. private static _ClearCoatTintTextureEnabled;
  97296. /**
  97297. * Are clear coat tint textures enabled in the application.
  97298. */
  97299. static get ClearCoatTintTextureEnabled(): boolean;
  97300. static set ClearCoatTintTextureEnabled(value: boolean);
  97301. private static _SheenTextureEnabled;
  97302. /**
  97303. * Are sheen textures enabled in the application.
  97304. */
  97305. static get SheenTextureEnabled(): boolean;
  97306. static set SheenTextureEnabled(value: boolean);
  97307. private static _AnisotropicTextureEnabled;
  97308. /**
  97309. * Are anisotropic textures enabled in the application.
  97310. */
  97311. static get AnisotropicTextureEnabled(): boolean;
  97312. static set AnisotropicTextureEnabled(value: boolean);
  97313. private static _ThicknessTextureEnabled;
  97314. /**
  97315. * Are thickness textures enabled in the application.
  97316. */
  97317. static get ThicknessTextureEnabled(): boolean;
  97318. static set ThicknessTextureEnabled(value: boolean);
  97319. }
  97320. }
  97321. declare module BABYLON {
  97322. /** @hidden */
  97323. export var defaultFragmentDeclaration: {
  97324. name: string;
  97325. shader: string;
  97326. };
  97327. }
  97328. declare module BABYLON {
  97329. /** @hidden */
  97330. export var defaultUboDeclaration: {
  97331. name: string;
  97332. shader: string;
  97333. };
  97334. }
  97335. declare module BABYLON {
  97336. /** @hidden */
  97337. export var lightFragmentDeclaration: {
  97338. name: string;
  97339. shader: string;
  97340. };
  97341. }
  97342. declare module BABYLON {
  97343. /** @hidden */
  97344. export var lightUboDeclaration: {
  97345. name: string;
  97346. shader: string;
  97347. };
  97348. }
  97349. declare module BABYLON {
  97350. /** @hidden */
  97351. export var lightsFragmentFunctions: {
  97352. name: string;
  97353. shader: string;
  97354. };
  97355. }
  97356. declare module BABYLON {
  97357. /** @hidden */
  97358. export var shadowsFragmentFunctions: {
  97359. name: string;
  97360. shader: string;
  97361. };
  97362. }
  97363. declare module BABYLON {
  97364. /** @hidden */
  97365. export var fresnelFunction: {
  97366. name: string;
  97367. shader: string;
  97368. };
  97369. }
  97370. declare module BABYLON {
  97371. /** @hidden */
  97372. export var reflectionFunction: {
  97373. name: string;
  97374. shader: string;
  97375. };
  97376. }
  97377. declare module BABYLON {
  97378. /** @hidden */
  97379. export var bumpFragmentFunctions: {
  97380. name: string;
  97381. shader: string;
  97382. };
  97383. }
  97384. declare module BABYLON {
  97385. /** @hidden */
  97386. export var logDepthDeclaration: {
  97387. name: string;
  97388. shader: string;
  97389. };
  97390. }
  97391. declare module BABYLON {
  97392. /** @hidden */
  97393. export var bumpFragment: {
  97394. name: string;
  97395. shader: string;
  97396. };
  97397. }
  97398. declare module BABYLON {
  97399. /** @hidden */
  97400. export var depthPrePass: {
  97401. name: string;
  97402. shader: string;
  97403. };
  97404. }
  97405. declare module BABYLON {
  97406. /** @hidden */
  97407. export var lightFragment: {
  97408. name: string;
  97409. shader: string;
  97410. };
  97411. }
  97412. declare module BABYLON {
  97413. /** @hidden */
  97414. export var logDepthFragment: {
  97415. name: string;
  97416. shader: string;
  97417. };
  97418. }
  97419. declare module BABYLON {
  97420. /** @hidden */
  97421. export var defaultPixelShader: {
  97422. name: string;
  97423. shader: string;
  97424. };
  97425. }
  97426. declare module BABYLON {
  97427. /** @hidden */
  97428. export var defaultVertexDeclaration: {
  97429. name: string;
  97430. shader: string;
  97431. };
  97432. }
  97433. declare module BABYLON {
  97434. /** @hidden */
  97435. export var bumpVertexDeclaration: {
  97436. name: string;
  97437. shader: string;
  97438. };
  97439. }
  97440. declare module BABYLON {
  97441. /** @hidden */
  97442. export var bumpVertex: {
  97443. name: string;
  97444. shader: string;
  97445. };
  97446. }
  97447. declare module BABYLON {
  97448. /** @hidden */
  97449. export var fogVertex: {
  97450. name: string;
  97451. shader: string;
  97452. };
  97453. }
  97454. declare module BABYLON {
  97455. /** @hidden */
  97456. export var shadowsVertex: {
  97457. name: string;
  97458. shader: string;
  97459. };
  97460. }
  97461. declare module BABYLON {
  97462. /** @hidden */
  97463. export var pointCloudVertex: {
  97464. name: string;
  97465. shader: string;
  97466. };
  97467. }
  97468. declare module BABYLON {
  97469. /** @hidden */
  97470. export var logDepthVertex: {
  97471. name: string;
  97472. shader: string;
  97473. };
  97474. }
  97475. declare module BABYLON {
  97476. /** @hidden */
  97477. export var defaultVertexShader: {
  97478. name: string;
  97479. shader: string;
  97480. };
  97481. }
  97482. declare module BABYLON {
  97483. /** @hidden */
  97484. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97485. MAINUV1: boolean;
  97486. MAINUV2: boolean;
  97487. DIFFUSE: boolean;
  97488. DIFFUSEDIRECTUV: number;
  97489. AMBIENT: boolean;
  97490. AMBIENTDIRECTUV: number;
  97491. OPACITY: boolean;
  97492. OPACITYDIRECTUV: number;
  97493. OPACITYRGB: boolean;
  97494. REFLECTION: boolean;
  97495. EMISSIVE: boolean;
  97496. EMISSIVEDIRECTUV: number;
  97497. SPECULAR: boolean;
  97498. SPECULARDIRECTUV: number;
  97499. BUMP: boolean;
  97500. BUMPDIRECTUV: number;
  97501. PARALLAX: boolean;
  97502. PARALLAXOCCLUSION: boolean;
  97503. SPECULAROVERALPHA: boolean;
  97504. CLIPPLANE: boolean;
  97505. CLIPPLANE2: boolean;
  97506. CLIPPLANE3: boolean;
  97507. CLIPPLANE4: boolean;
  97508. CLIPPLANE5: boolean;
  97509. CLIPPLANE6: boolean;
  97510. ALPHATEST: boolean;
  97511. DEPTHPREPASS: boolean;
  97512. ALPHAFROMDIFFUSE: boolean;
  97513. POINTSIZE: boolean;
  97514. FOG: boolean;
  97515. SPECULARTERM: boolean;
  97516. DIFFUSEFRESNEL: boolean;
  97517. OPACITYFRESNEL: boolean;
  97518. REFLECTIONFRESNEL: boolean;
  97519. REFRACTIONFRESNEL: boolean;
  97520. EMISSIVEFRESNEL: boolean;
  97521. FRESNEL: boolean;
  97522. NORMAL: boolean;
  97523. UV1: boolean;
  97524. UV2: boolean;
  97525. VERTEXCOLOR: boolean;
  97526. VERTEXALPHA: boolean;
  97527. NUM_BONE_INFLUENCERS: number;
  97528. BonesPerMesh: number;
  97529. BONETEXTURE: boolean;
  97530. INSTANCES: boolean;
  97531. GLOSSINESS: boolean;
  97532. ROUGHNESS: boolean;
  97533. EMISSIVEASILLUMINATION: boolean;
  97534. LINKEMISSIVEWITHDIFFUSE: boolean;
  97535. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97536. LIGHTMAP: boolean;
  97537. LIGHTMAPDIRECTUV: number;
  97538. OBJECTSPACE_NORMALMAP: boolean;
  97539. USELIGHTMAPASSHADOWMAP: boolean;
  97540. REFLECTIONMAP_3D: boolean;
  97541. REFLECTIONMAP_SPHERICAL: boolean;
  97542. REFLECTIONMAP_PLANAR: boolean;
  97543. REFLECTIONMAP_CUBIC: boolean;
  97544. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97545. REFLECTIONMAP_PROJECTION: boolean;
  97546. REFLECTIONMAP_SKYBOX: boolean;
  97547. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97548. REFLECTIONMAP_EXPLICIT: boolean;
  97549. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97550. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97551. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97552. INVERTCUBICMAP: boolean;
  97553. LOGARITHMICDEPTH: boolean;
  97554. REFRACTION: boolean;
  97555. REFRACTIONMAP_3D: boolean;
  97556. REFLECTIONOVERALPHA: boolean;
  97557. TWOSIDEDLIGHTING: boolean;
  97558. SHADOWFLOAT: boolean;
  97559. MORPHTARGETS: boolean;
  97560. MORPHTARGETS_NORMAL: boolean;
  97561. MORPHTARGETS_TANGENT: boolean;
  97562. MORPHTARGETS_UV: boolean;
  97563. NUM_MORPH_INFLUENCERS: number;
  97564. NONUNIFORMSCALING: boolean;
  97565. PREMULTIPLYALPHA: boolean;
  97566. IMAGEPROCESSING: boolean;
  97567. VIGNETTE: boolean;
  97568. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97569. VIGNETTEBLENDMODEOPAQUE: boolean;
  97570. TONEMAPPING: boolean;
  97571. TONEMAPPING_ACES: boolean;
  97572. CONTRAST: boolean;
  97573. COLORCURVES: boolean;
  97574. COLORGRADING: boolean;
  97575. COLORGRADING3D: boolean;
  97576. SAMPLER3DGREENDEPTH: boolean;
  97577. SAMPLER3DBGRMAP: boolean;
  97578. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97579. MULTIVIEW: boolean;
  97580. /**
  97581. * If the reflection texture on this material is in linear color space
  97582. * @hidden
  97583. */
  97584. IS_REFLECTION_LINEAR: boolean;
  97585. /**
  97586. * If the refraction texture on this material is in linear color space
  97587. * @hidden
  97588. */
  97589. IS_REFRACTION_LINEAR: boolean;
  97590. EXPOSURE: boolean;
  97591. constructor();
  97592. setReflectionMode(modeToEnable: string): void;
  97593. }
  97594. /**
  97595. * This is the default material used in Babylon. It is the best trade off between quality
  97596. * and performances.
  97597. * @see http://doc.babylonjs.com/babylon101/materials
  97598. */
  97599. export class StandardMaterial extends PushMaterial {
  97600. private _diffuseTexture;
  97601. /**
  97602. * The basic texture of the material as viewed under a light.
  97603. */
  97604. diffuseTexture: Nullable<BaseTexture>;
  97605. private _ambientTexture;
  97606. /**
  97607. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97608. */
  97609. ambientTexture: Nullable<BaseTexture>;
  97610. private _opacityTexture;
  97611. /**
  97612. * Define the transparency of the material from a texture.
  97613. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97614. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97615. */
  97616. opacityTexture: Nullable<BaseTexture>;
  97617. private _reflectionTexture;
  97618. /**
  97619. * Define the texture used to display the reflection.
  97620. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97621. */
  97622. reflectionTexture: Nullable<BaseTexture>;
  97623. private _emissiveTexture;
  97624. /**
  97625. * Define texture of the material as if self lit.
  97626. * This will be mixed in the final result even in the absence of light.
  97627. */
  97628. emissiveTexture: Nullable<BaseTexture>;
  97629. private _specularTexture;
  97630. /**
  97631. * Define how the color and intensity of the highlight given by the light in the material.
  97632. */
  97633. specularTexture: Nullable<BaseTexture>;
  97634. private _bumpTexture;
  97635. /**
  97636. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97637. * 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.
  97638. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97639. */
  97640. bumpTexture: Nullable<BaseTexture>;
  97641. private _lightmapTexture;
  97642. /**
  97643. * Complex lighting can be computationally expensive to compute at runtime.
  97644. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97645. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97646. */
  97647. lightmapTexture: Nullable<BaseTexture>;
  97648. private _refractionTexture;
  97649. /**
  97650. * Define the texture used to display the refraction.
  97651. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97652. */
  97653. refractionTexture: Nullable<BaseTexture>;
  97654. /**
  97655. * The color of the material lit by the environmental background lighting.
  97656. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97657. */
  97658. ambientColor: Color3;
  97659. /**
  97660. * The basic color of the material as viewed under a light.
  97661. */
  97662. diffuseColor: Color3;
  97663. /**
  97664. * Define how the color and intensity of the highlight given by the light in the material.
  97665. */
  97666. specularColor: Color3;
  97667. /**
  97668. * Define the color of the material as if self lit.
  97669. * This will be mixed in the final result even in the absence of light.
  97670. */
  97671. emissiveColor: Color3;
  97672. /**
  97673. * Defines how sharp are the highlights in the material.
  97674. * The bigger the value the sharper giving a more glossy feeling to the result.
  97675. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97676. */
  97677. specularPower: number;
  97678. private _useAlphaFromDiffuseTexture;
  97679. /**
  97680. * Does the transparency come from the diffuse texture alpha channel.
  97681. */
  97682. useAlphaFromDiffuseTexture: boolean;
  97683. private _useEmissiveAsIllumination;
  97684. /**
  97685. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97686. */
  97687. useEmissiveAsIllumination: boolean;
  97688. private _linkEmissiveWithDiffuse;
  97689. /**
  97690. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97691. * the emissive level when the final color is close to one.
  97692. */
  97693. linkEmissiveWithDiffuse: boolean;
  97694. private _useSpecularOverAlpha;
  97695. /**
  97696. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97697. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97698. */
  97699. useSpecularOverAlpha: boolean;
  97700. private _useReflectionOverAlpha;
  97701. /**
  97702. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97703. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97704. */
  97705. useReflectionOverAlpha: boolean;
  97706. private _disableLighting;
  97707. /**
  97708. * Does lights from the scene impacts this material.
  97709. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97710. */
  97711. disableLighting: boolean;
  97712. private _useObjectSpaceNormalMap;
  97713. /**
  97714. * Allows using an object space normal map (instead of tangent space).
  97715. */
  97716. useObjectSpaceNormalMap: boolean;
  97717. private _useParallax;
  97718. /**
  97719. * Is parallax enabled or not.
  97720. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97721. */
  97722. useParallax: boolean;
  97723. private _useParallaxOcclusion;
  97724. /**
  97725. * Is parallax occlusion enabled or not.
  97726. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97727. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97728. */
  97729. useParallaxOcclusion: boolean;
  97730. /**
  97731. * 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.
  97732. */
  97733. parallaxScaleBias: number;
  97734. private _roughness;
  97735. /**
  97736. * Helps to define how blurry the reflections should appears in the material.
  97737. */
  97738. roughness: number;
  97739. /**
  97740. * In case of refraction, define the value of the index of refraction.
  97741. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97742. */
  97743. indexOfRefraction: number;
  97744. /**
  97745. * Invert the refraction texture alongside the y axis.
  97746. * It can be useful with procedural textures or probe for instance.
  97747. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97748. */
  97749. invertRefractionY: boolean;
  97750. /**
  97751. * Defines the alpha limits in alpha test mode.
  97752. */
  97753. alphaCutOff: number;
  97754. private _useLightmapAsShadowmap;
  97755. /**
  97756. * In case of light mapping, define whether the map contains light or shadow informations.
  97757. */
  97758. useLightmapAsShadowmap: boolean;
  97759. private _diffuseFresnelParameters;
  97760. /**
  97761. * Define the diffuse fresnel parameters of the material.
  97762. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97763. */
  97764. diffuseFresnelParameters: FresnelParameters;
  97765. private _opacityFresnelParameters;
  97766. /**
  97767. * Define the opacity fresnel parameters of the material.
  97768. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97769. */
  97770. opacityFresnelParameters: FresnelParameters;
  97771. private _reflectionFresnelParameters;
  97772. /**
  97773. * Define the reflection fresnel parameters of the material.
  97774. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97775. */
  97776. reflectionFresnelParameters: FresnelParameters;
  97777. private _refractionFresnelParameters;
  97778. /**
  97779. * Define the refraction fresnel parameters of the material.
  97780. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97781. */
  97782. refractionFresnelParameters: FresnelParameters;
  97783. private _emissiveFresnelParameters;
  97784. /**
  97785. * Define the emissive fresnel parameters of the material.
  97786. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97787. */
  97788. emissiveFresnelParameters: FresnelParameters;
  97789. private _useReflectionFresnelFromSpecular;
  97790. /**
  97791. * If true automatically deducts the fresnels values from the material specularity.
  97792. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97793. */
  97794. useReflectionFresnelFromSpecular: boolean;
  97795. private _useGlossinessFromSpecularMapAlpha;
  97796. /**
  97797. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97798. */
  97799. useGlossinessFromSpecularMapAlpha: boolean;
  97800. private _maxSimultaneousLights;
  97801. /**
  97802. * Defines the maximum number of lights that can be used in the material
  97803. */
  97804. maxSimultaneousLights: number;
  97805. private _invertNormalMapX;
  97806. /**
  97807. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97808. */
  97809. invertNormalMapX: boolean;
  97810. private _invertNormalMapY;
  97811. /**
  97812. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97813. */
  97814. invertNormalMapY: boolean;
  97815. private _twoSidedLighting;
  97816. /**
  97817. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97818. */
  97819. twoSidedLighting: boolean;
  97820. /**
  97821. * Default configuration related to image processing available in the standard Material.
  97822. */
  97823. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97824. /**
  97825. * Gets the image processing configuration used either in this material.
  97826. */
  97827. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  97828. /**
  97829. * Sets the Default image processing configuration used either in the this material.
  97830. *
  97831. * If sets to null, the scene one is in use.
  97832. */
  97833. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  97834. /**
  97835. * Keep track of the image processing observer to allow dispose and replace.
  97836. */
  97837. private _imageProcessingObserver;
  97838. /**
  97839. * Attaches a new image processing configuration to the Standard Material.
  97840. * @param configuration
  97841. */
  97842. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97843. /**
  97844. * Gets wether the color curves effect is enabled.
  97845. */
  97846. get cameraColorCurvesEnabled(): boolean;
  97847. /**
  97848. * Sets wether the color curves effect is enabled.
  97849. */
  97850. set cameraColorCurvesEnabled(value: boolean);
  97851. /**
  97852. * Gets wether the color grading effect is enabled.
  97853. */
  97854. get cameraColorGradingEnabled(): boolean;
  97855. /**
  97856. * Gets wether the color grading effect is enabled.
  97857. */
  97858. set cameraColorGradingEnabled(value: boolean);
  97859. /**
  97860. * Gets wether tonemapping is enabled or not.
  97861. */
  97862. get cameraToneMappingEnabled(): boolean;
  97863. /**
  97864. * Sets wether tonemapping is enabled or not
  97865. */
  97866. set cameraToneMappingEnabled(value: boolean);
  97867. /**
  97868. * The camera exposure used on this material.
  97869. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97870. * This corresponds to a photographic exposure.
  97871. */
  97872. get cameraExposure(): number;
  97873. /**
  97874. * The camera exposure used on this material.
  97875. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97876. * This corresponds to a photographic exposure.
  97877. */
  97878. set cameraExposure(value: number);
  97879. /**
  97880. * Gets The camera contrast used on this material.
  97881. */
  97882. get cameraContrast(): number;
  97883. /**
  97884. * Sets The camera contrast used on this material.
  97885. */
  97886. set cameraContrast(value: number);
  97887. /**
  97888. * Gets the Color Grading 2D Lookup Texture.
  97889. */
  97890. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  97891. /**
  97892. * Sets the Color Grading 2D Lookup Texture.
  97893. */
  97894. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  97895. /**
  97896. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97897. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97898. * 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;
  97899. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97900. */
  97901. get cameraColorCurves(): Nullable<ColorCurves>;
  97902. /**
  97903. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97904. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97905. * 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;
  97906. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97907. */
  97908. set cameraColorCurves(value: Nullable<ColorCurves>);
  97909. /**
  97910. * Custom callback helping to override the default shader used in the material.
  97911. */
  97912. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97913. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97914. protected _worldViewProjectionMatrix: Matrix;
  97915. protected _globalAmbientColor: Color3;
  97916. protected _useLogarithmicDepth: boolean;
  97917. protected _rebuildInParallel: boolean;
  97918. /**
  97919. * Instantiates a new standard material.
  97920. * This is the default material used in Babylon. It is the best trade off between quality
  97921. * and performances.
  97922. * @see http://doc.babylonjs.com/babylon101/materials
  97923. * @param name Define the name of the material in the scene
  97924. * @param scene Define the scene the material belong to
  97925. */
  97926. constructor(name: string, scene: Scene);
  97927. /**
  97928. * Gets a boolean indicating that current material needs to register RTT
  97929. */
  97930. get hasRenderTargetTextures(): boolean;
  97931. /**
  97932. * Gets the current class name of the material e.g. "StandardMaterial"
  97933. * Mainly use in serialization.
  97934. * @returns the class name
  97935. */
  97936. getClassName(): string;
  97937. /**
  97938. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97939. * You can try switching to logarithmic depth.
  97940. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97941. */
  97942. get useLogarithmicDepth(): boolean;
  97943. set useLogarithmicDepth(value: boolean);
  97944. /**
  97945. * Specifies if the material will require alpha blending
  97946. * @returns a boolean specifying if alpha blending is needed
  97947. */
  97948. needAlphaBlending(): boolean;
  97949. /**
  97950. * Specifies if this material should be rendered in alpha test mode
  97951. * @returns a boolean specifying if an alpha test is needed.
  97952. */
  97953. needAlphaTesting(): boolean;
  97954. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97955. /**
  97956. * Get the texture used for alpha test purpose.
  97957. * @returns the diffuse texture in case of the standard material.
  97958. */
  97959. getAlphaTestTexture(): Nullable<BaseTexture>;
  97960. /**
  97961. * Get if the submesh is ready to be used and all its information available.
  97962. * Child classes can use it to update shaders
  97963. * @param mesh defines the mesh to check
  97964. * @param subMesh defines which submesh to check
  97965. * @param useInstances specifies that instances should be used
  97966. * @returns a boolean indicating that the submesh is ready or not
  97967. */
  97968. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97969. /**
  97970. * Builds the material UBO layouts.
  97971. * Used internally during the effect preparation.
  97972. */
  97973. buildUniformLayout(): void;
  97974. /**
  97975. * Unbinds the material from the mesh
  97976. */
  97977. unbind(): void;
  97978. /**
  97979. * Binds the submesh to this material by preparing the effect and shader to draw
  97980. * @param world defines the world transformation matrix
  97981. * @param mesh defines the mesh containing the submesh
  97982. * @param subMesh defines the submesh to bind the material to
  97983. */
  97984. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97985. /**
  97986. * Get the list of animatables in the material.
  97987. * @returns the list of animatables object used in the material
  97988. */
  97989. getAnimatables(): IAnimatable[];
  97990. /**
  97991. * Gets the active textures from the material
  97992. * @returns an array of textures
  97993. */
  97994. getActiveTextures(): BaseTexture[];
  97995. /**
  97996. * Specifies if the material uses a texture
  97997. * @param texture defines the texture to check against the material
  97998. * @returns a boolean specifying if the material uses the texture
  97999. */
  98000. hasTexture(texture: BaseTexture): boolean;
  98001. /**
  98002. * Disposes the material
  98003. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98004. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98005. */
  98006. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98007. /**
  98008. * Makes a duplicate of the material, and gives it a new name
  98009. * @param name defines the new name for the duplicated material
  98010. * @returns the cloned material
  98011. */
  98012. clone(name: string): StandardMaterial;
  98013. /**
  98014. * Serializes this material in a JSON representation
  98015. * @returns the serialized material object
  98016. */
  98017. serialize(): any;
  98018. /**
  98019. * Creates a standard material from parsed material data
  98020. * @param source defines the JSON representation of the material
  98021. * @param scene defines the hosting scene
  98022. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98023. * @returns a new standard material
  98024. */
  98025. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98026. /**
  98027. * Are diffuse textures enabled in the application.
  98028. */
  98029. static get DiffuseTextureEnabled(): boolean;
  98030. static set DiffuseTextureEnabled(value: boolean);
  98031. /**
  98032. * Are ambient textures enabled in the application.
  98033. */
  98034. static get AmbientTextureEnabled(): boolean;
  98035. static set AmbientTextureEnabled(value: boolean);
  98036. /**
  98037. * Are opacity textures enabled in the application.
  98038. */
  98039. static get OpacityTextureEnabled(): boolean;
  98040. static set OpacityTextureEnabled(value: boolean);
  98041. /**
  98042. * Are reflection textures enabled in the application.
  98043. */
  98044. static get ReflectionTextureEnabled(): boolean;
  98045. static set ReflectionTextureEnabled(value: boolean);
  98046. /**
  98047. * Are emissive textures enabled in the application.
  98048. */
  98049. static get EmissiveTextureEnabled(): boolean;
  98050. static set EmissiveTextureEnabled(value: boolean);
  98051. /**
  98052. * Are specular textures enabled in the application.
  98053. */
  98054. static get SpecularTextureEnabled(): boolean;
  98055. static set SpecularTextureEnabled(value: boolean);
  98056. /**
  98057. * Are bump textures enabled in the application.
  98058. */
  98059. static get BumpTextureEnabled(): boolean;
  98060. static set BumpTextureEnabled(value: boolean);
  98061. /**
  98062. * Are lightmap textures enabled in the application.
  98063. */
  98064. static get LightmapTextureEnabled(): boolean;
  98065. static set LightmapTextureEnabled(value: boolean);
  98066. /**
  98067. * Are refraction textures enabled in the application.
  98068. */
  98069. static get RefractionTextureEnabled(): boolean;
  98070. static set RefractionTextureEnabled(value: boolean);
  98071. /**
  98072. * Are color grading textures enabled in the application.
  98073. */
  98074. static get ColorGradingTextureEnabled(): boolean;
  98075. static set ColorGradingTextureEnabled(value: boolean);
  98076. /**
  98077. * Are fresnels enabled in the application.
  98078. */
  98079. static get FresnelEnabled(): boolean;
  98080. static set FresnelEnabled(value: boolean);
  98081. }
  98082. }
  98083. declare module BABYLON {
  98084. /**
  98085. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  98086. *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.
  98087. * The SPS is also a particle system. It provides some methods to manage the particles.
  98088. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  98089. *
  98090. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  98091. */
  98092. export class SolidParticleSystem implements IDisposable {
  98093. /**
  98094. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  98095. * Example : var p = SPS.particles[i];
  98096. */
  98097. particles: SolidParticle[];
  98098. /**
  98099. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  98100. */
  98101. nbParticles: number;
  98102. /**
  98103. * If the particles must ever face the camera (default false). Useful for planar particles.
  98104. */
  98105. billboard: boolean;
  98106. /**
  98107. * Recompute normals when adding a shape
  98108. */
  98109. recomputeNormals: boolean;
  98110. /**
  98111. * This a counter ofr your own usage. It's not set by any SPS functions.
  98112. */
  98113. counter: number;
  98114. /**
  98115. * The SPS name. This name is also given to the underlying mesh.
  98116. */
  98117. name: string;
  98118. /**
  98119. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  98120. */
  98121. mesh: Mesh;
  98122. /**
  98123. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  98124. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  98125. */
  98126. vars: any;
  98127. /**
  98128. * This array is populated when the SPS is set as 'pickable'.
  98129. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  98130. * Each element of this array is an object `{idx: int, faceId: int}`.
  98131. * `idx` is the picked particle index in the `SPS.particles` array
  98132. * `faceId` is the picked face index counted within this particle.
  98133. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  98134. */
  98135. pickedParticles: {
  98136. idx: number;
  98137. faceId: number;
  98138. }[];
  98139. /**
  98140. * This array is populated when `enableDepthSort` is set to true.
  98141. * Each element of this array is an instance of the class DepthSortedParticle.
  98142. */
  98143. depthSortedParticles: DepthSortedParticle[];
  98144. /**
  98145. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  98146. * @hidden
  98147. */
  98148. _bSphereOnly: boolean;
  98149. /**
  98150. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  98151. * @hidden
  98152. */
  98153. _bSphereRadiusFactor: number;
  98154. private _scene;
  98155. private _positions;
  98156. private _indices;
  98157. private _normals;
  98158. private _colors;
  98159. private _uvs;
  98160. private _indices32;
  98161. private _positions32;
  98162. private _normals32;
  98163. private _fixedNormal32;
  98164. private _colors32;
  98165. private _uvs32;
  98166. private _index;
  98167. private _updatable;
  98168. private _pickable;
  98169. private _isVisibilityBoxLocked;
  98170. private _alwaysVisible;
  98171. private _depthSort;
  98172. private _expandable;
  98173. private _shapeCounter;
  98174. private _copy;
  98175. private _color;
  98176. private _computeParticleColor;
  98177. private _computeParticleTexture;
  98178. private _computeParticleRotation;
  98179. private _computeParticleVertex;
  98180. private _computeBoundingBox;
  98181. private _depthSortParticles;
  98182. private _camera;
  98183. private _mustUnrotateFixedNormals;
  98184. private _particlesIntersect;
  98185. private _needs32Bits;
  98186. private _isNotBuilt;
  98187. private _lastParticleId;
  98188. private _idxOfId;
  98189. private _multimaterialEnabled;
  98190. private _useModelMaterial;
  98191. private _indicesByMaterial;
  98192. private _materialIndexes;
  98193. private _depthSortFunction;
  98194. private _materialSortFunction;
  98195. private _materials;
  98196. private _multimaterial;
  98197. private _materialIndexesById;
  98198. private _defaultMaterial;
  98199. private _autoUpdateSubMeshes;
  98200. /**
  98201. * Creates a SPS (Solid Particle System) object.
  98202. * @param name (String) is the SPS name, this will be the underlying mesh name.
  98203. * @param scene (Scene) is the scene in which the SPS is added.
  98204. * @param options defines the options of the sps e.g.
  98205. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  98206. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  98207. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  98208. * * 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.
  98209. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  98210. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  98211. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  98212. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  98213. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  98214. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  98215. */
  98216. constructor(name: string, scene: Scene, options?: {
  98217. updatable?: boolean;
  98218. isPickable?: boolean;
  98219. enableDepthSort?: boolean;
  98220. particleIntersection?: boolean;
  98221. boundingSphereOnly?: boolean;
  98222. bSphereRadiusFactor?: number;
  98223. expandable?: boolean;
  98224. useModelMaterial?: boolean;
  98225. enableMultiMaterial?: boolean;
  98226. });
  98227. /**
  98228. * Builds the SPS underlying mesh. Returns a standard Mesh.
  98229. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  98230. * @returns the created mesh
  98231. */
  98232. buildMesh(): Mesh;
  98233. /**
  98234. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  98235. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  98236. * Thus the particles generated from `digest()` have their property `position` set yet.
  98237. * @param mesh ( Mesh ) is the mesh to be digested
  98238. * @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
  98239. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  98240. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  98241. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  98242. * @returns the current SPS
  98243. */
  98244. digest(mesh: Mesh, options?: {
  98245. facetNb?: number;
  98246. number?: number;
  98247. delta?: number;
  98248. storage?: [];
  98249. }): SolidParticleSystem;
  98250. /**
  98251. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  98252. * @hidden
  98253. */
  98254. private _unrotateFixedNormals;
  98255. /**
  98256. * Resets the temporary working copy particle
  98257. * @hidden
  98258. */
  98259. private _resetCopy;
  98260. /**
  98261. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  98262. * @param p the current index in the positions array to be updated
  98263. * @param ind the current index in the indices array
  98264. * @param shape a Vector3 array, the shape geometry
  98265. * @param positions the positions array to be updated
  98266. * @param meshInd the shape indices array
  98267. * @param indices the indices array to be updated
  98268. * @param meshUV the shape uv array
  98269. * @param uvs the uv array to be updated
  98270. * @param meshCol the shape color array
  98271. * @param colors the color array to be updated
  98272. * @param meshNor the shape normals array
  98273. * @param normals the normals array to be updated
  98274. * @param idx the particle index
  98275. * @param idxInShape the particle index in its shape
  98276. * @param options the addShape() method passed options
  98277. * @model the particle model
  98278. * @hidden
  98279. */
  98280. private _meshBuilder;
  98281. /**
  98282. * Returns a shape Vector3 array from positions float array
  98283. * @param positions float array
  98284. * @returns a vector3 array
  98285. * @hidden
  98286. */
  98287. private _posToShape;
  98288. /**
  98289. * Returns a shapeUV array from a float uvs (array deep copy)
  98290. * @param uvs as a float array
  98291. * @returns a shapeUV array
  98292. * @hidden
  98293. */
  98294. private _uvsToShapeUV;
  98295. /**
  98296. * Adds a new particle object in the particles array
  98297. * @param idx particle index in particles array
  98298. * @param id particle id
  98299. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  98300. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  98301. * @param model particle ModelShape object
  98302. * @param shapeId model shape identifier
  98303. * @param idxInShape index of the particle in the current model
  98304. * @param bInfo model bounding info object
  98305. * @param storage target storage array, if any
  98306. * @hidden
  98307. */
  98308. private _addParticle;
  98309. /**
  98310. * Adds some particles to the SPS from the model shape. Returns the shape id.
  98311. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  98312. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  98313. * @param nb (positive integer) the number of particles to be created from this model
  98314. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  98315. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  98316. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  98317. * @returns the number of shapes in the system
  98318. */
  98319. addShape(mesh: Mesh, nb: number, options?: {
  98320. positionFunction?: any;
  98321. vertexFunction?: any;
  98322. storage?: [];
  98323. }): number;
  98324. /**
  98325. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  98326. * @hidden
  98327. */
  98328. private _rebuildParticle;
  98329. /**
  98330. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  98331. * @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.
  98332. * @returns the SPS.
  98333. */
  98334. rebuildMesh(reset?: boolean): SolidParticleSystem;
  98335. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  98336. * Returns an array with the removed particles.
  98337. * 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.
  98338. * The SPS can't be empty so at least one particle needs to remain in place.
  98339. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  98340. * @param start index of the first particle to remove
  98341. * @param end index of the last particle to remove (included)
  98342. * @returns an array populated with the removed particles
  98343. */
  98344. removeParticles(start: number, end: number): SolidParticle[];
  98345. /**
  98346. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  98347. * @param solidParticleArray an array populated with Solid Particles objects
  98348. * @returns the SPS
  98349. */
  98350. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  98351. /**
  98352. * Creates a new particle and modifies the SPS mesh geometry :
  98353. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  98354. * - calls _addParticle() to populate the particle array
  98355. * factorized code from addShape() and insertParticlesFromArray()
  98356. * @param idx particle index in the particles array
  98357. * @param i particle index in its shape
  98358. * @param modelShape particle ModelShape object
  98359. * @param shape shape vertex array
  98360. * @param meshInd shape indices array
  98361. * @param meshUV shape uv array
  98362. * @param meshCol shape color array
  98363. * @param meshNor shape normals array
  98364. * @param bbInfo shape bounding info
  98365. * @param storage target particle storage
  98366. * @options addShape() passed options
  98367. * @hidden
  98368. */
  98369. private _insertNewParticle;
  98370. /**
  98371. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  98372. * This method calls `updateParticle()` for each particle of the SPS.
  98373. * For an animated SPS, it is usually called within the render loop.
  98374. * 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.
  98375. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  98376. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  98377. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  98378. * @returns the SPS.
  98379. */
  98380. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  98381. /**
  98382. * Disposes the SPS.
  98383. */
  98384. dispose(): void;
  98385. /**
  98386. * Returns a SolidParticle object from its identifier : particle.id
  98387. * @param id (integer) the particle Id
  98388. * @returns the searched particle or null if not found in the SPS.
  98389. */
  98390. getParticleById(id: number): Nullable<SolidParticle>;
  98391. /**
  98392. * Returns a new array populated with the particles having the passed shapeId.
  98393. * @param shapeId (integer) the shape identifier
  98394. * @returns a new solid particle array
  98395. */
  98396. getParticlesByShapeId(shapeId: number): SolidParticle[];
  98397. /**
  98398. * Populates the passed array "ref" with the particles having the passed shapeId.
  98399. * @param shapeId the shape identifier
  98400. * @returns the SPS
  98401. * @param ref
  98402. */
  98403. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  98404. /**
  98405. * Computes the required SubMeshes according the materials assigned to the particles.
  98406. * @returns the solid particle system.
  98407. * Does nothing if called before the SPS mesh is built.
  98408. */
  98409. computeSubMeshes(): SolidParticleSystem;
  98410. /**
  98411. * Sorts the solid particles by material when MultiMaterial is enabled.
  98412. * Updates the indices32 array.
  98413. * Updates the indicesByMaterial array.
  98414. * Updates the mesh indices array.
  98415. * @returns the SPS
  98416. * @hidden
  98417. */
  98418. private _sortParticlesByMaterial;
  98419. /**
  98420. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  98421. * @hidden
  98422. */
  98423. private _setMaterialIndexesById;
  98424. /**
  98425. * Returns an array with unique values of Materials from the passed array
  98426. * @param array the material array to be checked and filtered
  98427. * @hidden
  98428. */
  98429. private _filterUniqueMaterialId;
  98430. /**
  98431. * Sets a new Standard Material as _defaultMaterial if not already set.
  98432. * @hidden
  98433. */
  98434. private _setDefaultMaterial;
  98435. /**
  98436. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  98437. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98438. * @returns the SPS.
  98439. */
  98440. refreshVisibleSize(): SolidParticleSystem;
  98441. /**
  98442. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  98443. * @param size the size (float) of the visibility box
  98444. * note : this doesn't lock the SPS mesh bounding box.
  98445. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98446. */
  98447. setVisibilityBox(size: number): void;
  98448. /**
  98449. * Gets whether the SPS as always visible or not
  98450. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98451. */
  98452. get isAlwaysVisible(): boolean;
  98453. /**
  98454. * Sets the SPS as always visible or not
  98455. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98456. */
  98457. set isAlwaysVisible(val: boolean);
  98458. /**
  98459. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  98460. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98461. */
  98462. set isVisibilityBoxLocked(val: boolean);
  98463. /**
  98464. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  98465. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98466. */
  98467. get isVisibilityBoxLocked(): boolean;
  98468. /**
  98469. * Tells to `setParticles()` to compute the particle rotations or not.
  98470. * Default value : true. The SPS is faster when it's set to false.
  98471. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  98472. */
  98473. set computeParticleRotation(val: boolean);
  98474. /**
  98475. * Tells to `setParticles()` to compute the particle colors or not.
  98476. * Default value : true. The SPS is faster when it's set to false.
  98477. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  98478. */
  98479. set computeParticleColor(val: boolean);
  98480. set computeParticleTexture(val: boolean);
  98481. /**
  98482. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  98483. * Default value : false. The SPS is faster when it's set to false.
  98484. * Note : the particle custom vertex positions aren't stored values.
  98485. */
  98486. set computeParticleVertex(val: boolean);
  98487. /**
  98488. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  98489. */
  98490. set computeBoundingBox(val: boolean);
  98491. /**
  98492. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  98493. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  98494. * Default : `true`
  98495. */
  98496. set depthSortParticles(val: boolean);
  98497. /**
  98498. * Gets if `setParticles()` computes the particle rotations or not.
  98499. * Default value : true. The SPS is faster when it's set to false.
  98500. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  98501. */
  98502. get computeParticleRotation(): boolean;
  98503. /**
  98504. * Gets if `setParticles()` computes the particle colors or not.
  98505. * Default value : true. The SPS is faster when it's set to false.
  98506. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  98507. */
  98508. get computeParticleColor(): boolean;
  98509. /**
  98510. * Gets if `setParticles()` computes the particle textures or not.
  98511. * Default value : true. The SPS is faster when it's set to false.
  98512. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  98513. */
  98514. get computeParticleTexture(): boolean;
  98515. /**
  98516. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  98517. * Default value : false. The SPS is faster when it's set to false.
  98518. * Note : the particle custom vertex positions aren't stored values.
  98519. */
  98520. get computeParticleVertex(): boolean;
  98521. /**
  98522. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  98523. */
  98524. get computeBoundingBox(): boolean;
  98525. /**
  98526. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  98527. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  98528. * Default : `true`
  98529. */
  98530. get depthSortParticles(): boolean;
  98531. /**
  98532. * Gets if the SPS is created as expandable at construction time.
  98533. * Default : `false`
  98534. */
  98535. get expandable(): boolean;
  98536. /**
  98537. * Gets if the SPS supports the Multi Materials
  98538. */
  98539. get multimaterialEnabled(): boolean;
  98540. /**
  98541. * Gets if the SPS uses the model materials for its own multimaterial.
  98542. */
  98543. get useModelMaterial(): boolean;
  98544. /**
  98545. * The SPS used material array.
  98546. */
  98547. get materials(): Material[];
  98548. /**
  98549. * Sets the SPS MultiMaterial from the passed materials.
  98550. * Note : the passed array is internally copied and not used then by reference.
  98551. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  98552. */
  98553. setMultiMaterial(materials: Material[]): void;
  98554. /**
  98555. * The SPS computed multimaterial object
  98556. */
  98557. get multimaterial(): MultiMaterial;
  98558. set multimaterial(mm: MultiMaterial);
  98559. /**
  98560. * If the subMeshes must be updated on the next call to setParticles()
  98561. */
  98562. get autoUpdateSubMeshes(): boolean;
  98563. set autoUpdateSubMeshes(val: boolean);
  98564. /**
  98565. * This function does nothing. It may be overwritten to set all the particle first values.
  98566. * The SPS doesn't call this function, you may have to call it by your own.
  98567. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  98568. */
  98569. initParticles(): void;
  98570. /**
  98571. * This function does nothing. It may be overwritten to recycle a particle.
  98572. * The SPS doesn't call this function, you may have to call it by your own.
  98573. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  98574. * @param particle The particle to recycle
  98575. * @returns the recycled particle
  98576. */
  98577. recycleParticle(particle: SolidParticle): SolidParticle;
  98578. /**
  98579. * Updates a particle : this function should be overwritten by the user.
  98580. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  98581. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  98582. * @example : just set a particle position or velocity and recycle conditions
  98583. * @param particle The particle to update
  98584. * @returns the updated particle
  98585. */
  98586. updateParticle(particle: SolidParticle): SolidParticle;
  98587. /**
  98588. * Updates a vertex of a particle : it can be overwritten by the user.
  98589. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  98590. * @param particle the current particle
  98591. * @param vertex the current index of the current particle
  98592. * @param pt the index of the current vertex in the particle shape
  98593. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  98594. * @example : just set a vertex particle position
  98595. * @returns the updated vertex
  98596. */
  98597. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  98598. /**
  98599. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  98600. * This does nothing and may be overwritten by the user.
  98601. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  98602. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  98603. * @param update the boolean update value actually passed to setParticles()
  98604. */
  98605. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  98606. /**
  98607. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  98608. * This will be passed three parameters.
  98609. * This does nothing and may be overwritten by the user.
  98610. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  98611. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  98612. * @param update the boolean update value actually passed to setParticles()
  98613. */
  98614. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  98615. }
  98616. }
  98617. declare module BABYLON {
  98618. /**
  98619. * Represents one particle of a solid particle system.
  98620. */
  98621. export class SolidParticle {
  98622. /**
  98623. * particle global index
  98624. */
  98625. idx: number;
  98626. /**
  98627. * particle identifier
  98628. */
  98629. id: number;
  98630. /**
  98631. * The color of the particle
  98632. */
  98633. color: Nullable<Color4>;
  98634. /**
  98635. * The world space position of the particle.
  98636. */
  98637. position: Vector3;
  98638. /**
  98639. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  98640. */
  98641. rotation: Vector3;
  98642. /**
  98643. * The world space rotation quaternion of the particle.
  98644. */
  98645. rotationQuaternion: Nullable<Quaternion>;
  98646. /**
  98647. * The scaling of the particle.
  98648. */
  98649. scaling: Vector3;
  98650. /**
  98651. * The uvs of the particle.
  98652. */
  98653. uvs: Vector4;
  98654. /**
  98655. * The current speed of the particle.
  98656. */
  98657. velocity: Vector3;
  98658. /**
  98659. * The pivot point in the particle local space.
  98660. */
  98661. pivot: Vector3;
  98662. /**
  98663. * Must the particle be translated from its pivot point in its local space ?
  98664. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  98665. * Default : false
  98666. */
  98667. translateFromPivot: boolean;
  98668. /**
  98669. * Is the particle active or not ?
  98670. */
  98671. alive: boolean;
  98672. /**
  98673. * Is the particle visible or not ?
  98674. */
  98675. isVisible: boolean;
  98676. /**
  98677. * Index of this particle in the global "positions" array (Internal use)
  98678. * @hidden
  98679. */
  98680. _pos: number;
  98681. /**
  98682. * @hidden Index of this particle in the global "indices" array (Internal use)
  98683. */
  98684. _ind: number;
  98685. /**
  98686. * @hidden ModelShape of this particle (Internal use)
  98687. */
  98688. _model: ModelShape;
  98689. /**
  98690. * ModelShape id of this particle
  98691. */
  98692. shapeId: number;
  98693. /**
  98694. * Index of the particle in its shape id
  98695. */
  98696. idxInShape: number;
  98697. /**
  98698. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  98699. */
  98700. _modelBoundingInfo: BoundingInfo;
  98701. /**
  98702. * @hidden Particle BoundingInfo object (Internal use)
  98703. */
  98704. _boundingInfo: BoundingInfo;
  98705. /**
  98706. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  98707. */
  98708. _sps: SolidParticleSystem;
  98709. /**
  98710. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  98711. */
  98712. _stillInvisible: boolean;
  98713. /**
  98714. * @hidden Last computed particle rotation matrix
  98715. */
  98716. _rotationMatrix: number[];
  98717. /**
  98718. * Parent particle Id, if any.
  98719. * Default null.
  98720. */
  98721. parentId: Nullable<number>;
  98722. /**
  98723. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  98724. */
  98725. materialIndex: Nullable<number>;
  98726. /**
  98727. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  98728. * The possible values are :
  98729. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98730. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98731. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98732. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98733. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98734. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  98735. * */
  98736. cullingStrategy: number;
  98737. /**
  98738. * @hidden Internal global position in the SPS.
  98739. */
  98740. _globalPosition: Vector3;
  98741. /**
  98742. * Creates a Solid Particle object.
  98743. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  98744. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  98745. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  98746. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  98747. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  98748. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  98749. * @param shapeId (integer) is the model shape identifier in the SPS.
  98750. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  98751. * @param sps defines the sps it is associated to
  98752. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  98753. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  98754. */
  98755. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  98756. /**
  98757. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  98758. * @param target the particle target
  98759. * @returns the current particle
  98760. */
  98761. copyToRef(target: SolidParticle): SolidParticle;
  98762. /**
  98763. * Legacy support, changed scale to scaling
  98764. */
  98765. get scale(): Vector3;
  98766. /**
  98767. * Legacy support, changed scale to scaling
  98768. */
  98769. set scale(scale: Vector3);
  98770. /**
  98771. * Legacy support, changed quaternion to rotationQuaternion
  98772. */
  98773. get quaternion(): Nullable<Quaternion>;
  98774. /**
  98775. * Legacy support, changed quaternion to rotationQuaternion
  98776. */
  98777. set quaternion(q: Nullable<Quaternion>);
  98778. /**
  98779. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  98780. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  98781. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  98782. * @returns true if it intersects
  98783. */
  98784. intersectsMesh(target: Mesh | SolidParticle): boolean;
  98785. /**
  98786. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  98787. * A particle is in the frustum if its bounding box intersects the frustum
  98788. * @param frustumPlanes defines the frustum to test
  98789. * @returns true if the particle is in the frustum planes
  98790. */
  98791. isInFrustum(frustumPlanes: Plane[]): boolean;
  98792. /**
  98793. * get the rotation matrix of the particle
  98794. * @hidden
  98795. */
  98796. getRotationMatrix(m: Matrix): void;
  98797. }
  98798. /**
  98799. * Represents the shape of the model used by one particle of a solid particle system.
  98800. * SPS internal tool, don't use it manually.
  98801. */
  98802. export class ModelShape {
  98803. /**
  98804. * The shape id
  98805. * @hidden
  98806. */
  98807. shapeID: number;
  98808. /**
  98809. * flat array of model positions (internal use)
  98810. * @hidden
  98811. */
  98812. _shape: Vector3[];
  98813. /**
  98814. * flat array of model UVs (internal use)
  98815. * @hidden
  98816. */
  98817. _shapeUV: number[];
  98818. /**
  98819. * color array of the model
  98820. * @hidden
  98821. */
  98822. _shapeColors: number[];
  98823. /**
  98824. * indices array of the model
  98825. * @hidden
  98826. */
  98827. _indices: number[];
  98828. /**
  98829. * normals array of the model
  98830. * @hidden
  98831. */
  98832. _normals: number[];
  98833. /**
  98834. * length of the shape in the model indices array (internal use)
  98835. * @hidden
  98836. */
  98837. _indicesLength: number;
  98838. /**
  98839. * Custom position function (internal use)
  98840. * @hidden
  98841. */
  98842. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  98843. /**
  98844. * Custom vertex function (internal use)
  98845. * @hidden
  98846. */
  98847. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  98848. /**
  98849. * Model material (internal use)
  98850. * @hidden
  98851. */
  98852. _material: Nullable<Material>;
  98853. /**
  98854. * 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.
  98855. * SPS internal tool, don't use it manually.
  98856. * @hidden
  98857. */
  98858. 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>);
  98859. }
  98860. /**
  98861. * Represents a Depth Sorted Particle in the solid particle system.
  98862. * @hidden
  98863. */
  98864. export class DepthSortedParticle {
  98865. /**
  98866. * Index of the particle in the "indices" array
  98867. */
  98868. ind: number;
  98869. /**
  98870. * Length of the particle shape in the "indices" array
  98871. */
  98872. indicesLength: number;
  98873. /**
  98874. * Squared distance from the particle to the camera
  98875. */
  98876. sqDistance: number;
  98877. /**
  98878. * Material index when used with MultiMaterials
  98879. */
  98880. materialIndex: number;
  98881. /**
  98882. * Creates a new sorted particle
  98883. * @param materialIndex
  98884. */
  98885. constructor(ind: number, indLength: number, materialIndex: number);
  98886. }
  98887. }
  98888. declare module BABYLON {
  98889. /**
  98890. * @hidden
  98891. */
  98892. export class _MeshCollisionData {
  98893. _checkCollisions: boolean;
  98894. _collisionMask: number;
  98895. _collisionGroup: number;
  98896. _collider: Nullable<Collider>;
  98897. _oldPositionForCollisions: Vector3;
  98898. _diffPositionForCollisions: Vector3;
  98899. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  98900. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  98901. }
  98902. }
  98903. declare module BABYLON {
  98904. /** @hidden */
  98905. class _FacetDataStorage {
  98906. facetPositions: Vector3[];
  98907. facetNormals: Vector3[];
  98908. facetPartitioning: number[][];
  98909. facetNb: number;
  98910. partitioningSubdivisions: number;
  98911. partitioningBBoxRatio: number;
  98912. facetDataEnabled: boolean;
  98913. facetParameters: any;
  98914. bbSize: Vector3;
  98915. subDiv: {
  98916. max: number;
  98917. X: number;
  98918. Y: number;
  98919. Z: number;
  98920. };
  98921. facetDepthSort: boolean;
  98922. facetDepthSortEnabled: boolean;
  98923. depthSortedIndices: IndicesArray;
  98924. depthSortedFacets: {
  98925. ind: number;
  98926. sqDistance: number;
  98927. }[];
  98928. facetDepthSortFunction: (f1: {
  98929. ind: number;
  98930. sqDistance: number;
  98931. }, f2: {
  98932. ind: number;
  98933. sqDistance: number;
  98934. }) => number;
  98935. facetDepthSortFrom: Vector3;
  98936. facetDepthSortOrigin: Vector3;
  98937. invertedMatrix: Matrix;
  98938. }
  98939. /**
  98940. * @hidden
  98941. **/
  98942. class _InternalAbstractMeshDataInfo {
  98943. _hasVertexAlpha: boolean;
  98944. _useVertexColors: boolean;
  98945. _numBoneInfluencers: number;
  98946. _applyFog: boolean;
  98947. _receiveShadows: boolean;
  98948. _facetData: _FacetDataStorage;
  98949. _visibility: number;
  98950. _skeleton: Nullable<Skeleton>;
  98951. _layerMask: number;
  98952. _computeBonesUsingShaders: boolean;
  98953. _isActive: boolean;
  98954. _onlyForInstances: boolean;
  98955. _isActiveIntermediate: boolean;
  98956. _onlyForInstancesIntermediate: boolean;
  98957. _actAsRegularMesh: boolean;
  98958. }
  98959. /**
  98960. * Class used to store all common mesh properties
  98961. */
  98962. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  98963. /** No occlusion */
  98964. static OCCLUSION_TYPE_NONE: number;
  98965. /** Occlusion set to optimisitic */
  98966. static OCCLUSION_TYPE_OPTIMISTIC: number;
  98967. /** Occlusion set to strict */
  98968. static OCCLUSION_TYPE_STRICT: number;
  98969. /** Use an accurante occlusion algorithm */
  98970. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  98971. /** Use a conservative occlusion algorithm */
  98972. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  98973. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  98974. * Test order :
  98975. * Is the bounding sphere outside the frustum ?
  98976. * If not, are the bounding box vertices outside the frustum ?
  98977. * It not, then the cullable object is in the frustum.
  98978. */
  98979. static readonly CULLINGSTRATEGY_STANDARD: number;
  98980. /** Culling strategy : Bounding Sphere Only.
  98981. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  98982. * It's also less accurate than the standard because some not visible objects can still be selected.
  98983. * Test : is the bounding sphere outside the frustum ?
  98984. * If not, then the cullable object is in the frustum.
  98985. */
  98986. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  98987. /** Culling strategy : Optimistic Inclusion.
  98988. * This in an inclusion test first, then the standard exclusion test.
  98989. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  98990. * 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.
  98991. * Anyway, it's as accurate as the standard strategy.
  98992. * Test :
  98993. * Is the cullable object bounding sphere center in the frustum ?
  98994. * If not, apply the default culling strategy.
  98995. */
  98996. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  98997. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  98998. * This in an inclusion test first, then the bounding sphere only exclusion test.
  98999. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  99000. * 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.
  99001. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  99002. * Test :
  99003. * Is the cullable object bounding sphere center in the frustum ?
  99004. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  99005. */
  99006. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  99007. /**
  99008. * No billboard
  99009. */
  99010. static get BILLBOARDMODE_NONE(): number;
  99011. /** Billboard on X axis */
  99012. static get BILLBOARDMODE_X(): number;
  99013. /** Billboard on Y axis */
  99014. static get BILLBOARDMODE_Y(): number;
  99015. /** Billboard on Z axis */
  99016. static get BILLBOARDMODE_Z(): number;
  99017. /** Billboard on all axes */
  99018. static get BILLBOARDMODE_ALL(): number;
  99019. /** Billboard on using position instead of orientation */
  99020. static get BILLBOARDMODE_USE_POSITION(): number;
  99021. /** @hidden */
  99022. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  99023. /**
  99024. * The culling strategy to use to check whether the mesh must be rendered or not.
  99025. * This value can be changed at any time and will be used on the next render mesh selection.
  99026. * The possible values are :
  99027. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  99028. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  99029. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  99030. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  99031. * Please read each static variable documentation to get details about the culling process.
  99032. * */
  99033. cullingStrategy: number;
  99034. /**
  99035. * Gets the number of facets in the mesh
  99036. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  99037. */
  99038. get facetNb(): number;
  99039. /**
  99040. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  99041. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  99042. */
  99043. get partitioningSubdivisions(): number;
  99044. set partitioningSubdivisions(nb: number);
  99045. /**
  99046. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  99047. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  99048. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  99049. */
  99050. get partitioningBBoxRatio(): number;
  99051. set partitioningBBoxRatio(ratio: number);
  99052. /**
  99053. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  99054. * Works only for updatable meshes.
  99055. * Doesn't work with multi-materials
  99056. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  99057. */
  99058. get mustDepthSortFacets(): boolean;
  99059. set mustDepthSortFacets(sort: boolean);
  99060. /**
  99061. * The location (Vector3) where the facet depth sort must be computed from.
  99062. * By default, the active camera position.
  99063. * Used only when facet depth sort is enabled
  99064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  99065. */
  99066. get facetDepthSortFrom(): Vector3;
  99067. set facetDepthSortFrom(location: Vector3);
  99068. /**
  99069. * gets a boolean indicating if facetData is enabled
  99070. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  99071. */
  99072. get isFacetDataEnabled(): boolean;
  99073. /** @hidden */
  99074. _updateNonUniformScalingState(value: boolean): boolean;
  99075. /**
  99076. * An event triggered when this mesh collides with another one
  99077. */
  99078. onCollideObservable: Observable<AbstractMesh>;
  99079. /** Set a function to call when this mesh collides with another one */
  99080. set onCollide(callback: () => void);
  99081. /**
  99082. * An event triggered when the collision's position changes
  99083. */
  99084. onCollisionPositionChangeObservable: Observable<Vector3>;
  99085. /** Set a function to call when the collision's position changes */
  99086. set onCollisionPositionChange(callback: () => void);
  99087. /**
  99088. * An event triggered when material is changed
  99089. */
  99090. onMaterialChangedObservable: Observable<AbstractMesh>;
  99091. /**
  99092. * Gets or sets the orientation for POV movement & rotation
  99093. */
  99094. definedFacingForward: boolean;
  99095. /** @hidden */
  99096. _occlusionQuery: Nullable<WebGLQuery>;
  99097. /** @hidden */
  99098. _renderingGroup: Nullable<RenderingGroup>;
  99099. /**
  99100. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  99101. */
  99102. get visibility(): number;
  99103. /**
  99104. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  99105. */
  99106. set visibility(value: number);
  99107. /** Gets or sets the alpha index used to sort transparent meshes
  99108. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  99109. */
  99110. alphaIndex: number;
  99111. /**
  99112. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  99113. */
  99114. isVisible: boolean;
  99115. /**
  99116. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  99117. */
  99118. isPickable: boolean;
  99119. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  99120. showSubMeshesBoundingBox: boolean;
  99121. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  99122. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  99123. */
  99124. isBlocker: boolean;
  99125. /**
  99126. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  99127. */
  99128. enablePointerMoveEvents: boolean;
  99129. /**
  99130. * Specifies the rendering group id for this mesh (0 by default)
  99131. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  99132. */
  99133. renderingGroupId: number;
  99134. private _material;
  99135. /** Gets or sets current material */
  99136. get material(): Nullable<Material>;
  99137. set material(value: Nullable<Material>);
  99138. /**
  99139. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  99140. * @see http://doc.babylonjs.com/babylon101/shadows
  99141. */
  99142. get receiveShadows(): boolean;
  99143. set receiveShadows(value: boolean);
  99144. /** Defines color to use when rendering outline */
  99145. outlineColor: Color3;
  99146. /** Define width to use when rendering outline */
  99147. outlineWidth: number;
  99148. /** Defines color to use when rendering overlay */
  99149. overlayColor: Color3;
  99150. /** Defines alpha to use when rendering overlay */
  99151. overlayAlpha: number;
  99152. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  99153. get hasVertexAlpha(): boolean;
  99154. set hasVertexAlpha(value: boolean);
  99155. /** 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) */
  99156. get useVertexColors(): boolean;
  99157. set useVertexColors(value: boolean);
  99158. /**
  99159. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  99160. */
  99161. get computeBonesUsingShaders(): boolean;
  99162. set computeBonesUsingShaders(value: boolean);
  99163. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  99164. get numBoneInfluencers(): number;
  99165. set numBoneInfluencers(value: number);
  99166. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  99167. get applyFog(): boolean;
  99168. set applyFog(value: boolean);
  99169. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  99170. useOctreeForRenderingSelection: boolean;
  99171. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  99172. useOctreeForPicking: boolean;
  99173. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  99174. useOctreeForCollisions: boolean;
  99175. /**
  99176. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  99177. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  99178. */
  99179. get layerMask(): number;
  99180. set layerMask(value: number);
  99181. /**
  99182. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  99183. */
  99184. alwaysSelectAsActiveMesh: boolean;
  99185. /**
  99186. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  99187. */
  99188. doNotSyncBoundingInfo: boolean;
  99189. /**
  99190. * Gets or sets the current action manager
  99191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99192. */
  99193. actionManager: Nullable<AbstractActionManager>;
  99194. private _meshCollisionData;
  99195. /**
  99196. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  99197. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99198. */
  99199. ellipsoid: Vector3;
  99200. /**
  99201. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  99202. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99203. */
  99204. ellipsoidOffset: Vector3;
  99205. /**
  99206. * Gets or sets a collision mask used to mask collisions (default is -1).
  99207. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  99208. */
  99209. get collisionMask(): number;
  99210. set collisionMask(mask: number);
  99211. /**
  99212. * Gets or sets the current collision group mask (-1 by default).
  99213. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  99214. */
  99215. get collisionGroup(): number;
  99216. set collisionGroup(mask: number);
  99217. /**
  99218. * Defines edge width used when edgesRenderer is enabled
  99219. * @see https://www.babylonjs-playground.com/#10OJSG#13
  99220. */
  99221. edgesWidth: number;
  99222. /**
  99223. * Defines edge color used when edgesRenderer is enabled
  99224. * @see https://www.babylonjs-playground.com/#10OJSG#13
  99225. */
  99226. edgesColor: Color4;
  99227. /** @hidden */
  99228. _edgesRenderer: Nullable<IEdgesRenderer>;
  99229. /** @hidden */
  99230. _masterMesh: Nullable<AbstractMesh>;
  99231. /** @hidden */
  99232. _boundingInfo: Nullable<BoundingInfo>;
  99233. /** @hidden */
  99234. _renderId: number;
  99235. /**
  99236. * Gets or sets the list of subMeshes
  99237. * @see http://doc.babylonjs.com/how_to/multi_materials
  99238. */
  99239. subMeshes: SubMesh[];
  99240. /** @hidden */
  99241. _intersectionsInProgress: AbstractMesh[];
  99242. /** @hidden */
  99243. _unIndexed: boolean;
  99244. /** @hidden */
  99245. _lightSources: Light[];
  99246. /** Gets the list of lights affecting that mesh */
  99247. get lightSources(): Light[];
  99248. /** @hidden */
  99249. get _positions(): Nullable<Vector3[]>;
  99250. /** @hidden */
  99251. _waitingData: {
  99252. lods: Nullable<any>;
  99253. actions: Nullable<any>;
  99254. freezeWorldMatrix: Nullable<boolean>;
  99255. };
  99256. /** @hidden */
  99257. _bonesTransformMatrices: Nullable<Float32Array>;
  99258. /** @hidden */
  99259. _transformMatrixTexture: Nullable<RawTexture>;
  99260. /**
  99261. * Gets or sets a skeleton to apply skining transformations
  99262. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  99263. */
  99264. set skeleton(value: Nullable<Skeleton>);
  99265. get skeleton(): Nullable<Skeleton>;
  99266. /**
  99267. * An event triggered when the mesh is rebuilt.
  99268. */
  99269. onRebuildObservable: Observable<AbstractMesh>;
  99270. /**
  99271. * Creates a new AbstractMesh
  99272. * @param name defines the name of the mesh
  99273. * @param scene defines the hosting scene
  99274. */
  99275. constructor(name: string, scene?: Nullable<Scene>);
  99276. /**
  99277. * Returns the string "AbstractMesh"
  99278. * @returns "AbstractMesh"
  99279. */
  99280. getClassName(): string;
  99281. /**
  99282. * Gets a string representation of the current mesh
  99283. * @param fullDetails defines a boolean indicating if full details must be included
  99284. * @returns a string representation of the current mesh
  99285. */
  99286. toString(fullDetails?: boolean): string;
  99287. /**
  99288. * @hidden
  99289. */
  99290. protected _getEffectiveParent(): Nullable<Node>;
  99291. /** @hidden */
  99292. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  99293. /** @hidden */
  99294. _rebuild(): void;
  99295. /** @hidden */
  99296. _resyncLightSources(): void;
  99297. /** @hidden */
  99298. _resyncLightSource(light: Light): void;
  99299. /** @hidden */
  99300. _unBindEffect(): void;
  99301. /** @hidden */
  99302. _removeLightSource(light: Light, dispose: boolean): void;
  99303. private _markSubMeshesAsDirty;
  99304. /** @hidden */
  99305. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  99306. /** @hidden */
  99307. _markSubMeshesAsAttributesDirty(): void;
  99308. /** @hidden */
  99309. _markSubMeshesAsMiscDirty(): void;
  99310. /**
  99311. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  99312. */
  99313. get scaling(): Vector3;
  99314. set scaling(newScaling: Vector3);
  99315. /**
  99316. * Returns true if the mesh is blocked. Implemented by child classes
  99317. */
  99318. get isBlocked(): boolean;
  99319. /**
  99320. * Returns the mesh itself by default. Implemented by child classes
  99321. * @param camera defines the camera to use to pick the right LOD level
  99322. * @returns the currentAbstractMesh
  99323. */
  99324. getLOD(camera: Camera): Nullable<AbstractMesh>;
  99325. /**
  99326. * Returns 0 by default. Implemented by child classes
  99327. * @returns an integer
  99328. */
  99329. getTotalVertices(): number;
  99330. /**
  99331. * Returns a positive integer : the total number of indices in this mesh geometry.
  99332. * @returns the numner of indices or zero if the mesh has no geometry.
  99333. */
  99334. getTotalIndices(): number;
  99335. /**
  99336. * Returns null by default. Implemented by child classes
  99337. * @returns null
  99338. */
  99339. getIndices(): Nullable<IndicesArray>;
  99340. /**
  99341. * Returns the array of the requested vertex data kind. Implemented by child classes
  99342. * @param kind defines the vertex data kind to use
  99343. * @returns null
  99344. */
  99345. getVerticesData(kind: string): Nullable<FloatArray>;
  99346. /**
  99347. * Sets the vertex data of the mesh geometry for the requested `kind`.
  99348. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  99349. * Note that a new underlying VertexBuffer object is created each call.
  99350. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  99351. * @param kind defines vertex data kind:
  99352. * * VertexBuffer.PositionKind
  99353. * * VertexBuffer.UVKind
  99354. * * VertexBuffer.UV2Kind
  99355. * * VertexBuffer.UV3Kind
  99356. * * VertexBuffer.UV4Kind
  99357. * * VertexBuffer.UV5Kind
  99358. * * VertexBuffer.UV6Kind
  99359. * * VertexBuffer.ColorKind
  99360. * * VertexBuffer.MatricesIndicesKind
  99361. * * VertexBuffer.MatricesIndicesExtraKind
  99362. * * VertexBuffer.MatricesWeightsKind
  99363. * * VertexBuffer.MatricesWeightsExtraKind
  99364. * @param data defines the data source
  99365. * @param updatable defines if the data must be flagged as updatable (or static)
  99366. * @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
  99367. * @returns the current mesh
  99368. */
  99369. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  99370. /**
  99371. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  99372. * If the mesh has no geometry, it is simply returned as it is.
  99373. * @param kind defines vertex data kind:
  99374. * * VertexBuffer.PositionKind
  99375. * * VertexBuffer.UVKind
  99376. * * VertexBuffer.UV2Kind
  99377. * * VertexBuffer.UV3Kind
  99378. * * VertexBuffer.UV4Kind
  99379. * * VertexBuffer.UV5Kind
  99380. * * VertexBuffer.UV6Kind
  99381. * * VertexBuffer.ColorKind
  99382. * * VertexBuffer.MatricesIndicesKind
  99383. * * VertexBuffer.MatricesIndicesExtraKind
  99384. * * VertexBuffer.MatricesWeightsKind
  99385. * * VertexBuffer.MatricesWeightsExtraKind
  99386. * @param data defines the data source
  99387. * @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
  99388. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  99389. * @returns the current mesh
  99390. */
  99391. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  99392. /**
  99393. * Sets the mesh indices,
  99394. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  99395. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  99396. * @param totalVertices Defines the total number of vertices
  99397. * @returns the current mesh
  99398. */
  99399. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  99400. /**
  99401. * Gets a boolean indicating if specific vertex data is present
  99402. * @param kind defines the vertex data kind to use
  99403. * @returns true is data kind is present
  99404. */
  99405. isVerticesDataPresent(kind: string): boolean;
  99406. /**
  99407. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  99408. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  99409. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  99410. * @returns a BoundingInfo
  99411. */
  99412. getBoundingInfo(): BoundingInfo;
  99413. /**
  99414. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  99415. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  99416. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  99417. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  99418. * @returns the current mesh
  99419. */
  99420. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  99421. /**
  99422. * Overwrite the current bounding info
  99423. * @param boundingInfo defines the new bounding info
  99424. * @returns the current mesh
  99425. */
  99426. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  99427. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  99428. get useBones(): boolean;
  99429. /** @hidden */
  99430. _preActivate(): void;
  99431. /** @hidden */
  99432. _preActivateForIntermediateRendering(renderId: number): void;
  99433. /** @hidden */
  99434. _activate(renderId: number, intermediateRendering: boolean): boolean;
  99435. /** @hidden */
  99436. _postActivate(): void;
  99437. /** @hidden */
  99438. _freeze(): void;
  99439. /** @hidden */
  99440. _unFreeze(): void;
  99441. /**
  99442. * Gets the current world matrix
  99443. * @returns a Matrix
  99444. */
  99445. getWorldMatrix(): Matrix;
  99446. /** @hidden */
  99447. _getWorldMatrixDeterminant(): number;
  99448. /**
  99449. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  99450. */
  99451. get isAnInstance(): boolean;
  99452. /**
  99453. * Gets a boolean indicating if this mesh has instances
  99454. */
  99455. get hasInstances(): boolean;
  99456. /**
  99457. * Perform relative position change from the point of view of behind the front of the mesh.
  99458. * This is performed taking into account the meshes current rotation, so you do not have to care.
  99459. * Supports definition of mesh facing forward or backward
  99460. * @param amountRight defines the distance on the right axis
  99461. * @param amountUp defines the distance on the up axis
  99462. * @param amountForward defines the distance on the forward axis
  99463. * @returns the current mesh
  99464. */
  99465. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  99466. /**
  99467. * Calculate relative position change from the point of view of behind the front of the mesh.
  99468. * This is performed taking into account the meshes current rotation, so you do not have to care.
  99469. * Supports definition of mesh facing forward or backward
  99470. * @param amountRight defines the distance on the right axis
  99471. * @param amountUp defines the distance on the up axis
  99472. * @param amountForward defines the distance on the forward axis
  99473. * @returns the new displacement vector
  99474. */
  99475. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  99476. /**
  99477. * Perform relative rotation change from the point of view of behind the front of the mesh.
  99478. * Supports definition of mesh facing forward or backward
  99479. * @param flipBack defines the flip
  99480. * @param twirlClockwise defines the twirl
  99481. * @param tiltRight defines the tilt
  99482. * @returns the current mesh
  99483. */
  99484. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  99485. /**
  99486. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  99487. * Supports definition of mesh facing forward or backward.
  99488. * @param flipBack defines the flip
  99489. * @param twirlClockwise defines the twirl
  99490. * @param tiltRight defines the tilt
  99491. * @returns the new rotation vector
  99492. */
  99493. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  99494. /**
  99495. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  99496. * This means the mesh underlying bounding box and sphere are recomputed.
  99497. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  99498. * @returns the current mesh
  99499. */
  99500. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  99501. /** @hidden */
  99502. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  99503. /** @hidden */
  99504. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  99505. /** @hidden */
  99506. _updateBoundingInfo(): AbstractMesh;
  99507. /** @hidden */
  99508. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  99509. /** @hidden */
  99510. protected _afterComputeWorldMatrix(): void;
  99511. /** @hidden */
  99512. get _effectiveMesh(): AbstractMesh;
  99513. /**
  99514. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  99515. * A mesh is in the frustum if its bounding box intersects the frustum
  99516. * @param frustumPlanes defines the frustum to test
  99517. * @returns true if the mesh is in the frustum planes
  99518. */
  99519. isInFrustum(frustumPlanes: Plane[]): boolean;
  99520. /**
  99521. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  99522. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  99523. * @param frustumPlanes defines the frustum to test
  99524. * @returns true if the mesh is completely in the frustum planes
  99525. */
  99526. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  99527. /**
  99528. * True if the mesh intersects another mesh or a SolidParticle object
  99529. * @param mesh defines a target mesh or SolidParticle to test
  99530. * @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)
  99531. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  99532. * @returns true if there is an intersection
  99533. */
  99534. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  99535. /**
  99536. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  99537. * @param point defines the point to test
  99538. * @returns true if there is an intersection
  99539. */
  99540. intersectsPoint(point: Vector3): boolean;
  99541. /**
  99542. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  99543. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99544. */
  99545. get checkCollisions(): boolean;
  99546. set checkCollisions(collisionEnabled: boolean);
  99547. /**
  99548. * Gets Collider object used to compute collisions (not physics)
  99549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99550. */
  99551. get collider(): Nullable<Collider>;
  99552. /**
  99553. * Move the mesh using collision engine
  99554. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99555. * @param displacement defines the requested displacement vector
  99556. * @returns the current mesh
  99557. */
  99558. moveWithCollisions(displacement: Vector3): AbstractMesh;
  99559. private _onCollisionPositionChange;
  99560. /** @hidden */
  99561. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  99562. /** @hidden */
  99563. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  99564. /** @hidden */
  99565. _checkCollision(collider: Collider): AbstractMesh;
  99566. /** @hidden */
  99567. _generatePointsArray(): boolean;
  99568. /**
  99569. * Checks if the passed Ray intersects with the mesh
  99570. * @param ray defines the ray to use
  99571. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  99572. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99573. * @returns the picking info
  99574. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  99575. */
  99576. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  99577. /**
  99578. * Clones the current mesh
  99579. * @param name defines the mesh name
  99580. * @param newParent defines the new mesh parent
  99581. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  99582. * @returns the new mesh
  99583. */
  99584. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  99585. /**
  99586. * Disposes all the submeshes of the current meshnp
  99587. * @returns the current mesh
  99588. */
  99589. releaseSubMeshes(): AbstractMesh;
  99590. /**
  99591. * Releases resources associated with this abstract mesh.
  99592. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99593. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99594. */
  99595. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99596. /**
  99597. * Adds the passed mesh as a child to the current mesh
  99598. * @param mesh defines the child mesh
  99599. * @returns the current mesh
  99600. */
  99601. addChild(mesh: AbstractMesh): AbstractMesh;
  99602. /**
  99603. * Removes the passed mesh from the current mesh children list
  99604. * @param mesh defines the child mesh
  99605. * @returns the current mesh
  99606. */
  99607. removeChild(mesh: AbstractMesh): AbstractMesh;
  99608. /** @hidden */
  99609. private _initFacetData;
  99610. /**
  99611. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  99612. * This method can be called within the render loop.
  99613. * 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
  99614. * @returns the current mesh
  99615. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99616. */
  99617. updateFacetData(): AbstractMesh;
  99618. /**
  99619. * Returns the facetLocalNormals array.
  99620. * The normals are expressed in the mesh local spac
  99621. * @returns an array of Vector3
  99622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99623. */
  99624. getFacetLocalNormals(): Vector3[];
  99625. /**
  99626. * Returns the facetLocalPositions array.
  99627. * The facet positions are expressed in the mesh local space
  99628. * @returns an array of Vector3
  99629. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99630. */
  99631. getFacetLocalPositions(): Vector3[];
  99632. /**
  99633. * Returns the facetLocalPartioning array
  99634. * @returns an array of array of numbers
  99635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99636. */
  99637. getFacetLocalPartitioning(): number[][];
  99638. /**
  99639. * Returns the i-th facet position in the world system.
  99640. * This method allocates a new Vector3 per call
  99641. * @param i defines the facet index
  99642. * @returns a new Vector3
  99643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99644. */
  99645. getFacetPosition(i: number): Vector3;
  99646. /**
  99647. * Sets the reference Vector3 with the i-th facet position in the world system
  99648. * @param i defines the facet index
  99649. * @param ref defines the target vector
  99650. * @returns the current mesh
  99651. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99652. */
  99653. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  99654. /**
  99655. * Returns the i-th facet normal in the world system.
  99656. * This method allocates a new Vector3 per call
  99657. * @param i defines the facet index
  99658. * @returns a new Vector3
  99659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99660. */
  99661. getFacetNormal(i: number): Vector3;
  99662. /**
  99663. * Sets the reference Vector3 with the i-th facet normal in the world system
  99664. * @param i defines the facet index
  99665. * @param ref defines the target vector
  99666. * @returns the current mesh
  99667. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99668. */
  99669. getFacetNormalToRef(i: number, ref: Vector3): this;
  99670. /**
  99671. * 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)
  99672. * @param x defines x coordinate
  99673. * @param y defines y coordinate
  99674. * @param z defines z coordinate
  99675. * @returns the array of facet indexes
  99676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99677. */
  99678. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  99679. /**
  99680. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  99681. * @param projected sets as the (x,y,z) world projection on the facet
  99682. * @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
  99683. * @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
  99684. * @param x defines x coordinate
  99685. * @param y defines y coordinate
  99686. * @param z defines z coordinate
  99687. * @returns the face index if found (or null instead)
  99688. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99689. */
  99690. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  99691. /**
  99692. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  99693. * @param projected sets as the (x,y,z) local projection on the facet
  99694. * @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
  99695. * @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
  99696. * @param x defines x coordinate
  99697. * @param y defines y coordinate
  99698. * @param z defines z coordinate
  99699. * @returns the face index if found (or null instead)
  99700. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99701. */
  99702. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  99703. /**
  99704. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  99705. * @returns the parameters
  99706. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99707. */
  99708. getFacetDataParameters(): any;
  99709. /**
  99710. * Disables the feature FacetData and frees the related memory
  99711. * @returns the current mesh
  99712. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99713. */
  99714. disableFacetData(): AbstractMesh;
  99715. /**
  99716. * Updates the AbstractMesh indices array
  99717. * @param indices defines the data source
  99718. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  99719. * @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)
  99720. * @returns the current mesh
  99721. */
  99722. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  99723. /**
  99724. * Creates new normals data for the mesh
  99725. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  99726. * @returns the current mesh
  99727. */
  99728. createNormals(updatable: boolean): AbstractMesh;
  99729. /**
  99730. * Align the mesh with a normal
  99731. * @param normal defines the normal to use
  99732. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  99733. * @returns the current mesh
  99734. */
  99735. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  99736. /** @hidden */
  99737. _checkOcclusionQuery(): boolean;
  99738. /**
  99739. * Disables the mesh edge rendering mode
  99740. * @returns the currentAbstractMesh
  99741. */
  99742. disableEdgesRendering(): AbstractMesh;
  99743. /**
  99744. * Enables the edge rendering mode on the mesh.
  99745. * This mode makes the mesh edges visible
  99746. * @param epsilon defines the maximal distance between two angles to detect a face
  99747. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  99748. * @returns the currentAbstractMesh
  99749. * @see https://www.babylonjs-playground.com/#19O9TU#0
  99750. */
  99751. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  99752. }
  99753. }
  99754. declare module BABYLON {
  99755. /**
  99756. * Interface used to define ActionEvent
  99757. */
  99758. export interface IActionEvent {
  99759. /** The mesh or sprite that triggered the action */
  99760. source: any;
  99761. /** The X mouse cursor position at the time of the event */
  99762. pointerX: number;
  99763. /** The Y mouse cursor position at the time of the event */
  99764. pointerY: number;
  99765. /** The mesh that is currently pointed at (can be null) */
  99766. meshUnderPointer: Nullable<AbstractMesh>;
  99767. /** the original (browser) event that triggered the ActionEvent */
  99768. sourceEvent?: any;
  99769. /** additional data for the event */
  99770. additionalData?: any;
  99771. }
  99772. /**
  99773. * ActionEvent is the event being sent when an action is triggered.
  99774. */
  99775. export class ActionEvent implements IActionEvent {
  99776. /** The mesh or sprite that triggered the action */
  99777. source: any;
  99778. /** The X mouse cursor position at the time of the event */
  99779. pointerX: number;
  99780. /** The Y mouse cursor position at the time of the event */
  99781. pointerY: number;
  99782. /** The mesh that is currently pointed at (can be null) */
  99783. meshUnderPointer: Nullable<AbstractMesh>;
  99784. /** the original (browser) event that triggered the ActionEvent */
  99785. sourceEvent?: any;
  99786. /** additional data for the event */
  99787. additionalData?: any;
  99788. /**
  99789. * Creates a new ActionEvent
  99790. * @param source The mesh or sprite that triggered the action
  99791. * @param pointerX The X mouse cursor position at the time of the event
  99792. * @param pointerY The Y mouse cursor position at the time of the event
  99793. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  99794. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  99795. * @param additionalData additional data for the event
  99796. */
  99797. constructor(
  99798. /** The mesh or sprite that triggered the action */
  99799. source: any,
  99800. /** The X mouse cursor position at the time of the event */
  99801. pointerX: number,
  99802. /** The Y mouse cursor position at the time of the event */
  99803. pointerY: number,
  99804. /** The mesh that is currently pointed at (can be null) */
  99805. meshUnderPointer: Nullable<AbstractMesh>,
  99806. /** the original (browser) event that triggered the ActionEvent */
  99807. sourceEvent?: any,
  99808. /** additional data for the event */
  99809. additionalData?: any);
  99810. /**
  99811. * Helper function to auto-create an ActionEvent from a source mesh.
  99812. * @param source The source mesh that triggered the event
  99813. * @param evt The original (browser) event
  99814. * @param additionalData additional data for the event
  99815. * @returns the new ActionEvent
  99816. */
  99817. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  99818. /**
  99819. * Helper function to auto-create an ActionEvent from a source sprite
  99820. * @param source The source sprite that triggered the event
  99821. * @param scene Scene associated with the sprite
  99822. * @param evt The original (browser) event
  99823. * @param additionalData additional data for the event
  99824. * @returns the new ActionEvent
  99825. */
  99826. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  99827. /**
  99828. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  99829. * @param scene the scene where the event occurred
  99830. * @param evt The original (browser) event
  99831. * @returns the new ActionEvent
  99832. */
  99833. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  99834. /**
  99835. * Helper function to auto-create an ActionEvent from a primitive
  99836. * @param prim defines the target primitive
  99837. * @param pointerPos defines the pointer position
  99838. * @param evt The original (browser) event
  99839. * @param additionalData additional data for the event
  99840. * @returns the new ActionEvent
  99841. */
  99842. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  99843. }
  99844. }
  99845. declare module BABYLON {
  99846. /**
  99847. * Abstract class used to decouple action Manager from scene and meshes.
  99848. * Do not instantiate.
  99849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99850. */
  99851. export abstract class AbstractActionManager implements IDisposable {
  99852. /** Gets the list of active triggers */
  99853. static Triggers: {
  99854. [key: string]: number;
  99855. };
  99856. /** Gets the cursor to use when hovering items */
  99857. hoverCursor: string;
  99858. /** Gets the list of actions */
  99859. actions: IAction[];
  99860. /**
  99861. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  99862. */
  99863. isRecursive: boolean;
  99864. /**
  99865. * Releases all associated resources
  99866. */
  99867. abstract dispose(): void;
  99868. /**
  99869. * Does this action manager has pointer triggers
  99870. */
  99871. abstract get hasPointerTriggers(): boolean;
  99872. /**
  99873. * Does this action manager has pick triggers
  99874. */
  99875. abstract get hasPickTriggers(): boolean;
  99876. /**
  99877. * Process a specific trigger
  99878. * @param trigger defines the trigger to process
  99879. * @param evt defines the event details to be processed
  99880. */
  99881. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  99882. /**
  99883. * Does this action manager handles actions of any of the given triggers
  99884. * @param triggers defines the triggers to be tested
  99885. * @return a boolean indicating whether one (or more) of the triggers is handled
  99886. */
  99887. abstract hasSpecificTriggers(triggers: number[]): boolean;
  99888. /**
  99889. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  99890. * speed.
  99891. * @param triggerA defines the trigger to be tested
  99892. * @param triggerB defines the trigger to be tested
  99893. * @return a boolean indicating whether one (or more) of the triggers is handled
  99894. */
  99895. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  99896. /**
  99897. * Does this action manager handles actions of a given trigger
  99898. * @param trigger defines the trigger to be tested
  99899. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  99900. * @return whether the trigger is handled
  99901. */
  99902. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  99903. /**
  99904. * Serialize this manager to a JSON object
  99905. * @param name defines the property name to store this manager
  99906. * @returns a JSON representation of this manager
  99907. */
  99908. abstract serialize(name: string): any;
  99909. /**
  99910. * Registers an action to this action manager
  99911. * @param action defines the action to be registered
  99912. * @return the action amended (prepared) after registration
  99913. */
  99914. abstract registerAction(action: IAction): Nullable<IAction>;
  99915. /**
  99916. * Unregisters an action to this action manager
  99917. * @param action defines the action to be unregistered
  99918. * @return a boolean indicating whether the action has been unregistered
  99919. */
  99920. abstract unregisterAction(action: IAction): Boolean;
  99921. /**
  99922. * Does exist one action manager with at least one trigger
  99923. **/
  99924. static get HasTriggers(): boolean;
  99925. /**
  99926. * Does exist one action manager with at least one pick trigger
  99927. **/
  99928. static get HasPickTriggers(): boolean;
  99929. /**
  99930. * Does exist one action manager that handles actions of a given trigger
  99931. * @param trigger defines the trigger to be tested
  99932. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  99933. **/
  99934. static HasSpecificTrigger(trigger: number): boolean;
  99935. }
  99936. }
  99937. declare module BABYLON {
  99938. /**
  99939. * Defines how a node can be built from a string name.
  99940. */
  99941. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  99942. /**
  99943. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  99944. */
  99945. export class Node implements IBehaviorAware<Node> {
  99946. /** @hidden */
  99947. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  99948. private static _NodeConstructors;
  99949. /**
  99950. * Add a new node constructor
  99951. * @param type defines the type name of the node to construct
  99952. * @param constructorFunc defines the constructor function
  99953. */
  99954. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  99955. /**
  99956. * Returns a node constructor based on type name
  99957. * @param type defines the type name
  99958. * @param name defines the new node name
  99959. * @param scene defines the hosting scene
  99960. * @param options defines optional options to transmit to constructors
  99961. * @returns the new constructor or null
  99962. */
  99963. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  99964. /**
  99965. * Gets or sets the name of the node
  99966. */
  99967. name: string;
  99968. /**
  99969. * Gets or sets the id of the node
  99970. */
  99971. id: string;
  99972. /**
  99973. * Gets or sets the unique id of the node
  99974. */
  99975. uniqueId: number;
  99976. /**
  99977. * Gets or sets a string used to store user defined state for the node
  99978. */
  99979. state: string;
  99980. /**
  99981. * Gets or sets an object used to store user defined information for the node
  99982. */
  99983. metadata: any;
  99984. /**
  99985. * For internal use only. Please do not use.
  99986. */
  99987. reservedDataStore: any;
  99988. /**
  99989. * List of inspectable custom properties (used by the Inspector)
  99990. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99991. */
  99992. inspectableCustomProperties: IInspectable[];
  99993. private _doNotSerialize;
  99994. /**
  99995. * Gets or sets a boolean used to define if the node must be serialized
  99996. */
  99997. get doNotSerialize(): boolean;
  99998. set doNotSerialize(value: boolean);
  99999. /** @hidden */
  100000. _isDisposed: boolean;
  100001. /**
  100002. * Gets a list of Animations associated with the node
  100003. */
  100004. animations: Animation[];
  100005. protected _ranges: {
  100006. [name: string]: Nullable<AnimationRange>;
  100007. };
  100008. /**
  100009. * Callback raised when the node is ready to be used
  100010. */
  100011. onReady: Nullable<(node: Node) => void>;
  100012. private _isEnabled;
  100013. private _isParentEnabled;
  100014. private _isReady;
  100015. /** @hidden */
  100016. _currentRenderId: number;
  100017. private _parentUpdateId;
  100018. /** @hidden */
  100019. _childUpdateId: number;
  100020. /** @hidden */
  100021. _waitingParentId: Nullable<string>;
  100022. /** @hidden */
  100023. _scene: Scene;
  100024. /** @hidden */
  100025. _cache: any;
  100026. private _parentNode;
  100027. private _children;
  100028. /** @hidden */
  100029. _worldMatrix: Matrix;
  100030. /** @hidden */
  100031. _worldMatrixDeterminant: number;
  100032. /** @hidden */
  100033. _worldMatrixDeterminantIsDirty: boolean;
  100034. /** @hidden */
  100035. private _sceneRootNodesIndex;
  100036. /**
  100037. * Gets a boolean indicating if the node has been disposed
  100038. * @returns true if the node was disposed
  100039. */
  100040. isDisposed(): boolean;
  100041. /**
  100042. * Gets or sets the parent of the node (without keeping the current position in the scene)
  100043. * @see https://doc.babylonjs.com/how_to/parenting
  100044. */
  100045. set parent(parent: Nullable<Node>);
  100046. get parent(): Nullable<Node>;
  100047. /** @hidden */
  100048. _addToSceneRootNodes(): void;
  100049. /** @hidden */
  100050. _removeFromSceneRootNodes(): void;
  100051. private _animationPropertiesOverride;
  100052. /**
  100053. * Gets or sets the animation properties override
  100054. */
  100055. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  100056. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  100057. /**
  100058. * Gets a string idenfifying the name of the class
  100059. * @returns "Node" string
  100060. */
  100061. getClassName(): string;
  100062. /** @hidden */
  100063. readonly _isNode: boolean;
  100064. /**
  100065. * An event triggered when the mesh is disposed
  100066. */
  100067. onDisposeObservable: Observable<Node>;
  100068. private _onDisposeObserver;
  100069. /**
  100070. * Sets a callback that will be raised when the node will be disposed
  100071. */
  100072. set onDispose(callback: () => void);
  100073. /**
  100074. * Creates a new Node
  100075. * @param name the name and id to be given to this node
  100076. * @param scene the scene this node will be added to
  100077. */
  100078. constructor(name: string, scene?: Nullable<Scene>);
  100079. /**
  100080. * Gets the scene of the node
  100081. * @returns a scene
  100082. */
  100083. getScene(): Scene;
  100084. /**
  100085. * Gets the engine of the node
  100086. * @returns a Engine
  100087. */
  100088. getEngine(): Engine;
  100089. private _behaviors;
  100090. /**
  100091. * Attach a behavior to the node
  100092. * @see http://doc.babylonjs.com/features/behaviour
  100093. * @param behavior defines the behavior to attach
  100094. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  100095. * @returns the current Node
  100096. */
  100097. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  100098. /**
  100099. * Remove an attached behavior
  100100. * @see http://doc.babylonjs.com/features/behaviour
  100101. * @param behavior defines the behavior to attach
  100102. * @returns the current Node
  100103. */
  100104. removeBehavior(behavior: Behavior<Node>): Node;
  100105. /**
  100106. * Gets the list of attached behaviors
  100107. * @see http://doc.babylonjs.com/features/behaviour
  100108. */
  100109. get behaviors(): Behavior<Node>[];
  100110. /**
  100111. * Gets an attached behavior by name
  100112. * @param name defines the name of the behavior to look for
  100113. * @see http://doc.babylonjs.com/features/behaviour
  100114. * @returns null if behavior was not found else the requested behavior
  100115. */
  100116. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  100117. /**
  100118. * Returns the latest update of the World matrix
  100119. * @returns a Matrix
  100120. */
  100121. getWorldMatrix(): Matrix;
  100122. /** @hidden */
  100123. _getWorldMatrixDeterminant(): number;
  100124. /**
  100125. * Returns directly the latest state of the mesh World matrix.
  100126. * A Matrix is returned.
  100127. */
  100128. get worldMatrixFromCache(): Matrix;
  100129. /** @hidden */
  100130. _initCache(): void;
  100131. /** @hidden */
  100132. updateCache(force?: boolean): void;
  100133. /** @hidden */
  100134. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  100135. /** @hidden */
  100136. _updateCache(ignoreParentClass?: boolean): void;
  100137. /** @hidden */
  100138. _isSynchronized(): boolean;
  100139. /** @hidden */
  100140. _markSyncedWithParent(): void;
  100141. /** @hidden */
  100142. isSynchronizedWithParent(): boolean;
  100143. /** @hidden */
  100144. isSynchronized(): boolean;
  100145. /**
  100146. * Is this node ready to be used/rendered
  100147. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  100148. * @return true if the node is ready
  100149. */
  100150. isReady(completeCheck?: boolean): boolean;
  100151. /**
  100152. * Is this node enabled?
  100153. * 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
  100154. * @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
  100155. * @return whether this node (and its parent) is enabled
  100156. */
  100157. isEnabled(checkAncestors?: boolean): boolean;
  100158. /** @hidden */
  100159. protected _syncParentEnabledState(): void;
  100160. /**
  100161. * Set the enabled state of this node
  100162. * @param value defines the new enabled state
  100163. */
  100164. setEnabled(value: boolean): void;
  100165. /**
  100166. * Is this node a descendant of the given node?
  100167. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  100168. * @param ancestor defines the parent node to inspect
  100169. * @returns a boolean indicating if this node is a descendant of the given node
  100170. */
  100171. isDescendantOf(ancestor: Node): boolean;
  100172. /** @hidden */
  100173. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  100174. /**
  100175. * Will return all nodes that have this node as ascendant
  100176. * @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
  100177. * @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
  100178. * @return all children nodes of all types
  100179. */
  100180. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  100181. /**
  100182. * Get all child-meshes of this node
  100183. * @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)
  100184. * @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
  100185. * @returns an array of AbstractMesh
  100186. */
  100187. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  100188. /**
  100189. * Get all direct children of this node
  100190. * @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
  100191. * @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)
  100192. * @returns an array of Node
  100193. */
  100194. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  100195. /** @hidden */
  100196. _setReady(state: boolean): void;
  100197. /**
  100198. * Get an animation by name
  100199. * @param name defines the name of the animation to look for
  100200. * @returns null if not found else the requested animation
  100201. */
  100202. getAnimationByName(name: string): Nullable<Animation>;
  100203. /**
  100204. * Creates an animation range for this node
  100205. * @param name defines the name of the range
  100206. * @param from defines the starting key
  100207. * @param to defines the end key
  100208. */
  100209. createAnimationRange(name: string, from: number, to: number): void;
  100210. /**
  100211. * Delete a specific animation range
  100212. * @param name defines the name of the range to delete
  100213. * @param deleteFrames defines if animation frames from the range must be deleted as well
  100214. */
  100215. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  100216. /**
  100217. * Get an animation range by name
  100218. * @param name defines the name of the animation range to look for
  100219. * @returns null if not found else the requested animation range
  100220. */
  100221. getAnimationRange(name: string): Nullable<AnimationRange>;
  100222. /**
  100223. * Gets the list of all animation ranges defined on this node
  100224. * @returns an array
  100225. */
  100226. getAnimationRanges(): Nullable<AnimationRange>[];
  100227. /**
  100228. * Will start the animation sequence
  100229. * @param name defines the range frames for animation sequence
  100230. * @param loop defines if the animation should loop (false by default)
  100231. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  100232. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  100233. * @returns the object created for this animation. If range does not exist, it will return null
  100234. */
  100235. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  100236. /**
  100237. * Serialize animation ranges into a JSON compatible object
  100238. * @returns serialization object
  100239. */
  100240. serializeAnimationRanges(): any;
  100241. /**
  100242. * Computes the world matrix of the node
  100243. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100244. * @returns the world matrix
  100245. */
  100246. computeWorldMatrix(force?: boolean): Matrix;
  100247. /**
  100248. * Releases resources associated with this node.
  100249. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100250. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100251. */
  100252. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100253. /**
  100254. * Parse animation range data from a serialization object and store them into a given node
  100255. * @param node defines where to store the animation ranges
  100256. * @param parsedNode defines the serialization object to read data from
  100257. * @param scene defines the hosting scene
  100258. */
  100259. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  100260. /**
  100261. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  100262. * @param includeDescendants Include bounding info from descendants as well (true by default)
  100263. * @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
  100264. * @returns the new bounding vectors
  100265. */
  100266. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  100267. min: Vector3;
  100268. max: Vector3;
  100269. };
  100270. }
  100271. }
  100272. declare module BABYLON {
  100273. /**
  100274. * @hidden
  100275. */
  100276. export class _IAnimationState {
  100277. key: number;
  100278. repeatCount: number;
  100279. workValue?: any;
  100280. loopMode?: number;
  100281. offsetValue?: any;
  100282. highLimitValue?: any;
  100283. }
  100284. /**
  100285. * Class used to store any kind of animation
  100286. */
  100287. export class Animation {
  100288. /**Name of the animation */
  100289. name: string;
  100290. /**Property to animate */
  100291. targetProperty: string;
  100292. /**The frames per second of the animation */
  100293. framePerSecond: number;
  100294. /**The data type of the animation */
  100295. dataType: number;
  100296. /**The loop mode of the animation */
  100297. loopMode?: number | undefined;
  100298. /**Specifies if blending should be enabled */
  100299. enableBlending?: boolean | undefined;
  100300. /**
  100301. * Use matrix interpolation instead of using direct key value when animating matrices
  100302. */
  100303. static AllowMatricesInterpolation: boolean;
  100304. /**
  100305. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  100306. */
  100307. static AllowMatrixDecomposeForInterpolation: boolean;
  100308. /**
  100309. * Stores the key frames of the animation
  100310. */
  100311. private _keys;
  100312. /**
  100313. * Stores the easing function of the animation
  100314. */
  100315. private _easingFunction;
  100316. /**
  100317. * @hidden Internal use only
  100318. */
  100319. _runtimeAnimations: RuntimeAnimation[];
  100320. /**
  100321. * The set of event that will be linked to this animation
  100322. */
  100323. private _events;
  100324. /**
  100325. * Stores an array of target property paths
  100326. */
  100327. targetPropertyPath: string[];
  100328. /**
  100329. * Stores the blending speed of the animation
  100330. */
  100331. blendingSpeed: number;
  100332. /**
  100333. * Stores the animation ranges for the animation
  100334. */
  100335. private _ranges;
  100336. /**
  100337. * @hidden Internal use
  100338. */
  100339. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  100340. /**
  100341. * Sets up an animation
  100342. * @param property The property to animate
  100343. * @param animationType The animation type to apply
  100344. * @param framePerSecond The frames per second of the animation
  100345. * @param easingFunction The easing function used in the animation
  100346. * @returns The created animation
  100347. */
  100348. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  100349. /**
  100350. * Create and start an animation on a node
  100351. * @param name defines the name of the global animation that will be run on all nodes
  100352. * @param node defines the root node where the animation will take place
  100353. * @param targetProperty defines property to animate
  100354. * @param framePerSecond defines the number of frame per second yo use
  100355. * @param totalFrame defines the number of frames in total
  100356. * @param from defines the initial value
  100357. * @param to defines the final value
  100358. * @param loopMode defines which loop mode you want to use (off by default)
  100359. * @param easingFunction defines the easing function to use (linear by default)
  100360. * @param onAnimationEnd defines the callback to call when animation end
  100361. * @returns the animatable created for this animation
  100362. */
  100363. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  100364. /**
  100365. * Create and start an animation on a node and its descendants
  100366. * @param name defines the name of the global animation that will be run on all nodes
  100367. * @param node defines the root node where the animation will take place
  100368. * @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
  100369. * @param targetProperty defines property to animate
  100370. * @param framePerSecond defines the number of frame per second to use
  100371. * @param totalFrame defines the number of frames in total
  100372. * @param from defines the initial value
  100373. * @param to defines the final value
  100374. * @param loopMode defines which loop mode you want to use (off by default)
  100375. * @param easingFunction defines the easing function to use (linear by default)
  100376. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  100377. * @returns the list of animatables created for all nodes
  100378. * @example https://www.babylonjs-playground.com/#MH0VLI
  100379. */
  100380. 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[]>;
  100381. /**
  100382. * Creates a new animation, merges it with the existing animations and starts it
  100383. * @param name Name of the animation
  100384. * @param node Node which contains the scene that begins the animations
  100385. * @param targetProperty Specifies which property to animate
  100386. * @param framePerSecond The frames per second of the animation
  100387. * @param totalFrame The total number of frames
  100388. * @param from The frame at the beginning of the animation
  100389. * @param to The frame at the end of the animation
  100390. * @param loopMode Specifies the loop mode of the animation
  100391. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  100392. * @param onAnimationEnd Callback to run once the animation is complete
  100393. * @returns Nullable animation
  100394. */
  100395. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  100396. /**
  100397. * Transition property of an host to the target Value
  100398. * @param property The property to transition
  100399. * @param targetValue The target Value of the property
  100400. * @param host The object where the property to animate belongs
  100401. * @param scene Scene used to run the animation
  100402. * @param frameRate Framerate (in frame/s) to use
  100403. * @param transition The transition type we want to use
  100404. * @param duration The duration of the animation, in milliseconds
  100405. * @param onAnimationEnd Callback trigger at the end of the animation
  100406. * @returns Nullable animation
  100407. */
  100408. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  100409. /**
  100410. * Return the array of runtime animations currently using this animation
  100411. */
  100412. get runtimeAnimations(): RuntimeAnimation[];
  100413. /**
  100414. * Specifies if any of the runtime animations are currently running
  100415. */
  100416. get hasRunningRuntimeAnimations(): boolean;
  100417. /**
  100418. * Initializes the animation
  100419. * @param name Name of the animation
  100420. * @param targetProperty Property to animate
  100421. * @param framePerSecond The frames per second of the animation
  100422. * @param dataType The data type of the animation
  100423. * @param loopMode The loop mode of the animation
  100424. * @param enableBlending Specifies if blending should be enabled
  100425. */
  100426. constructor(
  100427. /**Name of the animation */
  100428. name: string,
  100429. /**Property to animate */
  100430. targetProperty: string,
  100431. /**The frames per second of the animation */
  100432. framePerSecond: number,
  100433. /**The data type of the animation */
  100434. dataType: number,
  100435. /**The loop mode of the animation */
  100436. loopMode?: number | undefined,
  100437. /**Specifies if blending should be enabled */
  100438. enableBlending?: boolean | undefined);
  100439. /**
  100440. * Converts the animation to a string
  100441. * @param fullDetails support for multiple levels of logging within scene loading
  100442. * @returns String form of the animation
  100443. */
  100444. toString(fullDetails?: boolean): string;
  100445. /**
  100446. * Add an event to this animation
  100447. * @param event Event to add
  100448. */
  100449. addEvent(event: AnimationEvent): void;
  100450. /**
  100451. * Remove all events found at the given frame
  100452. * @param frame The frame to remove events from
  100453. */
  100454. removeEvents(frame: number): void;
  100455. /**
  100456. * Retrieves all the events from the animation
  100457. * @returns Events from the animation
  100458. */
  100459. getEvents(): AnimationEvent[];
  100460. /**
  100461. * Creates an animation range
  100462. * @param name Name of the animation range
  100463. * @param from Starting frame of the animation range
  100464. * @param to Ending frame of the animation
  100465. */
  100466. createRange(name: string, from: number, to: number): void;
  100467. /**
  100468. * Deletes an animation range by name
  100469. * @param name Name of the animation range to delete
  100470. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  100471. */
  100472. deleteRange(name: string, deleteFrames?: boolean): void;
  100473. /**
  100474. * Gets the animation range by name, or null if not defined
  100475. * @param name Name of the animation range
  100476. * @returns Nullable animation range
  100477. */
  100478. getRange(name: string): Nullable<AnimationRange>;
  100479. /**
  100480. * Gets the key frames from the animation
  100481. * @returns The key frames of the animation
  100482. */
  100483. getKeys(): Array<IAnimationKey>;
  100484. /**
  100485. * Gets the highest frame rate of the animation
  100486. * @returns Highest frame rate of the animation
  100487. */
  100488. getHighestFrame(): number;
  100489. /**
  100490. * Gets the easing function of the animation
  100491. * @returns Easing function of the animation
  100492. */
  100493. getEasingFunction(): IEasingFunction;
  100494. /**
  100495. * Sets the easing function of the animation
  100496. * @param easingFunction A custom mathematical formula for animation
  100497. */
  100498. setEasingFunction(easingFunction: EasingFunction): void;
  100499. /**
  100500. * Interpolates a scalar linearly
  100501. * @param startValue Start value of the animation curve
  100502. * @param endValue End value of the animation curve
  100503. * @param gradient Scalar amount to interpolate
  100504. * @returns Interpolated scalar value
  100505. */
  100506. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  100507. /**
  100508. * Interpolates a scalar cubically
  100509. * @param startValue Start value of the animation curve
  100510. * @param outTangent End tangent of the animation
  100511. * @param endValue End value of the animation curve
  100512. * @param inTangent Start tangent of the animation curve
  100513. * @param gradient Scalar amount to interpolate
  100514. * @returns Interpolated scalar value
  100515. */
  100516. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  100517. /**
  100518. * Interpolates a quaternion using a spherical linear interpolation
  100519. * @param startValue Start value of the animation curve
  100520. * @param endValue End value of the animation curve
  100521. * @param gradient Scalar amount to interpolate
  100522. * @returns Interpolated quaternion value
  100523. */
  100524. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  100525. /**
  100526. * Interpolates a quaternion cubically
  100527. * @param startValue Start value of the animation curve
  100528. * @param outTangent End tangent of the animation curve
  100529. * @param endValue End value of the animation curve
  100530. * @param inTangent Start tangent of the animation curve
  100531. * @param gradient Scalar amount to interpolate
  100532. * @returns Interpolated quaternion value
  100533. */
  100534. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  100535. /**
  100536. * Interpolates a Vector3 linearl
  100537. * @param startValue Start value of the animation curve
  100538. * @param endValue End value of the animation curve
  100539. * @param gradient Scalar amount to interpolate
  100540. * @returns Interpolated scalar value
  100541. */
  100542. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  100543. /**
  100544. * Interpolates a Vector3 cubically
  100545. * @param startValue Start value of the animation curve
  100546. * @param outTangent End tangent of the animation
  100547. * @param endValue End value of the animation curve
  100548. * @param inTangent Start tangent of the animation curve
  100549. * @param gradient Scalar amount to interpolate
  100550. * @returns InterpolatedVector3 value
  100551. */
  100552. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  100553. /**
  100554. * Interpolates a Vector2 linearly
  100555. * @param startValue Start value of the animation curve
  100556. * @param endValue End value of the animation curve
  100557. * @param gradient Scalar amount to interpolate
  100558. * @returns Interpolated Vector2 value
  100559. */
  100560. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  100561. /**
  100562. * Interpolates a Vector2 cubically
  100563. * @param startValue Start value of the animation curve
  100564. * @param outTangent End tangent of the animation
  100565. * @param endValue End value of the animation curve
  100566. * @param inTangent Start tangent of the animation curve
  100567. * @param gradient Scalar amount to interpolate
  100568. * @returns Interpolated Vector2 value
  100569. */
  100570. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  100571. /**
  100572. * Interpolates a size linearly
  100573. * @param startValue Start value of the animation curve
  100574. * @param endValue End value of the animation curve
  100575. * @param gradient Scalar amount to interpolate
  100576. * @returns Interpolated Size value
  100577. */
  100578. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  100579. /**
  100580. * Interpolates a Color3 linearly
  100581. * @param startValue Start value of the animation curve
  100582. * @param endValue End value of the animation curve
  100583. * @param gradient Scalar amount to interpolate
  100584. * @returns Interpolated Color3 value
  100585. */
  100586. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  100587. /**
  100588. * Interpolates a Color4 linearly
  100589. * @param startValue Start value of the animation curve
  100590. * @param endValue End value of the animation curve
  100591. * @param gradient Scalar amount to interpolate
  100592. * @returns Interpolated Color3 value
  100593. */
  100594. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  100595. /**
  100596. * @hidden Internal use only
  100597. */
  100598. _getKeyValue(value: any): any;
  100599. /**
  100600. * @hidden Internal use only
  100601. */
  100602. _interpolate(currentFrame: number, state: _IAnimationState): any;
  100603. /**
  100604. * Defines the function to use to interpolate matrices
  100605. * @param startValue defines the start matrix
  100606. * @param endValue defines the end matrix
  100607. * @param gradient defines the gradient between both matrices
  100608. * @param result defines an optional target matrix where to store the interpolation
  100609. * @returns the interpolated matrix
  100610. */
  100611. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  100612. /**
  100613. * Makes a copy of the animation
  100614. * @returns Cloned animation
  100615. */
  100616. clone(): Animation;
  100617. /**
  100618. * Sets the key frames of the animation
  100619. * @param values The animation key frames to set
  100620. */
  100621. setKeys(values: Array<IAnimationKey>): void;
  100622. /**
  100623. * Serializes the animation to an object
  100624. * @returns Serialized object
  100625. */
  100626. serialize(): any;
  100627. /**
  100628. * Float animation type
  100629. */
  100630. static readonly ANIMATIONTYPE_FLOAT: number;
  100631. /**
  100632. * Vector3 animation type
  100633. */
  100634. static readonly ANIMATIONTYPE_VECTOR3: number;
  100635. /**
  100636. * Quaternion animation type
  100637. */
  100638. static readonly ANIMATIONTYPE_QUATERNION: number;
  100639. /**
  100640. * Matrix animation type
  100641. */
  100642. static readonly ANIMATIONTYPE_MATRIX: number;
  100643. /**
  100644. * Color3 animation type
  100645. */
  100646. static readonly ANIMATIONTYPE_COLOR3: number;
  100647. /**
  100648. * Color3 animation type
  100649. */
  100650. static readonly ANIMATIONTYPE_COLOR4: number;
  100651. /**
  100652. * Vector2 animation type
  100653. */
  100654. static readonly ANIMATIONTYPE_VECTOR2: number;
  100655. /**
  100656. * Size animation type
  100657. */
  100658. static readonly ANIMATIONTYPE_SIZE: number;
  100659. /**
  100660. * Relative Loop Mode
  100661. */
  100662. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  100663. /**
  100664. * Cycle Loop Mode
  100665. */
  100666. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  100667. /**
  100668. * Constant Loop Mode
  100669. */
  100670. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  100671. /** @hidden */
  100672. static _UniversalLerp(left: any, right: any, amount: number): any;
  100673. /**
  100674. * Parses an animation object and creates an animation
  100675. * @param parsedAnimation Parsed animation object
  100676. * @returns Animation object
  100677. */
  100678. static Parse(parsedAnimation: any): Animation;
  100679. /**
  100680. * Appends the serialized animations from the source animations
  100681. * @param source Source containing the animations
  100682. * @param destination Target to store the animations
  100683. */
  100684. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  100685. }
  100686. }
  100687. declare module BABYLON {
  100688. /**
  100689. * Interface containing an array of animations
  100690. */
  100691. export interface IAnimatable {
  100692. /**
  100693. * Array of animations
  100694. */
  100695. animations: Nullable<Array<Animation>>;
  100696. }
  100697. }
  100698. declare module BABYLON {
  100699. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  100700. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100701. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100702. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100703. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100704. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100705. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100706. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100707. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100708. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100709. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100710. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100711. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100712. /**
  100713. * Decorator used to define property that can be serialized as reference to a camera
  100714. * @param sourceName defines the name of the property to decorate
  100715. */
  100716. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100717. /**
  100718. * Class used to help serialization objects
  100719. */
  100720. export class SerializationHelper {
  100721. /** @hidden */
  100722. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  100723. /** @hidden */
  100724. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  100725. /** @hidden */
  100726. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  100727. /** @hidden */
  100728. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  100729. /**
  100730. * Appends the serialized animations from the source animations
  100731. * @param source Source containing the animations
  100732. * @param destination Target to store the animations
  100733. */
  100734. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  100735. /**
  100736. * Static function used to serialized a specific entity
  100737. * @param entity defines the entity to serialize
  100738. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  100739. * @returns a JSON compatible object representing the serialization of the entity
  100740. */
  100741. static Serialize<T>(entity: T, serializationObject?: any): any;
  100742. /**
  100743. * Creates a new entity from a serialization data object
  100744. * @param creationFunction defines a function used to instanciated the new entity
  100745. * @param source defines the source serialization data
  100746. * @param scene defines the hosting scene
  100747. * @param rootUrl defines the root url for resources
  100748. * @returns a new entity
  100749. */
  100750. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  100751. /**
  100752. * Clones an object
  100753. * @param creationFunction defines the function used to instanciate the new object
  100754. * @param source defines the source object
  100755. * @returns the cloned object
  100756. */
  100757. static Clone<T>(creationFunction: () => T, source: T): T;
  100758. /**
  100759. * Instanciates a new object based on a source one (some data will be shared between both object)
  100760. * @param creationFunction defines the function used to instanciate the new object
  100761. * @param source defines the source object
  100762. * @returns the new object
  100763. */
  100764. static Instanciate<T>(creationFunction: () => T, source: T): T;
  100765. }
  100766. }
  100767. declare module BABYLON {
  100768. /**
  100769. * Class used to manipulate GUIDs
  100770. */
  100771. export class GUID {
  100772. /**
  100773. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100774. * Be aware Math.random() could cause collisions, but:
  100775. * "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"
  100776. * @returns a pseudo random id
  100777. */
  100778. static RandomId(): string;
  100779. }
  100780. }
  100781. declare module BABYLON {
  100782. /**
  100783. * Base class of all the textures in babylon.
  100784. * It groups all the common properties the materials, post process, lights... might need
  100785. * in order to make a correct use of the texture.
  100786. */
  100787. export class BaseTexture implements IAnimatable {
  100788. /**
  100789. * Default anisotropic filtering level for the application.
  100790. * It is set to 4 as a good tradeoff between perf and quality.
  100791. */
  100792. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  100793. /**
  100794. * Gets or sets the unique id of the texture
  100795. */
  100796. uniqueId: number;
  100797. /**
  100798. * Define the name of the texture.
  100799. */
  100800. name: string;
  100801. /**
  100802. * Gets or sets an object used to store user defined information.
  100803. */
  100804. metadata: any;
  100805. /**
  100806. * For internal use only. Please do not use.
  100807. */
  100808. reservedDataStore: any;
  100809. private _hasAlpha;
  100810. /**
  100811. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  100812. */
  100813. set hasAlpha(value: boolean);
  100814. get hasAlpha(): boolean;
  100815. /**
  100816. * Defines if the alpha value should be determined via the rgb values.
  100817. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  100818. */
  100819. getAlphaFromRGB: boolean;
  100820. /**
  100821. * Intensity or strength of the texture.
  100822. * It is commonly used by materials to fine tune the intensity of the texture
  100823. */
  100824. level: number;
  100825. /**
  100826. * Define the UV chanel to use starting from 0 and defaulting to 0.
  100827. * This is part of the texture as textures usually maps to one uv set.
  100828. */
  100829. coordinatesIndex: number;
  100830. private _coordinatesMode;
  100831. /**
  100832. * How a texture is mapped.
  100833. *
  100834. * | Value | Type | Description |
  100835. * | ----- | ----------------------------------- | ----------- |
  100836. * | 0 | EXPLICIT_MODE | |
  100837. * | 1 | SPHERICAL_MODE | |
  100838. * | 2 | PLANAR_MODE | |
  100839. * | 3 | CUBIC_MODE | |
  100840. * | 4 | PROJECTION_MODE | |
  100841. * | 5 | SKYBOX_MODE | |
  100842. * | 6 | INVCUBIC_MODE | |
  100843. * | 7 | EQUIRECTANGULAR_MODE | |
  100844. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  100845. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  100846. */
  100847. set coordinatesMode(value: number);
  100848. get coordinatesMode(): number;
  100849. /**
  100850. * | Value | Type | Description |
  100851. * | ----- | ------------------ | ----------- |
  100852. * | 0 | CLAMP_ADDRESSMODE | |
  100853. * | 1 | WRAP_ADDRESSMODE | |
  100854. * | 2 | MIRROR_ADDRESSMODE | |
  100855. */
  100856. wrapU: number;
  100857. /**
  100858. * | Value | Type | Description |
  100859. * | ----- | ------------------ | ----------- |
  100860. * | 0 | CLAMP_ADDRESSMODE | |
  100861. * | 1 | WRAP_ADDRESSMODE | |
  100862. * | 2 | MIRROR_ADDRESSMODE | |
  100863. */
  100864. wrapV: number;
  100865. /**
  100866. * | Value | Type | Description |
  100867. * | ----- | ------------------ | ----------- |
  100868. * | 0 | CLAMP_ADDRESSMODE | |
  100869. * | 1 | WRAP_ADDRESSMODE | |
  100870. * | 2 | MIRROR_ADDRESSMODE | |
  100871. */
  100872. wrapR: number;
  100873. /**
  100874. * With compliant hardware and browser (supporting anisotropic filtering)
  100875. * this defines the level of anisotropic filtering in the texture.
  100876. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  100877. */
  100878. anisotropicFilteringLevel: number;
  100879. /**
  100880. * Define if the texture is a cube texture or if false a 2d texture.
  100881. */
  100882. get isCube(): boolean;
  100883. set isCube(value: boolean);
  100884. /**
  100885. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  100886. */
  100887. get is3D(): boolean;
  100888. set is3D(value: boolean);
  100889. /**
  100890. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  100891. */
  100892. get is2DArray(): boolean;
  100893. set is2DArray(value: boolean);
  100894. /**
  100895. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  100896. * HDR texture are usually stored in linear space.
  100897. * This only impacts the PBR and Background materials
  100898. */
  100899. gammaSpace: boolean;
  100900. /**
  100901. * Gets or sets whether or not the texture contains RGBD data.
  100902. */
  100903. get isRGBD(): boolean;
  100904. set isRGBD(value: boolean);
  100905. /**
  100906. * Is Z inverted in the texture (useful in a cube texture).
  100907. */
  100908. invertZ: boolean;
  100909. /**
  100910. * Are mip maps generated for this texture or not.
  100911. */
  100912. get noMipmap(): boolean;
  100913. /**
  100914. * @hidden
  100915. */
  100916. lodLevelInAlpha: boolean;
  100917. /**
  100918. * With prefiltered texture, defined the offset used during the prefiltering steps.
  100919. */
  100920. get lodGenerationOffset(): number;
  100921. set lodGenerationOffset(value: number);
  100922. /**
  100923. * With prefiltered texture, defined the scale used during the prefiltering steps.
  100924. */
  100925. get lodGenerationScale(): number;
  100926. set lodGenerationScale(value: number);
  100927. /**
  100928. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  100929. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  100930. * average roughness values.
  100931. */
  100932. get linearSpecularLOD(): boolean;
  100933. set linearSpecularLOD(value: boolean);
  100934. /**
  100935. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  100936. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  100937. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  100938. */
  100939. get irradianceTexture(): Nullable<BaseTexture>;
  100940. set irradianceTexture(value: Nullable<BaseTexture>);
  100941. /**
  100942. * Define if the texture is a render target.
  100943. */
  100944. isRenderTarget: boolean;
  100945. /**
  100946. * Define the unique id of the texture in the scene.
  100947. */
  100948. get uid(): string;
  100949. /**
  100950. * Return a string representation of the texture.
  100951. * @returns the texture as a string
  100952. */
  100953. toString(): string;
  100954. /**
  100955. * Get the class name of the texture.
  100956. * @returns "BaseTexture"
  100957. */
  100958. getClassName(): string;
  100959. /**
  100960. * Define the list of animation attached to the texture.
  100961. */
  100962. animations: Animation[];
  100963. /**
  100964. * An event triggered when the texture is disposed.
  100965. */
  100966. onDisposeObservable: Observable<BaseTexture>;
  100967. private _onDisposeObserver;
  100968. /**
  100969. * Callback triggered when the texture has been disposed.
  100970. * Kept for back compatibility, you can use the onDisposeObservable instead.
  100971. */
  100972. set onDispose(callback: () => void);
  100973. /**
  100974. * Define the current state of the loading sequence when in delayed load mode.
  100975. */
  100976. delayLoadState: number;
  100977. private _scene;
  100978. /** @hidden */
  100979. _texture: Nullable<InternalTexture>;
  100980. private _uid;
  100981. /**
  100982. * Define if the texture is preventinga material to render or not.
  100983. * If not and the texture is not ready, the engine will use a default black texture instead.
  100984. */
  100985. get isBlocking(): boolean;
  100986. /**
  100987. * Instantiates a new BaseTexture.
  100988. * Base class of all the textures in babylon.
  100989. * It groups all the common properties the materials, post process, lights... might need
  100990. * in order to make a correct use of the texture.
  100991. * @param scene Define the scene the texture blongs to
  100992. */
  100993. constructor(scene: Nullable<Scene>);
  100994. /**
  100995. * Get the scene the texture belongs to.
  100996. * @returns the scene or null if undefined
  100997. */
  100998. getScene(): Nullable<Scene>;
  100999. /**
  101000. * Get the texture transform matrix used to offset tile the texture for istance.
  101001. * @returns the transformation matrix
  101002. */
  101003. getTextureMatrix(): Matrix;
  101004. /**
  101005. * Get the texture reflection matrix used to rotate/transform the reflection.
  101006. * @returns the reflection matrix
  101007. */
  101008. getReflectionTextureMatrix(): Matrix;
  101009. /**
  101010. * Get the underlying lower level texture from Babylon.
  101011. * @returns the insternal texture
  101012. */
  101013. getInternalTexture(): Nullable<InternalTexture>;
  101014. /**
  101015. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  101016. * @returns true if ready or not blocking
  101017. */
  101018. isReadyOrNotBlocking(): boolean;
  101019. /**
  101020. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  101021. * @returns true if fully ready
  101022. */
  101023. isReady(): boolean;
  101024. private _cachedSize;
  101025. /**
  101026. * Get the size of the texture.
  101027. * @returns the texture size.
  101028. */
  101029. getSize(): ISize;
  101030. /**
  101031. * Get the base size of the texture.
  101032. * It can be different from the size if the texture has been resized for POT for instance
  101033. * @returns the base size
  101034. */
  101035. getBaseSize(): ISize;
  101036. /**
  101037. * Update the sampling mode of the texture.
  101038. * Default is Trilinear mode.
  101039. *
  101040. * | Value | Type | Description |
  101041. * | ----- | ------------------ | ----------- |
  101042. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  101043. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  101044. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  101045. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  101046. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  101047. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  101048. * | 7 | NEAREST_LINEAR | |
  101049. * | 8 | NEAREST_NEAREST | |
  101050. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  101051. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  101052. * | 11 | LINEAR_LINEAR | |
  101053. * | 12 | LINEAR_NEAREST | |
  101054. *
  101055. * > _mag_: magnification filter (close to the viewer)
  101056. * > _min_: minification filter (far from the viewer)
  101057. * > _mip_: filter used between mip map levels
  101058. *@param samplingMode Define the new sampling mode of the texture
  101059. */
  101060. updateSamplingMode(samplingMode: number): void;
  101061. /**
  101062. * Scales the texture if is `canRescale()`
  101063. * @param ratio the resize factor we want to use to rescale
  101064. */
  101065. scale(ratio: number): void;
  101066. /**
  101067. * Get if the texture can rescale.
  101068. */
  101069. get canRescale(): boolean;
  101070. /** @hidden */
  101071. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  101072. /** @hidden */
  101073. _rebuild(): void;
  101074. /**
  101075. * Triggers the load sequence in delayed load mode.
  101076. */
  101077. delayLoad(): void;
  101078. /**
  101079. * Clones the texture.
  101080. * @returns the cloned texture
  101081. */
  101082. clone(): Nullable<BaseTexture>;
  101083. /**
  101084. * Get the texture underlying type (INT, FLOAT...)
  101085. */
  101086. get textureType(): number;
  101087. /**
  101088. * Get the texture underlying format (RGB, RGBA...)
  101089. */
  101090. get textureFormat(): number;
  101091. /**
  101092. * Indicates that textures need to be re-calculated for all materials
  101093. */
  101094. protected _markAllSubMeshesAsTexturesDirty(): void;
  101095. /**
  101096. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  101097. * This will returns an RGBA array buffer containing either in values (0-255) or
  101098. * float values (0-1) depending of the underlying buffer type.
  101099. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  101100. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  101101. * @param buffer defines a user defined buffer to fill with data (can be null)
  101102. * @returns The Array buffer containing the pixels data.
  101103. */
  101104. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  101105. /**
  101106. * Release and destroy the underlying lower level texture aka internalTexture.
  101107. */
  101108. releaseInternalTexture(): void;
  101109. /** @hidden */
  101110. get _lodTextureHigh(): Nullable<BaseTexture>;
  101111. /** @hidden */
  101112. get _lodTextureMid(): Nullable<BaseTexture>;
  101113. /** @hidden */
  101114. get _lodTextureLow(): Nullable<BaseTexture>;
  101115. /**
  101116. * Dispose the texture and release its associated resources.
  101117. */
  101118. dispose(): void;
  101119. /**
  101120. * Serialize the texture into a JSON representation that can be parsed later on.
  101121. * @returns the JSON representation of the texture
  101122. */
  101123. serialize(): any;
  101124. /**
  101125. * Helper function to be called back once a list of texture contains only ready textures.
  101126. * @param textures Define the list of textures to wait for
  101127. * @param callback Define the callback triggered once the entire list will be ready
  101128. */
  101129. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  101130. }
  101131. }
  101132. declare module BABYLON {
  101133. /**
  101134. * Options to be used when creating an effect.
  101135. */
  101136. export interface IEffectCreationOptions {
  101137. /**
  101138. * Atrributes that will be used in the shader.
  101139. */
  101140. attributes: string[];
  101141. /**
  101142. * Uniform varible names that will be set in the shader.
  101143. */
  101144. uniformsNames: string[];
  101145. /**
  101146. * Uniform buffer variable names that will be set in the shader.
  101147. */
  101148. uniformBuffersNames: string[];
  101149. /**
  101150. * Sampler texture variable names that will be set in the shader.
  101151. */
  101152. samplers: string[];
  101153. /**
  101154. * Define statements that will be set in the shader.
  101155. */
  101156. defines: any;
  101157. /**
  101158. * Possible fallbacks for this effect to improve performance when needed.
  101159. */
  101160. fallbacks: Nullable<IEffectFallbacks>;
  101161. /**
  101162. * Callback that will be called when the shader is compiled.
  101163. */
  101164. onCompiled: Nullable<(effect: Effect) => void>;
  101165. /**
  101166. * Callback that will be called if an error occurs during shader compilation.
  101167. */
  101168. onError: Nullable<(effect: Effect, errors: string) => void>;
  101169. /**
  101170. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  101171. */
  101172. indexParameters?: any;
  101173. /**
  101174. * Max number of lights that can be used in the shader.
  101175. */
  101176. maxSimultaneousLights?: number;
  101177. /**
  101178. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  101179. */
  101180. transformFeedbackVaryings?: Nullable<string[]>;
  101181. }
  101182. /**
  101183. * Effect containing vertex and fragment shader that can be executed on an object.
  101184. */
  101185. export class Effect implements IDisposable {
  101186. /**
  101187. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  101188. */
  101189. static ShadersRepository: string;
  101190. /**
  101191. * Name of the effect.
  101192. */
  101193. name: any;
  101194. /**
  101195. * String container all the define statements that should be set on the shader.
  101196. */
  101197. defines: string;
  101198. /**
  101199. * Callback that will be called when the shader is compiled.
  101200. */
  101201. onCompiled: Nullable<(effect: Effect) => void>;
  101202. /**
  101203. * Callback that will be called if an error occurs during shader compilation.
  101204. */
  101205. onError: Nullable<(effect: Effect, errors: string) => void>;
  101206. /**
  101207. * Callback that will be called when effect is bound.
  101208. */
  101209. onBind: Nullable<(effect: Effect) => void>;
  101210. /**
  101211. * Unique ID of the effect.
  101212. */
  101213. uniqueId: number;
  101214. /**
  101215. * Observable that will be called when the shader is compiled.
  101216. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  101217. */
  101218. onCompileObservable: Observable<Effect>;
  101219. /**
  101220. * Observable that will be called if an error occurs during shader compilation.
  101221. */
  101222. onErrorObservable: Observable<Effect>;
  101223. /** @hidden */
  101224. _onBindObservable: Nullable<Observable<Effect>>;
  101225. /**
  101226. * @hidden
  101227. * Specifies if the effect was previously ready
  101228. */
  101229. _wasPreviouslyReady: boolean;
  101230. /**
  101231. * Observable that will be called when effect is bound.
  101232. */
  101233. get onBindObservable(): Observable<Effect>;
  101234. /** @hidden */
  101235. _bonesComputationForcedToCPU: boolean;
  101236. private static _uniqueIdSeed;
  101237. private _engine;
  101238. private _uniformBuffersNames;
  101239. private _uniformsNames;
  101240. private _samplerList;
  101241. private _samplers;
  101242. private _isReady;
  101243. private _compilationError;
  101244. private _allFallbacksProcessed;
  101245. private _attributesNames;
  101246. private _attributes;
  101247. private _attributeLocationByName;
  101248. private _uniforms;
  101249. /**
  101250. * Key for the effect.
  101251. * @hidden
  101252. */
  101253. _key: string;
  101254. private _indexParameters;
  101255. private _fallbacks;
  101256. private _vertexSourceCode;
  101257. private _fragmentSourceCode;
  101258. private _vertexSourceCodeOverride;
  101259. private _fragmentSourceCodeOverride;
  101260. private _transformFeedbackVaryings;
  101261. /**
  101262. * Compiled shader to webGL program.
  101263. * @hidden
  101264. */
  101265. _pipelineContext: Nullable<IPipelineContext>;
  101266. private _valueCache;
  101267. private static _baseCache;
  101268. /**
  101269. * Instantiates an effect.
  101270. * An effect can be used to create/manage/execute vertex and fragment shaders.
  101271. * @param baseName Name of the effect.
  101272. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  101273. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  101274. * @param samplers List of sampler variables that will be passed to the shader.
  101275. * @param engine Engine to be used to render the effect
  101276. * @param defines Define statements to be added to the shader.
  101277. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  101278. * @param onCompiled Callback that will be called when the shader is compiled.
  101279. * @param onError Callback that will be called if an error occurs during shader compilation.
  101280. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  101281. */
  101282. 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);
  101283. private _useFinalCode;
  101284. /**
  101285. * Unique key for this effect
  101286. */
  101287. get key(): string;
  101288. /**
  101289. * If the effect has been compiled and prepared.
  101290. * @returns if the effect is compiled and prepared.
  101291. */
  101292. isReady(): boolean;
  101293. private _isReadyInternal;
  101294. /**
  101295. * The engine the effect was initialized with.
  101296. * @returns the engine.
  101297. */
  101298. getEngine(): Engine;
  101299. /**
  101300. * The pipeline context for this effect
  101301. * @returns the associated pipeline context
  101302. */
  101303. getPipelineContext(): Nullable<IPipelineContext>;
  101304. /**
  101305. * The set of names of attribute variables for the shader.
  101306. * @returns An array of attribute names.
  101307. */
  101308. getAttributesNames(): string[];
  101309. /**
  101310. * Returns the attribute at the given index.
  101311. * @param index The index of the attribute.
  101312. * @returns The location of the attribute.
  101313. */
  101314. getAttributeLocation(index: number): number;
  101315. /**
  101316. * Returns the attribute based on the name of the variable.
  101317. * @param name of the attribute to look up.
  101318. * @returns the attribute location.
  101319. */
  101320. getAttributeLocationByName(name: string): number;
  101321. /**
  101322. * The number of attributes.
  101323. * @returns the numnber of attributes.
  101324. */
  101325. getAttributesCount(): number;
  101326. /**
  101327. * Gets the index of a uniform variable.
  101328. * @param uniformName of the uniform to look up.
  101329. * @returns the index.
  101330. */
  101331. getUniformIndex(uniformName: string): number;
  101332. /**
  101333. * Returns the attribute based on the name of the variable.
  101334. * @param uniformName of the uniform to look up.
  101335. * @returns the location of the uniform.
  101336. */
  101337. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  101338. /**
  101339. * Returns an array of sampler variable names
  101340. * @returns The array of sampler variable neames.
  101341. */
  101342. getSamplers(): string[];
  101343. /**
  101344. * The error from the last compilation.
  101345. * @returns the error string.
  101346. */
  101347. getCompilationError(): string;
  101348. /**
  101349. * Gets a boolean indicating that all fallbacks were used during compilation
  101350. * @returns true if all fallbacks were used
  101351. */
  101352. allFallbacksProcessed(): boolean;
  101353. /**
  101354. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  101355. * @param func The callback to be used.
  101356. */
  101357. executeWhenCompiled(func: (effect: Effect) => void): void;
  101358. private _checkIsReady;
  101359. private _loadShader;
  101360. /**
  101361. * Recompiles the webGL program
  101362. * @param vertexSourceCode The source code for the vertex shader.
  101363. * @param fragmentSourceCode The source code for the fragment shader.
  101364. * @param onCompiled Callback called when completed.
  101365. * @param onError Callback called on error.
  101366. * @hidden
  101367. */
  101368. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  101369. /**
  101370. * Prepares the effect
  101371. * @hidden
  101372. */
  101373. _prepareEffect(): void;
  101374. private _processCompilationErrors;
  101375. /**
  101376. * Checks if the effect is supported. (Must be called after compilation)
  101377. */
  101378. get isSupported(): boolean;
  101379. /**
  101380. * Binds a texture to the engine to be used as output of the shader.
  101381. * @param channel Name of the output variable.
  101382. * @param texture Texture to bind.
  101383. * @hidden
  101384. */
  101385. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  101386. /**
  101387. * Sets a texture on the engine to be used in the shader.
  101388. * @param channel Name of the sampler variable.
  101389. * @param texture Texture to set.
  101390. */
  101391. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  101392. /**
  101393. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  101394. * @param channel Name of the sampler variable.
  101395. * @param texture Texture to set.
  101396. */
  101397. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  101398. /**
  101399. * Sets an array of textures on the engine to be used in the shader.
  101400. * @param channel Name of the variable.
  101401. * @param textures Textures to set.
  101402. */
  101403. setTextureArray(channel: string, textures: BaseTexture[]): void;
  101404. /**
  101405. * 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)
  101406. * @param channel Name of the sampler variable.
  101407. * @param postProcess Post process to get the input texture from.
  101408. */
  101409. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  101410. /**
  101411. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  101412. * 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)
  101413. * @param channel Name of the sampler variable.
  101414. * @param postProcess Post process to get the output texture from.
  101415. */
  101416. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  101417. /** @hidden */
  101418. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  101419. /** @hidden */
  101420. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  101421. /** @hidden */
  101422. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  101423. /** @hidden */
  101424. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  101425. /**
  101426. * Binds a buffer to a uniform.
  101427. * @param buffer Buffer to bind.
  101428. * @param name Name of the uniform variable to bind to.
  101429. */
  101430. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  101431. /**
  101432. * Binds block to a uniform.
  101433. * @param blockName Name of the block to bind.
  101434. * @param index Index to bind.
  101435. */
  101436. bindUniformBlock(blockName: string, index: number): void;
  101437. /**
  101438. * Sets an interger value on a uniform variable.
  101439. * @param uniformName Name of the variable.
  101440. * @param value Value to be set.
  101441. * @returns this effect.
  101442. */
  101443. setInt(uniformName: string, value: number): Effect;
  101444. /**
  101445. * Sets an int array on a uniform variable.
  101446. * @param uniformName Name of the variable.
  101447. * @param array array to be set.
  101448. * @returns this effect.
  101449. */
  101450. setIntArray(uniformName: string, array: Int32Array): Effect;
  101451. /**
  101452. * 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)
  101453. * @param uniformName Name of the variable.
  101454. * @param array array to be set.
  101455. * @returns this effect.
  101456. */
  101457. setIntArray2(uniformName: string, array: Int32Array): Effect;
  101458. /**
  101459. * 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)
  101460. * @param uniformName Name of the variable.
  101461. * @param array array to be set.
  101462. * @returns this effect.
  101463. */
  101464. setIntArray3(uniformName: string, array: Int32Array): Effect;
  101465. /**
  101466. * 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)
  101467. * @param uniformName Name of the variable.
  101468. * @param array array to be set.
  101469. * @returns this effect.
  101470. */
  101471. setIntArray4(uniformName: string, array: Int32Array): Effect;
  101472. /**
  101473. * Sets an float array on a uniform variable.
  101474. * @param uniformName Name of the variable.
  101475. * @param array array to be set.
  101476. * @returns this effect.
  101477. */
  101478. setFloatArray(uniformName: string, array: Float32Array): Effect;
  101479. /**
  101480. * 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)
  101481. * @param uniformName Name of the variable.
  101482. * @param array array to be set.
  101483. * @returns this effect.
  101484. */
  101485. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  101486. /**
  101487. * 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)
  101488. * @param uniformName Name of the variable.
  101489. * @param array array to be set.
  101490. * @returns this effect.
  101491. */
  101492. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  101493. /**
  101494. * 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)
  101495. * @param uniformName Name of the variable.
  101496. * @param array array to be set.
  101497. * @returns this effect.
  101498. */
  101499. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  101500. /**
  101501. * Sets an array on a uniform variable.
  101502. * @param uniformName Name of the variable.
  101503. * @param array array to be set.
  101504. * @returns this effect.
  101505. */
  101506. setArray(uniformName: string, array: number[]): Effect;
  101507. /**
  101508. * 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)
  101509. * @param uniformName Name of the variable.
  101510. * @param array array to be set.
  101511. * @returns this effect.
  101512. */
  101513. setArray2(uniformName: string, array: number[]): Effect;
  101514. /**
  101515. * 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)
  101516. * @param uniformName Name of the variable.
  101517. * @param array array to be set.
  101518. * @returns this effect.
  101519. */
  101520. setArray3(uniformName: string, array: number[]): Effect;
  101521. /**
  101522. * 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)
  101523. * @param uniformName Name of the variable.
  101524. * @param array array to be set.
  101525. * @returns this effect.
  101526. */
  101527. setArray4(uniformName: string, array: number[]): Effect;
  101528. /**
  101529. * Sets matrices on a uniform variable.
  101530. * @param uniformName Name of the variable.
  101531. * @param matrices matrices to be set.
  101532. * @returns this effect.
  101533. */
  101534. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  101535. /**
  101536. * Sets matrix on a uniform variable.
  101537. * @param uniformName Name of the variable.
  101538. * @param matrix matrix to be set.
  101539. * @returns this effect.
  101540. */
  101541. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  101542. /**
  101543. * 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)
  101544. * @param uniformName Name of the variable.
  101545. * @param matrix matrix to be set.
  101546. * @returns this effect.
  101547. */
  101548. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  101549. /**
  101550. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  101551. * @param uniformName Name of the variable.
  101552. * @param matrix matrix to be set.
  101553. * @returns this effect.
  101554. */
  101555. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  101556. /**
  101557. * Sets a float on a uniform variable.
  101558. * @param uniformName Name of the variable.
  101559. * @param value value to be set.
  101560. * @returns this effect.
  101561. */
  101562. setFloat(uniformName: string, value: number): Effect;
  101563. /**
  101564. * Sets a boolean on a uniform variable.
  101565. * @param uniformName Name of the variable.
  101566. * @param bool value to be set.
  101567. * @returns this effect.
  101568. */
  101569. setBool(uniformName: string, bool: boolean): Effect;
  101570. /**
  101571. * Sets a Vector2 on a uniform variable.
  101572. * @param uniformName Name of the variable.
  101573. * @param vector2 vector2 to be set.
  101574. * @returns this effect.
  101575. */
  101576. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  101577. /**
  101578. * Sets a float2 on a uniform variable.
  101579. * @param uniformName Name of the variable.
  101580. * @param x First float in float2.
  101581. * @param y Second float in float2.
  101582. * @returns this effect.
  101583. */
  101584. setFloat2(uniformName: string, x: number, y: number): Effect;
  101585. /**
  101586. * Sets a Vector3 on a uniform variable.
  101587. * @param uniformName Name of the variable.
  101588. * @param vector3 Value to be set.
  101589. * @returns this effect.
  101590. */
  101591. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  101592. /**
  101593. * Sets a float3 on a uniform variable.
  101594. * @param uniformName Name of the variable.
  101595. * @param x First float in float3.
  101596. * @param y Second float in float3.
  101597. * @param z Third float in float3.
  101598. * @returns this effect.
  101599. */
  101600. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  101601. /**
  101602. * Sets a Vector4 on a uniform variable.
  101603. * @param uniformName Name of the variable.
  101604. * @param vector4 Value to be set.
  101605. * @returns this effect.
  101606. */
  101607. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  101608. /**
  101609. * Sets a float4 on a uniform variable.
  101610. * @param uniformName Name of the variable.
  101611. * @param x First float in float4.
  101612. * @param y Second float in float4.
  101613. * @param z Third float in float4.
  101614. * @param w Fourth float in float4.
  101615. * @returns this effect.
  101616. */
  101617. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  101618. /**
  101619. * Sets a Color3 on a uniform variable.
  101620. * @param uniformName Name of the variable.
  101621. * @param color3 Value to be set.
  101622. * @returns this effect.
  101623. */
  101624. setColor3(uniformName: string, color3: IColor3Like): Effect;
  101625. /**
  101626. * Sets a Color4 on a uniform variable.
  101627. * @param uniformName Name of the variable.
  101628. * @param color3 Value to be set.
  101629. * @param alpha Alpha value to be set.
  101630. * @returns this effect.
  101631. */
  101632. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  101633. /**
  101634. * Sets a Color4 on a uniform variable
  101635. * @param uniformName defines the name of the variable
  101636. * @param color4 defines the value to be set
  101637. * @returns this effect.
  101638. */
  101639. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  101640. /** Release all associated resources */
  101641. dispose(): void;
  101642. /**
  101643. * This function will add a new shader to the shader store
  101644. * @param name the name of the shader
  101645. * @param pixelShader optional pixel shader content
  101646. * @param vertexShader optional vertex shader content
  101647. */
  101648. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  101649. /**
  101650. * Store of each shader (The can be looked up using effect.key)
  101651. */
  101652. static ShadersStore: {
  101653. [key: string]: string;
  101654. };
  101655. /**
  101656. * Store of each included file for a shader (The can be looked up using effect.key)
  101657. */
  101658. static IncludesShadersStore: {
  101659. [key: string]: string;
  101660. };
  101661. /**
  101662. * Resets the cache of effects.
  101663. */
  101664. static ResetCache(): void;
  101665. }
  101666. }
  101667. declare module BABYLON {
  101668. /**
  101669. * Interface used to describe the capabilities of the engine relatively to the current browser
  101670. */
  101671. export interface EngineCapabilities {
  101672. /** Maximum textures units per fragment shader */
  101673. maxTexturesImageUnits: number;
  101674. /** Maximum texture units per vertex shader */
  101675. maxVertexTextureImageUnits: number;
  101676. /** Maximum textures units in the entire pipeline */
  101677. maxCombinedTexturesImageUnits: number;
  101678. /** Maximum texture size */
  101679. maxTextureSize: number;
  101680. /** Maximum texture samples */
  101681. maxSamples?: number;
  101682. /** Maximum cube texture size */
  101683. maxCubemapTextureSize: number;
  101684. /** Maximum render texture size */
  101685. maxRenderTextureSize: number;
  101686. /** Maximum number of vertex attributes */
  101687. maxVertexAttribs: number;
  101688. /** Maximum number of varyings */
  101689. maxVaryingVectors: number;
  101690. /** Maximum number of uniforms per vertex shader */
  101691. maxVertexUniformVectors: number;
  101692. /** Maximum number of uniforms per fragment shader */
  101693. maxFragmentUniformVectors: number;
  101694. /** Defines if standard derivates (dx/dy) are supported */
  101695. standardDerivatives: boolean;
  101696. /** Defines if s3tc texture compression is supported */
  101697. s3tc?: WEBGL_compressed_texture_s3tc;
  101698. /** Defines if pvrtc texture compression is supported */
  101699. pvrtc: any;
  101700. /** Defines if etc1 texture compression is supported */
  101701. etc1: any;
  101702. /** Defines if etc2 texture compression is supported */
  101703. etc2: any;
  101704. /** Defines if astc texture compression is supported */
  101705. astc: any;
  101706. /** Defines if float textures are supported */
  101707. textureFloat: boolean;
  101708. /** Defines if vertex array objects are supported */
  101709. vertexArrayObject: boolean;
  101710. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  101711. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  101712. /** Gets the maximum level of anisotropy supported */
  101713. maxAnisotropy: number;
  101714. /** Defines if instancing is supported */
  101715. instancedArrays: boolean;
  101716. /** Defines if 32 bits indices are supported */
  101717. uintIndices: boolean;
  101718. /** Defines if high precision shaders are supported */
  101719. highPrecisionShaderSupported: boolean;
  101720. /** Defines if depth reading in the fragment shader is supported */
  101721. fragmentDepthSupported: boolean;
  101722. /** Defines if float texture linear filtering is supported*/
  101723. textureFloatLinearFiltering: boolean;
  101724. /** Defines if rendering to float textures is supported */
  101725. textureFloatRender: boolean;
  101726. /** Defines if half float textures are supported*/
  101727. textureHalfFloat: boolean;
  101728. /** Defines if half float texture linear filtering is supported*/
  101729. textureHalfFloatLinearFiltering: boolean;
  101730. /** Defines if rendering to half float textures is supported */
  101731. textureHalfFloatRender: boolean;
  101732. /** Defines if textureLOD shader command is supported */
  101733. textureLOD: boolean;
  101734. /** Defines if draw buffers extension is supported */
  101735. drawBuffersExtension: boolean;
  101736. /** Defines if depth textures are supported */
  101737. depthTextureExtension: boolean;
  101738. /** Defines if float color buffer are supported */
  101739. colorBufferFloat: boolean;
  101740. /** Gets disjoint timer query extension (null if not supported) */
  101741. timerQuery?: EXT_disjoint_timer_query;
  101742. /** Defines if timestamp can be used with timer query */
  101743. canUseTimestampForTimerQuery: boolean;
  101744. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  101745. multiview?: any;
  101746. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  101747. oculusMultiview?: any;
  101748. /** Function used to let the system compiles shaders in background */
  101749. parallelShaderCompile?: {
  101750. COMPLETION_STATUS_KHR: number;
  101751. };
  101752. /** Max number of texture samples for MSAA */
  101753. maxMSAASamples: number;
  101754. /** Defines if the blend min max extension is supported */
  101755. blendMinMax: boolean;
  101756. }
  101757. }
  101758. declare module BABYLON {
  101759. /**
  101760. * @hidden
  101761. **/
  101762. export class DepthCullingState {
  101763. private _isDepthTestDirty;
  101764. private _isDepthMaskDirty;
  101765. private _isDepthFuncDirty;
  101766. private _isCullFaceDirty;
  101767. private _isCullDirty;
  101768. private _isZOffsetDirty;
  101769. private _isFrontFaceDirty;
  101770. private _depthTest;
  101771. private _depthMask;
  101772. private _depthFunc;
  101773. private _cull;
  101774. private _cullFace;
  101775. private _zOffset;
  101776. private _frontFace;
  101777. /**
  101778. * Initializes the state.
  101779. */
  101780. constructor();
  101781. get isDirty(): boolean;
  101782. get zOffset(): number;
  101783. set zOffset(value: number);
  101784. get cullFace(): Nullable<number>;
  101785. set cullFace(value: Nullable<number>);
  101786. get cull(): Nullable<boolean>;
  101787. set cull(value: Nullable<boolean>);
  101788. get depthFunc(): Nullable<number>;
  101789. set depthFunc(value: Nullable<number>);
  101790. get depthMask(): boolean;
  101791. set depthMask(value: boolean);
  101792. get depthTest(): boolean;
  101793. set depthTest(value: boolean);
  101794. get frontFace(): Nullable<number>;
  101795. set frontFace(value: Nullable<number>);
  101796. reset(): void;
  101797. apply(gl: WebGLRenderingContext): void;
  101798. }
  101799. }
  101800. declare module BABYLON {
  101801. /**
  101802. * @hidden
  101803. **/
  101804. export class StencilState {
  101805. /** 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 */
  101806. static readonly ALWAYS: number;
  101807. /** Passed to stencilOperation to specify that stencil value must be kept */
  101808. static readonly KEEP: number;
  101809. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101810. static readonly REPLACE: number;
  101811. private _isStencilTestDirty;
  101812. private _isStencilMaskDirty;
  101813. private _isStencilFuncDirty;
  101814. private _isStencilOpDirty;
  101815. private _stencilTest;
  101816. private _stencilMask;
  101817. private _stencilFunc;
  101818. private _stencilFuncRef;
  101819. private _stencilFuncMask;
  101820. private _stencilOpStencilFail;
  101821. private _stencilOpDepthFail;
  101822. private _stencilOpStencilDepthPass;
  101823. get isDirty(): boolean;
  101824. get stencilFunc(): number;
  101825. set stencilFunc(value: number);
  101826. get stencilFuncRef(): number;
  101827. set stencilFuncRef(value: number);
  101828. get stencilFuncMask(): number;
  101829. set stencilFuncMask(value: number);
  101830. get stencilOpStencilFail(): number;
  101831. set stencilOpStencilFail(value: number);
  101832. get stencilOpDepthFail(): number;
  101833. set stencilOpDepthFail(value: number);
  101834. get stencilOpStencilDepthPass(): number;
  101835. set stencilOpStencilDepthPass(value: number);
  101836. get stencilMask(): number;
  101837. set stencilMask(value: number);
  101838. get stencilTest(): boolean;
  101839. set stencilTest(value: boolean);
  101840. constructor();
  101841. reset(): void;
  101842. apply(gl: WebGLRenderingContext): void;
  101843. }
  101844. }
  101845. declare module BABYLON {
  101846. /**
  101847. * @hidden
  101848. **/
  101849. export class AlphaState {
  101850. private _isAlphaBlendDirty;
  101851. private _isBlendFunctionParametersDirty;
  101852. private _isBlendEquationParametersDirty;
  101853. private _isBlendConstantsDirty;
  101854. private _alphaBlend;
  101855. private _blendFunctionParameters;
  101856. private _blendEquationParameters;
  101857. private _blendConstants;
  101858. /**
  101859. * Initializes the state.
  101860. */
  101861. constructor();
  101862. get isDirty(): boolean;
  101863. get alphaBlend(): boolean;
  101864. set alphaBlend(value: boolean);
  101865. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  101866. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  101867. setAlphaEquationParameters(rgb: number, alpha: number): void;
  101868. reset(): void;
  101869. apply(gl: WebGLRenderingContext): void;
  101870. }
  101871. }
  101872. declare module BABYLON {
  101873. /** @hidden */
  101874. export class WebGL2ShaderProcessor implements IShaderProcessor {
  101875. attributeProcessor(attribute: string): string;
  101876. varyingProcessor(varying: string, isFragment: boolean): string;
  101877. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  101878. }
  101879. }
  101880. declare module BABYLON {
  101881. /**
  101882. * Interface for attribute information associated with buffer instanciation
  101883. */
  101884. export interface InstancingAttributeInfo {
  101885. /**
  101886. * Name of the GLSL attribute
  101887. * if attribute index is not specified, this is used to retrieve the index from the effect
  101888. */
  101889. attributeName: string;
  101890. /**
  101891. * Index/offset of the attribute in the vertex shader
  101892. * if not specified, this will be computes from the name.
  101893. */
  101894. index?: number;
  101895. /**
  101896. * size of the attribute, 1, 2, 3 or 4
  101897. */
  101898. attributeSize: number;
  101899. /**
  101900. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  101901. */
  101902. offset: number;
  101903. /**
  101904. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  101905. * default to 1
  101906. */
  101907. divisor?: number;
  101908. /**
  101909. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  101910. * default is FLOAT
  101911. */
  101912. attributeType?: number;
  101913. /**
  101914. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  101915. */
  101916. normalized?: boolean;
  101917. }
  101918. }
  101919. declare module BABYLON {
  101920. interface ThinEngine {
  101921. /**
  101922. * Update a video texture
  101923. * @param texture defines the texture to update
  101924. * @param video defines the video element to use
  101925. * @param invertY defines if data must be stored with Y axis inverted
  101926. */
  101927. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  101928. }
  101929. }
  101930. declare module BABYLON {
  101931. /**
  101932. * Settings for finer control over video usage
  101933. */
  101934. export interface VideoTextureSettings {
  101935. /**
  101936. * Applies `autoplay` to video, if specified
  101937. */
  101938. autoPlay?: boolean;
  101939. /**
  101940. * Applies `loop` to video, if specified
  101941. */
  101942. loop?: boolean;
  101943. /**
  101944. * Automatically updates internal texture from video at every frame in the render loop
  101945. */
  101946. autoUpdateTexture: boolean;
  101947. /**
  101948. * Image src displayed during the video loading or until the user interacts with the video.
  101949. */
  101950. poster?: string;
  101951. }
  101952. /**
  101953. * If you want to display a video in your scene, this is the special texture for that.
  101954. * This special texture works similar to other textures, with the exception of a few parameters.
  101955. * @see https://doc.babylonjs.com/how_to/video_texture
  101956. */
  101957. export class VideoTexture extends Texture {
  101958. /**
  101959. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  101960. */
  101961. readonly autoUpdateTexture: boolean;
  101962. /**
  101963. * The video instance used by the texture internally
  101964. */
  101965. readonly video: HTMLVideoElement;
  101966. private _onUserActionRequestedObservable;
  101967. /**
  101968. * Event triggerd when a dom action is required by the user to play the video.
  101969. * This happens due to recent changes in browser policies preventing video to auto start.
  101970. */
  101971. get onUserActionRequestedObservable(): Observable<Texture>;
  101972. private _generateMipMaps;
  101973. private _engine;
  101974. private _stillImageCaptured;
  101975. private _displayingPosterTexture;
  101976. private _settings;
  101977. private _createInternalTextureOnEvent;
  101978. private _frameId;
  101979. private _currentSrc;
  101980. /**
  101981. * Creates a video texture.
  101982. * If you want to display a video in your scene, this is the special texture for that.
  101983. * This special texture works similar to other textures, with the exception of a few parameters.
  101984. * @see https://doc.babylonjs.com/how_to/video_texture
  101985. * @param name optional name, will detect from video source, if not defined
  101986. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  101987. * @param scene is obviously the current scene.
  101988. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  101989. * @param invertY is false by default but can be used to invert video on Y axis
  101990. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  101991. * @param settings allows finer control over video usage
  101992. */
  101993. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  101994. private _getName;
  101995. private _getVideo;
  101996. private _createInternalTexture;
  101997. private reset;
  101998. /**
  101999. * @hidden Internal method to initiate `update`.
  102000. */
  102001. _rebuild(): void;
  102002. /**
  102003. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  102004. */
  102005. update(): void;
  102006. /**
  102007. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  102008. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  102009. */
  102010. updateTexture(isVisible: boolean): void;
  102011. protected _updateInternalTexture: () => void;
  102012. /**
  102013. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  102014. * @param url New url.
  102015. */
  102016. updateURL(url: string): void;
  102017. /**
  102018. * Clones the texture.
  102019. * @returns the cloned texture
  102020. */
  102021. clone(): VideoTexture;
  102022. /**
  102023. * Dispose the texture and release its associated resources.
  102024. */
  102025. dispose(): void;
  102026. /**
  102027. * Creates a video texture straight from a stream.
  102028. * @param scene Define the scene the texture should be created in
  102029. * @param stream Define the stream the texture should be created from
  102030. * @returns The created video texture as a promise
  102031. */
  102032. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  102033. /**
  102034. * Creates a video texture straight from your WebCam video feed.
  102035. * @param scene Define the scene the texture should be created in
  102036. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  102037. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  102038. * @returns The created video texture as a promise
  102039. */
  102040. static CreateFromWebCamAsync(scene: Scene, constraints: {
  102041. minWidth: number;
  102042. maxWidth: number;
  102043. minHeight: number;
  102044. maxHeight: number;
  102045. deviceId: string;
  102046. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  102047. /**
  102048. * Creates a video texture straight from your WebCam video feed.
  102049. * @param scene Define the scene the texture should be created in
  102050. * @param onReady Define a callback to triggered once the texture will be ready
  102051. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  102052. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  102053. */
  102054. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  102055. minWidth: number;
  102056. maxWidth: number;
  102057. minHeight: number;
  102058. maxHeight: number;
  102059. deviceId: string;
  102060. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  102061. }
  102062. }
  102063. declare module BABYLON {
  102064. /**
  102065. * Defines the interface used by objects working like Scene
  102066. * @hidden
  102067. */
  102068. interface ISceneLike {
  102069. _addPendingData(data: any): void;
  102070. _removePendingData(data: any): void;
  102071. offlineProvider: IOfflineProvider;
  102072. }
  102073. /** Interface defining initialization parameters for Engine class */
  102074. export interface EngineOptions extends WebGLContextAttributes {
  102075. /**
  102076. * Defines if the engine should no exceed a specified device ratio
  102077. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  102078. */
  102079. limitDeviceRatio?: number;
  102080. /**
  102081. * Defines if webvr should be enabled automatically
  102082. * @see http://doc.babylonjs.com/how_to/webvr_camera
  102083. */
  102084. autoEnableWebVR?: boolean;
  102085. /**
  102086. * Defines if webgl2 should be turned off even if supported
  102087. * @see http://doc.babylonjs.com/features/webgl2
  102088. */
  102089. disableWebGL2Support?: boolean;
  102090. /**
  102091. * Defines if webaudio should be initialized as well
  102092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102093. */
  102094. audioEngine?: boolean;
  102095. /**
  102096. * Defines if animations should run using a deterministic lock step
  102097. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102098. */
  102099. deterministicLockstep?: boolean;
  102100. /** Defines the maximum steps to use with deterministic lock step mode */
  102101. lockstepMaxSteps?: number;
  102102. /** Defines the seconds between each deterministic lock step */
  102103. timeStep?: number;
  102104. /**
  102105. * Defines that engine should ignore context lost events
  102106. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  102107. */
  102108. doNotHandleContextLost?: boolean;
  102109. /**
  102110. * Defines that engine should ignore modifying touch action attribute and style
  102111. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  102112. */
  102113. doNotHandleTouchAction?: boolean;
  102114. /**
  102115. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  102116. */
  102117. useHighPrecisionFloats?: boolean;
  102118. }
  102119. /**
  102120. * The base engine class (root of all engines)
  102121. */
  102122. export class ThinEngine {
  102123. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  102124. static ExceptionList: ({
  102125. key: string;
  102126. capture: string;
  102127. captureConstraint: number;
  102128. targets: string[];
  102129. } | {
  102130. key: string;
  102131. capture: null;
  102132. captureConstraint: null;
  102133. targets: string[];
  102134. })[];
  102135. /** @hidden */
  102136. static _TextureLoaders: IInternalTextureLoader[];
  102137. /**
  102138. * Returns the current npm package of the sdk
  102139. */
  102140. static get NpmPackage(): string;
  102141. /**
  102142. * Returns the current version of the framework
  102143. */
  102144. static get Version(): string;
  102145. /**
  102146. * Returns a string describing the current engine
  102147. */
  102148. get description(): string;
  102149. /**
  102150. * Gets or sets the epsilon value used by collision engine
  102151. */
  102152. static CollisionsEpsilon: number;
  102153. /**
  102154. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  102155. */
  102156. static get ShadersRepository(): string;
  102157. static set ShadersRepository(value: string);
  102158. /**
  102159. * Gets or sets the textures that the engine should not attempt to load as compressed
  102160. */
  102161. protected _excludedCompressedTextures: string[];
  102162. /**
  102163. * Filters the compressed texture formats to only include
  102164. * files that are not included in the skippable list
  102165. *
  102166. * @param url the current extension
  102167. * @param textureFormatInUse the current compressed texture format
  102168. * @returns "format" string
  102169. */
  102170. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  102171. /** @hidden */
  102172. _shaderProcessor: IShaderProcessor;
  102173. /**
  102174. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  102175. */
  102176. forcePOTTextures: boolean;
  102177. /**
  102178. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  102179. */
  102180. isFullscreen: boolean;
  102181. /**
  102182. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  102183. */
  102184. cullBackFaces: boolean;
  102185. /**
  102186. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  102187. */
  102188. renderEvenInBackground: boolean;
  102189. /**
  102190. * Gets or sets a boolean indicating that cache can be kept between frames
  102191. */
  102192. preventCacheWipeBetweenFrames: boolean;
  102193. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  102194. validateShaderPrograms: boolean;
  102195. /**
  102196. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  102197. * This can provide greater z depth for distant objects.
  102198. */
  102199. useReverseDepthBuffer: boolean;
  102200. /**
  102201. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  102202. */
  102203. disableUniformBuffers: boolean;
  102204. /** @hidden */
  102205. _uniformBuffers: UniformBuffer[];
  102206. /**
  102207. * Gets a boolean indicating that the engine supports uniform buffers
  102208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  102209. */
  102210. get supportsUniformBuffers(): boolean;
  102211. /** @hidden */
  102212. _gl: WebGLRenderingContext;
  102213. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  102214. protected _windowIsBackground: boolean;
  102215. protected _webGLVersion: number;
  102216. protected _creationOptions: EngineOptions;
  102217. protected _highPrecisionShadersAllowed: boolean;
  102218. /** @hidden */
  102219. get _shouldUseHighPrecisionShader(): boolean;
  102220. /**
  102221. * Gets a boolean indicating that only power of 2 textures are supported
  102222. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  102223. */
  102224. get needPOTTextures(): boolean;
  102225. /** @hidden */
  102226. _badOS: boolean;
  102227. /** @hidden */
  102228. _badDesktopOS: boolean;
  102229. private _hardwareScalingLevel;
  102230. /** @hidden */
  102231. _caps: EngineCapabilities;
  102232. private _isStencilEnable;
  102233. private _glVersion;
  102234. private _glRenderer;
  102235. private _glVendor;
  102236. /** @hidden */
  102237. _videoTextureSupported: boolean;
  102238. protected _renderingQueueLaunched: boolean;
  102239. protected _activeRenderLoops: (() => void)[];
  102240. /**
  102241. * Observable signaled when a context lost event is raised
  102242. */
  102243. onContextLostObservable: Observable<ThinEngine>;
  102244. /**
  102245. * Observable signaled when a context restored event is raised
  102246. */
  102247. onContextRestoredObservable: Observable<ThinEngine>;
  102248. private _onContextLost;
  102249. private _onContextRestored;
  102250. protected _contextWasLost: boolean;
  102251. /** @hidden */
  102252. _doNotHandleContextLost: boolean;
  102253. /**
  102254. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  102255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  102256. */
  102257. get doNotHandleContextLost(): boolean;
  102258. set doNotHandleContextLost(value: boolean);
  102259. /**
  102260. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  102261. */
  102262. disableVertexArrayObjects: boolean;
  102263. /** @hidden */
  102264. protected _colorWrite: boolean;
  102265. /** @hidden */
  102266. protected _colorWriteChanged: boolean;
  102267. /** @hidden */
  102268. protected _depthCullingState: DepthCullingState;
  102269. /** @hidden */
  102270. protected _stencilState: StencilState;
  102271. /** @hidden */
  102272. _alphaState: AlphaState;
  102273. /** @hidden */
  102274. _alphaMode: number;
  102275. /** @hidden */
  102276. _alphaEquation: number;
  102277. /** @hidden */
  102278. _internalTexturesCache: InternalTexture[];
  102279. /** @hidden */
  102280. protected _activeChannel: number;
  102281. private _currentTextureChannel;
  102282. /** @hidden */
  102283. protected _boundTexturesCache: {
  102284. [key: string]: Nullable<InternalTexture>;
  102285. };
  102286. /** @hidden */
  102287. protected _currentEffect: Nullable<Effect>;
  102288. /** @hidden */
  102289. protected _currentProgram: Nullable<WebGLProgram>;
  102290. private _compiledEffects;
  102291. private _vertexAttribArraysEnabled;
  102292. /** @hidden */
  102293. protected _cachedViewport: Nullable<IViewportLike>;
  102294. private _cachedVertexArrayObject;
  102295. /** @hidden */
  102296. protected _cachedVertexBuffers: any;
  102297. /** @hidden */
  102298. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  102299. /** @hidden */
  102300. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  102301. /** @hidden */
  102302. _currentRenderTarget: Nullable<InternalTexture>;
  102303. private _uintIndicesCurrentlySet;
  102304. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  102305. /** @hidden */
  102306. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  102307. private _currentBufferPointers;
  102308. private _currentInstanceLocations;
  102309. private _currentInstanceBuffers;
  102310. private _textureUnits;
  102311. /** @hidden */
  102312. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  102313. /** @hidden */
  102314. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  102315. /** @hidden */
  102316. _boundRenderFunction: any;
  102317. private _vaoRecordInProgress;
  102318. private _mustWipeVertexAttributes;
  102319. private _emptyTexture;
  102320. private _emptyCubeTexture;
  102321. private _emptyTexture3D;
  102322. private _emptyTexture2DArray;
  102323. /** @hidden */
  102324. _frameHandler: number;
  102325. private _nextFreeTextureSlots;
  102326. private _maxSimultaneousTextures;
  102327. private _activeRequests;
  102328. protected _texturesSupported: string[];
  102329. /** @hidden */
  102330. _textureFormatInUse: Nullable<string>;
  102331. protected get _supportsHardwareTextureRescaling(): boolean;
  102332. /**
  102333. * Gets the list of texture formats supported
  102334. */
  102335. get texturesSupported(): Array<string>;
  102336. /**
  102337. * Gets the list of texture formats in use
  102338. */
  102339. get textureFormatInUse(): Nullable<string>;
  102340. /**
  102341. * Gets the current viewport
  102342. */
  102343. get currentViewport(): Nullable<IViewportLike>;
  102344. /**
  102345. * Gets the default empty texture
  102346. */
  102347. get emptyTexture(): InternalTexture;
  102348. /**
  102349. * Gets the default empty 3D texture
  102350. */
  102351. get emptyTexture3D(): InternalTexture;
  102352. /**
  102353. * Gets the default empty 2D array texture
  102354. */
  102355. get emptyTexture2DArray(): InternalTexture;
  102356. /**
  102357. * Gets the default empty cube texture
  102358. */
  102359. get emptyCubeTexture(): InternalTexture;
  102360. /**
  102361. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  102362. */
  102363. readonly premultipliedAlpha: boolean;
  102364. /**
  102365. * Observable event triggered before each texture is initialized
  102366. */
  102367. onBeforeTextureInitObservable: Observable<Texture>;
  102368. /**
  102369. * Creates a new engine
  102370. * @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
  102371. * @param antialias defines enable antialiasing (default: false)
  102372. * @param options defines further options to be sent to the getContext() function
  102373. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  102374. */
  102375. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  102376. private _rebuildInternalTextures;
  102377. private _rebuildEffects;
  102378. /**
  102379. * Gets a boolean indicating if all created effects are ready
  102380. * @returns true if all effects are ready
  102381. */
  102382. areAllEffectsReady(): boolean;
  102383. protected _rebuildBuffers(): void;
  102384. private _initGLContext;
  102385. /**
  102386. * Gets version of the current webGL context
  102387. */
  102388. get webGLVersion(): number;
  102389. /**
  102390. * Gets a string idenfifying the name of the class
  102391. * @returns "Engine" string
  102392. */
  102393. getClassName(): string;
  102394. /**
  102395. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  102396. */
  102397. get isStencilEnable(): boolean;
  102398. /** @hidden */
  102399. _prepareWorkingCanvas(): void;
  102400. /**
  102401. * Reset the texture cache to empty state
  102402. */
  102403. resetTextureCache(): void;
  102404. /**
  102405. * Gets an object containing information about the current webGL context
  102406. * @returns an object containing the vender, the renderer and the version of the current webGL context
  102407. */
  102408. getGlInfo(): {
  102409. vendor: string;
  102410. renderer: string;
  102411. version: string;
  102412. };
  102413. /**
  102414. * Defines the hardware scaling level.
  102415. * By default the hardware scaling level is computed from the window device ratio.
  102416. * 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.
  102417. * @param level defines the level to use
  102418. */
  102419. setHardwareScalingLevel(level: number): void;
  102420. /**
  102421. * Gets the current hardware scaling level.
  102422. * By default the hardware scaling level is computed from the window device ratio.
  102423. * 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.
  102424. * @returns a number indicating the current hardware scaling level
  102425. */
  102426. getHardwareScalingLevel(): number;
  102427. /**
  102428. * Gets the list of loaded textures
  102429. * @returns an array containing all loaded textures
  102430. */
  102431. getLoadedTexturesCache(): InternalTexture[];
  102432. /**
  102433. * Gets the object containing all engine capabilities
  102434. * @returns the EngineCapabilities object
  102435. */
  102436. getCaps(): EngineCapabilities;
  102437. /**
  102438. * stop executing a render loop function and remove it from the execution array
  102439. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  102440. */
  102441. stopRenderLoop(renderFunction?: () => void): void;
  102442. /** @hidden */
  102443. _renderLoop(): void;
  102444. /**
  102445. * Gets the HTML canvas attached with the current webGL context
  102446. * @returns a HTML canvas
  102447. */
  102448. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  102449. /**
  102450. * Gets host window
  102451. * @returns the host window object
  102452. */
  102453. getHostWindow(): Nullable<Window>;
  102454. /**
  102455. * Gets the current render width
  102456. * @param useScreen defines if screen size must be used (or the current render target if any)
  102457. * @returns a number defining the current render width
  102458. */
  102459. getRenderWidth(useScreen?: boolean): number;
  102460. /**
  102461. * Gets the current render height
  102462. * @param useScreen defines if screen size must be used (or the current render target if any)
  102463. * @returns a number defining the current render height
  102464. */
  102465. getRenderHeight(useScreen?: boolean): number;
  102466. /**
  102467. * Can be used to override the current requestAnimationFrame requester.
  102468. * @hidden
  102469. */
  102470. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  102471. /**
  102472. * Register and execute a render loop. The engine can have more than one render function
  102473. * @param renderFunction defines the function to continuously execute
  102474. */
  102475. runRenderLoop(renderFunction: () => void): void;
  102476. /**
  102477. * Clear the current render buffer or the current render target (if any is set up)
  102478. * @param color defines the color to use
  102479. * @param backBuffer defines if the back buffer must be cleared
  102480. * @param depth defines if the depth buffer must be cleared
  102481. * @param stencil defines if the stencil buffer must be cleared
  102482. */
  102483. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  102484. private _viewportCached;
  102485. /** @hidden */
  102486. _viewport(x: number, y: number, width: number, height: number): void;
  102487. /**
  102488. * Set the WebGL's viewport
  102489. * @param viewport defines the viewport element to be used
  102490. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  102491. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  102492. */
  102493. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  102494. /**
  102495. * Begin a new frame
  102496. */
  102497. beginFrame(): void;
  102498. /**
  102499. * Enf the current frame
  102500. */
  102501. endFrame(): void;
  102502. /**
  102503. * Resize the view according to the canvas' size
  102504. */
  102505. resize(): void;
  102506. /**
  102507. * Force a specific size of the canvas
  102508. * @param width defines the new canvas' width
  102509. * @param height defines the new canvas' height
  102510. */
  102511. setSize(width: number, height: number): void;
  102512. /**
  102513. * Binds the frame buffer to the specified texture.
  102514. * @param texture The texture to render to or null for the default canvas
  102515. * @param faceIndex The face of the texture to render to in case of cube texture
  102516. * @param requiredWidth The width of the target to render to
  102517. * @param requiredHeight The height of the target to render to
  102518. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  102519. * @param depthStencilTexture The depth stencil texture to use to render
  102520. * @param lodLevel defines le lod level to bind to the frame buffer
  102521. */
  102522. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  102523. /** @hidden */
  102524. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  102525. /**
  102526. * Unbind the current render target texture from the webGL context
  102527. * @param texture defines the render target texture to unbind
  102528. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102529. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102530. */
  102531. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  102532. /**
  102533. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  102534. */
  102535. flushFramebuffer(): void;
  102536. /**
  102537. * Unbind the current render target and bind the default framebuffer
  102538. */
  102539. restoreDefaultFramebuffer(): void;
  102540. /** @hidden */
  102541. protected _resetVertexBufferBinding(): void;
  102542. /**
  102543. * Creates a vertex buffer
  102544. * @param data the data for the vertex buffer
  102545. * @returns the new WebGL static buffer
  102546. */
  102547. createVertexBuffer(data: DataArray): DataBuffer;
  102548. private _createVertexBuffer;
  102549. /**
  102550. * Creates a dynamic vertex buffer
  102551. * @param data the data for the dynamic vertex buffer
  102552. * @returns the new WebGL dynamic buffer
  102553. */
  102554. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  102555. protected _resetIndexBufferBinding(): void;
  102556. /**
  102557. * Creates a new index buffer
  102558. * @param indices defines the content of the index buffer
  102559. * @param updatable defines if the index buffer must be updatable
  102560. * @returns a new webGL buffer
  102561. */
  102562. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  102563. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  102564. /**
  102565. * Bind a webGL buffer to the webGL context
  102566. * @param buffer defines the buffer to bind
  102567. */
  102568. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  102569. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  102570. private bindBuffer;
  102571. /**
  102572. * update the bound buffer with the given data
  102573. * @param data defines the data to update
  102574. */
  102575. updateArrayBuffer(data: Float32Array): void;
  102576. private _vertexAttribPointer;
  102577. private _bindIndexBufferWithCache;
  102578. private _bindVertexBuffersAttributes;
  102579. /**
  102580. * Records a vertex array object
  102581. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  102582. * @param vertexBuffers defines the list of vertex buffers to store
  102583. * @param indexBuffer defines the index buffer to store
  102584. * @param effect defines the effect to store
  102585. * @returns the new vertex array object
  102586. */
  102587. recordVertexArrayObject(vertexBuffers: {
  102588. [key: string]: VertexBuffer;
  102589. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  102590. /**
  102591. * Bind a specific vertex array object
  102592. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  102593. * @param vertexArrayObject defines the vertex array object to bind
  102594. * @param indexBuffer defines the index buffer to bind
  102595. */
  102596. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  102597. /**
  102598. * Bind webGl buffers directly to the webGL context
  102599. * @param vertexBuffer defines the vertex buffer to bind
  102600. * @param indexBuffer defines the index buffer to bind
  102601. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  102602. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  102603. * @param effect defines the effect associated with the vertex buffer
  102604. */
  102605. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  102606. private _unbindVertexArrayObject;
  102607. /**
  102608. * Bind a list of vertex buffers to the webGL context
  102609. * @param vertexBuffers defines the list of vertex buffers to bind
  102610. * @param indexBuffer defines the index buffer to bind
  102611. * @param effect defines the effect associated with the vertex buffers
  102612. */
  102613. bindBuffers(vertexBuffers: {
  102614. [key: string]: Nullable<VertexBuffer>;
  102615. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  102616. /**
  102617. * Unbind all instance attributes
  102618. */
  102619. unbindInstanceAttributes(): void;
  102620. /**
  102621. * Release and free the memory of a vertex array object
  102622. * @param vao defines the vertex array object to delete
  102623. */
  102624. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  102625. /** @hidden */
  102626. _releaseBuffer(buffer: DataBuffer): boolean;
  102627. protected _deleteBuffer(buffer: DataBuffer): void;
  102628. /**
  102629. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  102630. * @param instancesBuffer defines the webGL buffer to update and bind
  102631. * @param data defines the data to store in the buffer
  102632. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  102633. */
  102634. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  102635. /**
  102636. * Bind the content of a webGL buffer used with instanciation
  102637. * @param instancesBuffer defines the webGL buffer to bind
  102638. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  102639. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  102640. */
  102641. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  102642. /**
  102643. * Disable the instance attribute corresponding to the name in parameter
  102644. * @param name defines the name of the attribute to disable
  102645. */
  102646. disableInstanceAttributeByName(name: string): void;
  102647. /**
  102648. * Disable the instance attribute corresponding to the location in parameter
  102649. * @param attributeLocation defines the attribute location of the attribute to disable
  102650. */
  102651. disableInstanceAttribute(attributeLocation: number): void;
  102652. /**
  102653. * Disable the attribute corresponding to the location in parameter
  102654. * @param attributeLocation defines the attribute location of the attribute to disable
  102655. */
  102656. disableAttributeByIndex(attributeLocation: number): void;
  102657. /**
  102658. * Send a draw order
  102659. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  102660. * @param indexStart defines the starting index
  102661. * @param indexCount defines the number of index to draw
  102662. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102663. */
  102664. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  102665. /**
  102666. * Draw a list of points
  102667. * @param verticesStart defines the index of first vertex to draw
  102668. * @param verticesCount defines the count of vertices to draw
  102669. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102670. */
  102671. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  102672. /**
  102673. * Draw a list of unindexed primitives
  102674. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  102675. * @param verticesStart defines the index of first vertex to draw
  102676. * @param verticesCount defines the count of vertices to draw
  102677. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102678. */
  102679. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  102680. /**
  102681. * Draw a list of indexed primitives
  102682. * @param fillMode defines the primitive to use
  102683. * @param indexStart defines the starting index
  102684. * @param indexCount defines the number of index to draw
  102685. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102686. */
  102687. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  102688. /**
  102689. * Draw a list of unindexed primitives
  102690. * @param fillMode defines the primitive to use
  102691. * @param verticesStart defines the index of first vertex to draw
  102692. * @param verticesCount defines the count of vertices to draw
  102693. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102694. */
  102695. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  102696. private _drawMode;
  102697. /** @hidden */
  102698. protected _reportDrawCall(): void;
  102699. /** @hidden */
  102700. _releaseEffect(effect: Effect): void;
  102701. /** @hidden */
  102702. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  102703. /**
  102704. * Create a new effect (used to store vertex/fragment shaders)
  102705. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  102706. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  102707. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  102708. * @param samplers defines an array of string used to represent textures
  102709. * @param defines defines the string containing the defines to use to compile the shaders
  102710. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  102711. * @param onCompiled defines a function to call when the effect creation is successful
  102712. * @param onError defines a function to call when the effect creation has failed
  102713. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  102714. * @returns the new Effect
  102715. */
  102716. 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;
  102717. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  102718. private _compileShader;
  102719. private _compileRawShader;
  102720. /**
  102721. * Directly creates a webGL program
  102722. * @param pipelineContext defines the pipeline context to attach to
  102723. * @param vertexCode defines the vertex shader code to use
  102724. * @param fragmentCode defines the fragment shader code to use
  102725. * @param context defines the webGL context to use (if not set, the current one will be used)
  102726. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  102727. * @returns the new webGL program
  102728. */
  102729. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102730. /**
  102731. * Creates a webGL program
  102732. * @param pipelineContext defines the pipeline context to attach to
  102733. * @param vertexCode defines the vertex shader code to use
  102734. * @param fragmentCode defines the fragment shader code to use
  102735. * @param defines defines the string containing the defines to use to compile the shaders
  102736. * @param context defines the webGL context to use (if not set, the current one will be used)
  102737. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  102738. * @returns the new webGL program
  102739. */
  102740. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102741. /**
  102742. * Creates a new pipeline context
  102743. * @returns the new pipeline
  102744. */
  102745. createPipelineContext(): IPipelineContext;
  102746. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102747. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  102748. /** @hidden */
  102749. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  102750. /** @hidden */
  102751. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  102752. /** @hidden */
  102753. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  102754. /**
  102755. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  102756. * @param pipelineContext defines the pipeline context to use
  102757. * @param uniformsNames defines the list of uniform names
  102758. * @returns an array of webGL uniform locations
  102759. */
  102760. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  102761. /**
  102762. * Gets the lsit of active attributes for a given webGL program
  102763. * @param pipelineContext defines the pipeline context to use
  102764. * @param attributesNames defines the list of attribute names to get
  102765. * @returns an array of indices indicating the offset of each attribute
  102766. */
  102767. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  102768. /**
  102769. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  102770. * @param effect defines the effect to activate
  102771. */
  102772. enableEffect(effect: Nullable<Effect>): void;
  102773. /**
  102774. * Set the value of an uniform to a number (int)
  102775. * @param uniform defines the webGL uniform location where to store the value
  102776. * @param value defines the int number to store
  102777. */
  102778. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102779. /**
  102780. * Set the value of an uniform to an array of int32
  102781. * @param uniform defines the webGL uniform location where to store the value
  102782. * @param array defines the array of int32 to store
  102783. */
  102784. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102785. /**
  102786. * Set the value of an uniform to an array of int32 (stored as vec2)
  102787. * @param uniform defines the webGL uniform location where to store the value
  102788. * @param array defines the array of int32 to store
  102789. */
  102790. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102791. /**
  102792. * Set the value of an uniform to an array of int32 (stored as vec3)
  102793. * @param uniform defines the webGL uniform location where to store the value
  102794. * @param array defines the array of int32 to store
  102795. */
  102796. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102797. /**
  102798. * Set the value of an uniform to an array of int32 (stored as vec4)
  102799. * @param uniform defines the webGL uniform location where to store the value
  102800. * @param array defines the array of int32 to store
  102801. */
  102802. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102803. /**
  102804. * Set the value of an uniform to an array of number
  102805. * @param uniform defines the webGL uniform location where to store the value
  102806. * @param array defines the array of number to store
  102807. */
  102808. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102809. /**
  102810. * Set the value of an uniform to an array of number (stored as vec2)
  102811. * @param uniform defines the webGL uniform location where to store the value
  102812. * @param array defines the array of number to store
  102813. */
  102814. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102815. /**
  102816. * Set the value of an uniform to an array of number (stored as vec3)
  102817. * @param uniform defines the webGL uniform location where to store the value
  102818. * @param array defines the array of number to store
  102819. */
  102820. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102821. /**
  102822. * Set the value of an uniform to an array of number (stored as vec4)
  102823. * @param uniform defines the webGL uniform location where to store the value
  102824. * @param array defines the array of number to store
  102825. */
  102826. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102827. /**
  102828. * Set the value of an uniform to an array of float32 (stored as matrices)
  102829. * @param uniform defines the webGL uniform location where to store the value
  102830. * @param matrices defines the array of float32 to store
  102831. */
  102832. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  102833. /**
  102834. * Set the value of an uniform to a matrix (3x3)
  102835. * @param uniform defines the webGL uniform location where to store the value
  102836. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  102837. */
  102838. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102839. /**
  102840. * Set the value of an uniform to a matrix (2x2)
  102841. * @param uniform defines the webGL uniform location where to store the value
  102842. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  102843. */
  102844. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102845. /**
  102846. * Set the value of an uniform to a number (float)
  102847. * @param uniform defines the webGL uniform location where to store the value
  102848. * @param value defines the float number to store
  102849. */
  102850. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102851. /**
  102852. * Set the value of an uniform to a vec2
  102853. * @param uniform defines the webGL uniform location where to store the value
  102854. * @param x defines the 1st component of the value
  102855. * @param y defines the 2nd component of the value
  102856. */
  102857. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  102858. /**
  102859. * Set the value of an uniform to a vec3
  102860. * @param uniform defines the webGL uniform location where to store the value
  102861. * @param x defines the 1st component of the value
  102862. * @param y defines the 2nd component of the value
  102863. * @param z defines the 3rd component of the value
  102864. */
  102865. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  102866. /**
  102867. * Set the value of an uniform to a vec4
  102868. * @param uniform defines the webGL uniform location where to store the value
  102869. * @param x defines the 1st component of the value
  102870. * @param y defines the 2nd component of the value
  102871. * @param z defines the 3rd component of the value
  102872. * @param w defines the 4th component of the value
  102873. */
  102874. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  102875. /**
  102876. * Apply all cached states (depth, culling, stencil and alpha)
  102877. */
  102878. applyStates(): void;
  102879. /**
  102880. * Enable or disable color writing
  102881. * @param enable defines the state to set
  102882. */
  102883. setColorWrite(enable: boolean): void;
  102884. /**
  102885. * Gets a boolean indicating if color writing is enabled
  102886. * @returns the current color writing state
  102887. */
  102888. getColorWrite(): boolean;
  102889. /**
  102890. * Gets the depth culling state manager
  102891. */
  102892. get depthCullingState(): DepthCullingState;
  102893. /**
  102894. * Gets the alpha state manager
  102895. */
  102896. get alphaState(): AlphaState;
  102897. /**
  102898. * Gets the stencil state manager
  102899. */
  102900. get stencilState(): StencilState;
  102901. /**
  102902. * Clears the list of texture accessible through engine.
  102903. * This can help preventing texture load conflict due to name collision.
  102904. */
  102905. clearInternalTexturesCache(): void;
  102906. /**
  102907. * Force the entire cache to be cleared
  102908. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  102909. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  102910. */
  102911. wipeCaches(bruteForce?: boolean): void;
  102912. /** @hidden */
  102913. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  102914. min: number;
  102915. mag: number;
  102916. };
  102917. /** @hidden */
  102918. _createTexture(): WebGLTexture;
  102919. /**
  102920. * Usually called from Texture.ts.
  102921. * Passed information to create a WebGLTexture
  102922. * @param urlArg defines a value which contains one of the following:
  102923. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  102924. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  102925. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  102926. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  102927. * @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)
  102928. * @param scene needed for loading to the correct scene
  102929. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  102930. * @param onLoad optional callback to be called upon successful completion
  102931. * @param onError optional callback to be called upon failure
  102932. * @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
  102933. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  102934. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  102935. * @param forcedExtension defines the extension to use to pick the right loader
  102936. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  102937. * @param mimeType defines an optional mime type
  102938. * @returns a InternalTexture for assignment back into BABYLON.Texture
  102939. */
  102940. 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;
  102941. /**
  102942. * Loads an image as an HTMLImageElement.
  102943. * @param input url string, ArrayBuffer, or Blob to load
  102944. * @param onLoad callback called when the image successfully loads
  102945. * @param onError callback called when the image fails to load
  102946. * @param offlineProvider offline provider for caching
  102947. * @param mimeType optional mime type
  102948. * @returns the HTMLImageElement of the loaded image
  102949. * @hidden
  102950. */
  102951. 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>;
  102952. /**
  102953. * @hidden
  102954. */
  102955. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102956. /**
  102957. * Creates a raw texture
  102958. * @param data defines the data to store in the texture
  102959. * @param width defines the width of the texture
  102960. * @param height defines the height of the texture
  102961. * @param format defines the format of the data
  102962. * @param generateMipMaps defines if the engine should generate the mip levels
  102963. * @param invertY defines if data must be stored with Y axis inverted
  102964. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  102965. * @param compression defines the compression used (null by default)
  102966. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102967. * @returns the raw texture inside an InternalTexture
  102968. */
  102969. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  102970. /**
  102971. * Creates a new raw cube texture
  102972. * @param data defines the array of data to use to create each face
  102973. * @param size defines the size of the textures
  102974. * @param format defines the format of the data
  102975. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102976. * @param generateMipMaps defines if the engine should generate the mip levels
  102977. * @param invertY defines if data must be stored with Y axis inverted
  102978. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102979. * @param compression defines the compression used (null by default)
  102980. * @returns the cube texture as an InternalTexture
  102981. */
  102982. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  102983. /**
  102984. * Creates a new raw 3D texture
  102985. * @param data defines the data used to create the texture
  102986. * @param width defines the width of the texture
  102987. * @param height defines the height of the texture
  102988. * @param depth defines the depth of the texture
  102989. * @param format defines the format of the texture
  102990. * @param generateMipMaps defines if the engine must generate mip levels
  102991. * @param invertY defines if data must be stored with Y axis inverted
  102992. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102993. * @param compression defines the compressed used (can be null)
  102994. * @param textureType defines the compressed used (can be null)
  102995. * @returns a new raw 3D texture (stored in an InternalTexture)
  102996. */
  102997. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102998. /**
  102999. * Creates a new raw 2D array texture
  103000. * @param data defines the data used to create the texture
  103001. * @param width defines the width of the texture
  103002. * @param height defines the height of the texture
  103003. * @param depth defines the number of layers of the texture
  103004. * @param format defines the format of the texture
  103005. * @param generateMipMaps defines if the engine must generate mip levels
  103006. * @param invertY defines if data must be stored with Y axis inverted
  103007. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  103008. * @param compression defines the compressed used (can be null)
  103009. * @param textureType defines the compressed used (can be null)
  103010. * @returns a new raw 2D array texture (stored in an InternalTexture)
  103011. */
  103012. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  103013. private _unpackFlipYCached;
  103014. /**
  103015. * In case you are sharing the context with other applications, it might
  103016. * be interested to not cache the unpack flip y state to ensure a consistent
  103017. * value would be set.
  103018. */
  103019. enableUnpackFlipYCached: boolean;
  103020. /** @hidden */
  103021. _unpackFlipY(value: boolean): void;
  103022. /** @hidden */
  103023. _getUnpackAlignement(): number;
  103024. private _getTextureTarget;
  103025. /**
  103026. * Update the sampling mode of a given texture
  103027. * @param samplingMode defines the required sampling mode
  103028. * @param texture defines the texture to update
  103029. * @param generateMipMaps defines whether to generate mipmaps for the texture
  103030. */
  103031. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  103032. /**
  103033. * Update the sampling mode of a given texture
  103034. * @param texture defines the texture to update
  103035. * @param wrapU defines the texture wrap mode of the u coordinates
  103036. * @param wrapV defines the texture wrap mode of the v coordinates
  103037. * @param wrapR defines the texture wrap mode of the r coordinates
  103038. */
  103039. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  103040. /** @hidden */
  103041. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  103042. width: number;
  103043. height: number;
  103044. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  103045. /** @hidden */
  103046. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  103047. /** @hidden */
  103048. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  103049. /**
  103050. * Update a portion of an internal texture
  103051. * @param texture defines the texture to update
  103052. * @param imageData defines the data to store into the texture
  103053. * @param xOffset defines the x coordinates of the update rectangle
  103054. * @param yOffset defines the y coordinates of the update rectangle
  103055. * @param width defines the width of the update rectangle
  103056. * @param height defines the height of the update rectangle
  103057. * @param faceIndex defines the face index if texture is a cube (0 by default)
  103058. * @param lod defines the lod level to update (0 by default)
  103059. */
  103060. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  103061. /** @hidden */
  103062. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  103063. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  103064. private _prepareWebGLTexture;
  103065. /** @hidden */
  103066. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  103067. private _getDepthStencilBuffer;
  103068. /** @hidden */
  103069. _releaseFramebufferObjects(texture: InternalTexture): void;
  103070. /** @hidden */
  103071. _releaseTexture(texture: InternalTexture): void;
  103072. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  103073. protected _setProgram(program: WebGLProgram): void;
  103074. protected _boundUniforms: {
  103075. [key: number]: WebGLUniformLocation;
  103076. };
  103077. /**
  103078. * Binds an effect to the webGL context
  103079. * @param effect defines the effect to bind
  103080. */
  103081. bindSamplers(effect: Effect): void;
  103082. private _activateCurrentTexture;
  103083. /** @hidden */
  103084. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  103085. /** @hidden */
  103086. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  103087. /**
  103088. * Unbind all textures from the webGL context
  103089. */
  103090. unbindAllTextures(): void;
  103091. /**
  103092. * Sets a texture to the according uniform.
  103093. * @param channel The texture channel
  103094. * @param uniform The uniform to set
  103095. * @param texture The texture to apply
  103096. */
  103097. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  103098. private _bindSamplerUniformToChannel;
  103099. private _getTextureWrapMode;
  103100. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  103101. /**
  103102. * Sets an array of texture to the webGL context
  103103. * @param channel defines the channel where the texture array must be set
  103104. * @param uniform defines the associated uniform location
  103105. * @param textures defines the array of textures to bind
  103106. */
  103107. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  103108. /** @hidden */
  103109. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  103110. private _setTextureParameterFloat;
  103111. private _setTextureParameterInteger;
  103112. /**
  103113. * Unbind all vertex attributes from the webGL context
  103114. */
  103115. unbindAllAttributes(): void;
  103116. /**
  103117. * 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
  103118. */
  103119. releaseEffects(): void;
  103120. /**
  103121. * Dispose and release all associated resources
  103122. */
  103123. dispose(): void;
  103124. /**
  103125. * Attach a new callback raised when context lost event is fired
  103126. * @param callback defines the callback to call
  103127. */
  103128. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  103129. /**
  103130. * Attach a new callback raised when context restored event is fired
  103131. * @param callback defines the callback to call
  103132. */
  103133. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  103134. /**
  103135. * Get the current error code of the webGL context
  103136. * @returns the error code
  103137. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  103138. */
  103139. getError(): number;
  103140. private _canRenderToFloatFramebuffer;
  103141. private _canRenderToHalfFloatFramebuffer;
  103142. private _canRenderToFramebuffer;
  103143. /** @hidden */
  103144. _getWebGLTextureType(type: number): number;
  103145. /** @hidden */
  103146. _getInternalFormat(format: number): number;
  103147. /** @hidden */
  103148. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  103149. /** @hidden */
  103150. _getRGBAMultiSampleBufferFormat(type: number): number;
  103151. /** @hidden */
  103152. _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;
  103153. /**
  103154. * Loads a file from a url
  103155. * @param url url to load
  103156. * @param onSuccess callback called when the file successfully loads
  103157. * @param onProgress callback called while file is loading (if the server supports this mode)
  103158. * @param offlineProvider defines the offline provider for caching
  103159. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  103160. * @param onError callback called when the file fails to load
  103161. * @returns a file request object
  103162. * @hidden
  103163. */
  103164. 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;
  103165. /**
  103166. * Reads pixels from the current frame buffer. Please note that this function can be slow
  103167. * @param x defines the x coordinate of the rectangle where pixels must be read
  103168. * @param y defines the y coordinate of the rectangle where pixels must be read
  103169. * @param width defines the width of the rectangle where pixels must be read
  103170. * @param height defines the height of the rectangle where pixels must be read
  103171. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  103172. * @returns a Uint8Array containing RGBA colors
  103173. */
  103174. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  103175. private static _isSupported;
  103176. /**
  103177. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  103178. * @returns true if the engine can be created
  103179. * @ignorenaming
  103180. */
  103181. static isSupported(): boolean;
  103182. /**
  103183. * Find the next highest power of two.
  103184. * @param x Number to start search from.
  103185. * @return Next highest power of two.
  103186. */
  103187. static CeilingPOT(x: number): number;
  103188. /**
  103189. * Find the next lowest power of two.
  103190. * @param x Number to start search from.
  103191. * @return Next lowest power of two.
  103192. */
  103193. static FloorPOT(x: number): number;
  103194. /**
  103195. * Find the nearest power of two.
  103196. * @param x Number to start search from.
  103197. * @return Next nearest power of two.
  103198. */
  103199. static NearestPOT(x: number): number;
  103200. /**
  103201. * Get the closest exponent of two
  103202. * @param value defines the value to approximate
  103203. * @param max defines the maximum value to return
  103204. * @param mode defines how to define the closest value
  103205. * @returns closest exponent of two of the given value
  103206. */
  103207. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  103208. /**
  103209. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  103210. * @param func - the function to be called
  103211. * @param requester - the object that will request the next frame. Falls back to window.
  103212. * @returns frame number
  103213. */
  103214. static QueueNewFrame(func: () => void, requester?: any): number;
  103215. /**
  103216. * Gets host document
  103217. * @returns the host document object
  103218. */
  103219. getHostDocument(): Nullable<Document>;
  103220. }
  103221. }
  103222. declare module BABYLON {
  103223. /**
  103224. * Class representing spherical harmonics coefficients to the 3rd degree
  103225. */
  103226. export class SphericalHarmonics {
  103227. /**
  103228. * Defines whether or not the harmonics have been prescaled for rendering.
  103229. */
  103230. preScaled: boolean;
  103231. /**
  103232. * The l0,0 coefficients of the spherical harmonics
  103233. */
  103234. l00: Vector3;
  103235. /**
  103236. * The l1,-1 coefficients of the spherical harmonics
  103237. */
  103238. l1_1: Vector3;
  103239. /**
  103240. * The l1,0 coefficients of the spherical harmonics
  103241. */
  103242. l10: Vector3;
  103243. /**
  103244. * The l1,1 coefficients of the spherical harmonics
  103245. */
  103246. l11: Vector3;
  103247. /**
  103248. * The l2,-2 coefficients of the spherical harmonics
  103249. */
  103250. l2_2: Vector3;
  103251. /**
  103252. * The l2,-1 coefficients of the spherical harmonics
  103253. */
  103254. l2_1: Vector3;
  103255. /**
  103256. * The l2,0 coefficients of the spherical harmonics
  103257. */
  103258. l20: Vector3;
  103259. /**
  103260. * The l2,1 coefficients of the spherical harmonics
  103261. */
  103262. l21: Vector3;
  103263. /**
  103264. * The l2,2 coefficients of the spherical harmonics
  103265. */
  103266. l22: Vector3;
  103267. /**
  103268. * Adds a light to the spherical harmonics
  103269. * @param direction the direction of the light
  103270. * @param color the color of the light
  103271. * @param deltaSolidAngle the delta solid angle of the light
  103272. */
  103273. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  103274. /**
  103275. * Scales the spherical harmonics by the given amount
  103276. * @param scale the amount to scale
  103277. */
  103278. scaleInPlace(scale: number): void;
  103279. /**
  103280. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  103281. *
  103282. * ```
  103283. * E_lm = A_l * L_lm
  103284. * ```
  103285. *
  103286. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  103287. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  103288. * the scaling factors are given in equation 9.
  103289. */
  103290. convertIncidentRadianceToIrradiance(): void;
  103291. /**
  103292. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  103293. *
  103294. * ```
  103295. * L = (1/pi) * E * rho
  103296. * ```
  103297. *
  103298. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  103299. */
  103300. convertIrradianceToLambertianRadiance(): void;
  103301. /**
  103302. * Integrates the reconstruction coefficients directly in to the SH preventing further
  103303. * required operations at run time.
  103304. *
  103305. * This is simply done by scaling back the SH with Ylm constants parameter.
  103306. * The trigonometric part being applied by the shader at run time.
  103307. */
  103308. preScaleForRendering(): void;
  103309. /**
  103310. * Constructs a spherical harmonics from an array.
  103311. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  103312. * @returns the spherical harmonics
  103313. */
  103314. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  103315. /**
  103316. * Gets the spherical harmonics from polynomial
  103317. * @param polynomial the spherical polynomial
  103318. * @returns the spherical harmonics
  103319. */
  103320. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  103321. }
  103322. /**
  103323. * Class representing spherical polynomial coefficients to the 3rd degree
  103324. */
  103325. export class SphericalPolynomial {
  103326. private _harmonics;
  103327. /**
  103328. * The spherical harmonics used to create the polynomials.
  103329. */
  103330. get preScaledHarmonics(): SphericalHarmonics;
  103331. /**
  103332. * The x coefficients of the spherical polynomial
  103333. */
  103334. x: Vector3;
  103335. /**
  103336. * The y coefficients of the spherical polynomial
  103337. */
  103338. y: Vector3;
  103339. /**
  103340. * The z coefficients of the spherical polynomial
  103341. */
  103342. z: Vector3;
  103343. /**
  103344. * The xx coefficients of the spherical polynomial
  103345. */
  103346. xx: Vector3;
  103347. /**
  103348. * The yy coefficients of the spherical polynomial
  103349. */
  103350. yy: Vector3;
  103351. /**
  103352. * The zz coefficients of the spherical polynomial
  103353. */
  103354. zz: Vector3;
  103355. /**
  103356. * The xy coefficients of the spherical polynomial
  103357. */
  103358. xy: Vector3;
  103359. /**
  103360. * The yz coefficients of the spherical polynomial
  103361. */
  103362. yz: Vector3;
  103363. /**
  103364. * The zx coefficients of the spherical polynomial
  103365. */
  103366. zx: Vector3;
  103367. /**
  103368. * Adds an ambient color to the spherical polynomial
  103369. * @param color the color to add
  103370. */
  103371. addAmbient(color: Color3): void;
  103372. /**
  103373. * Scales the spherical polynomial by the given amount
  103374. * @param scale the amount to scale
  103375. */
  103376. scaleInPlace(scale: number): void;
  103377. /**
  103378. * Gets the spherical polynomial from harmonics
  103379. * @param harmonics the spherical harmonics
  103380. * @returns the spherical polynomial
  103381. */
  103382. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  103383. /**
  103384. * Constructs a spherical polynomial from an array.
  103385. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  103386. * @returns the spherical polynomial
  103387. */
  103388. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  103389. }
  103390. }
  103391. declare module BABYLON {
  103392. /**
  103393. * Defines the source of the internal texture
  103394. */
  103395. export enum InternalTextureSource {
  103396. /**
  103397. * The source of the texture data is unknown
  103398. */
  103399. Unknown = 0,
  103400. /**
  103401. * Texture data comes from an URL
  103402. */
  103403. Url = 1,
  103404. /**
  103405. * Texture data is only used for temporary storage
  103406. */
  103407. Temp = 2,
  103408. /**
  103409. * Texture data comes from raw data (ArrayBuffer)
  103410. */
  103411. Raw = 3,
  103412. /**
  103413. * Texture content is dynamic (video or dynamic texture)
  103414. */
  103415. Dynamic = 4,
  103416. /**
  103417. * Texture content is generated by rendering to it
  103418. */
  103419. RenderTarget = 5,
  103420. /**
  103421. * Texture content is part of a multi render target process
  103422. */
  103423. MultiRenderTarget = 6,
  103424. /**
  103425. * Texture data comes from a cube data file
  103426. */
  103427. Cube = 7,
  103428. /**
  103429. * Texture data comes from a raw cube data
  103430. */
  103431. CubeRaw = 8,
  103432. /**
  103433. * Texture data come from a prefiltered cube data file
  103434. */
  103435. CubePrefiltered = 9,
  103436. /**
  103437. * Texture content is raw 3D data
  103438. */
  103439. Raw3D = 10,
  103440. /**
  103441. * Texture content is raw 2D array data
  103442. */
  103443. Raw2DArray = 11,
  103444. /**
  103445. * Texture content is a depth texture
  103446. */
  103447. Depth = 12,
  103448. /**
  103449. * Texture data comes from a raw cube data encoded with RGBD
  103450. */
  103451. CubeRawRGBD = 13
  103452. }
  103453. /**
  103454. * Class used to store data associated with WebGL texture data for the engine
  103455. * This class should not be used directly
  103456. */
  103457. export class InternalTexture {
  103458. /** @hidden */
  103459. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  103460. /**
  103461. * Defines if the texture is ready
  103462. */
  103463. isReady: boolean;
  103464. /**
  103465. * Defines if the texture is a cube texture
  103466. */
  103467. isCube: boolean;
  103468. /**
  103469. * Defines if the texture contains 3D data
  103470. */
  103471. is3D: boolean;
  103472. /**
  103473. * Defines if the texture contains 2D array data
  103474. */
  103475. is2DArray: boolean;
  103476. /**
  103477. * Defines if the texture contains multiview data
  103478. */
  103479. isMultiview: boolean;
  103480. /**
  103481. * Gets the URL used to load this texture
  103482. */
  103483. url: string;
  103484. /**
  103485. * Gets the sampling mode of the texture
  103486. */
  103487. samplingMode: number;
  103488. /**
  103489. * Gets a boolean indicating if the texture needs mipmaps generation
  103490. */
  103491. generateMipMaps: boolean;
  103492. /**
  103493. * Gets the number of samples used by the texture (WebGL2+ only)
  103494. */
  103495. samples: number;
  103496. /**
  103497. * Gets the type of the texture (int, float...)
  103498. */
  103499. type: number;
  103500. /**
  103501. * Gets the format of the texture (RGB, RGBA...)
  103502. */
  103503. format: number;
  103504. /**
  103505. * Observable called when the texture is loaded
  103506. */
  103507. onLoadedObservable: Observable<InternalTexture>;
  103508. /**
  103509. * Gets the width of the texture
  103510. */
  103511. width: number;
  103512. /**
  103513. * Gets the height of the texture
  103514. */
  103515. height: number;
  103516. /**
  103517. * Gets the depth of the texture
  103518. */
  103519. depth: number;
  103520. /**
  103521. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  103522. */
  103523. baseWidth: number;
  103524. /**
  103525. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  103526. */
  103527. baseHeight: number;
  103528. /**
  103529. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  103530. */
  103531. baseDepth: number;
  103532. /**
  103533. * Gets a boolean indicating if the texture is inverted on Y axis
  103534. */
  103535. invertY: boolean;
  103536. /** @hidden */
  103537. _invertVScale: boolean;
  103538. /** @hidden */
  103539. _associatedChannel: number;
  103540. /** @hidden */
  103541. _source: InternalTextureSource;
  103542. /** @hidden */
  103543. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103544. /** @hidden */
  103545. _bufferView: Nullable<ArrayBufferView>;
  103546. /** @hidden */
  103547. _bufferViewArray: Nullable<ArrayBufferView[]>;
  103548. /** @hidden */
  103549. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  103550. /** @hidden */
  103551. _size: number;
  103552. /** @hidden */
  103553. _extension: string;
  103554. /** @hidden */
  103555. _files: Nullable<string[]>;
  103556. /** @hidden */
  103557. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  103558. /** @hidden */
  103559. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  103560. /** @hidden */
  103561. _framebuffer: Nullable<WebGLFramebuffer>;
  103562. /** @hidden */
  103563. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  103564. /** @hidden */
  103565. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  103566. /** @hidden */
  103567. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  103568. /** @hidden */
  103569. _attachments: Nullable<number[]>;
  103570. /** @hidden */
  103571. _cachedCoordinatesMode: Nullable<number>;
  103572. /** @hidden */
  103573. _cachedWrapU: Nullable<number>;
  103574. /** @hidden */
  103575. _cachedWrapV: Nullable<number>;
  103576. /** @hidden */
  103577. _cachedWrapR: Nullable<number>;
  103578. /** @hidden */
  103579. _cachedAnisotropicFilteringLevel: Nullable<number>;
  103580. /** @hidden */
  103581. _isDisabled: boolean;
  103582. /** @hidden */
  103583. _compression: Nullable<string>;
  103584. /** @hidden */
  103585. _generateStencilBuffer: boolean;
  103586. /** @hidden */
  103587. _generateDepthBuffer: boolean;
  103588. /** @hidden */
  103589. _comparisonFunction: number;
  103590. /** @hidden */
  103591. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  103592. /** @hidden */
  103593. _lodGenerationScale: number;
  103594. /** @hidden */
  103595. _lodGenerationOffset: number;
  103596. /** @hidden */
  103597. _colorTextureArray: Nullable<WebGLTexture>;
  103598. /** @hidden */
  103599. _depthStencilTextureArray: Nullable<WebGLTexture>;
  103600. /** @hidden */
  103601. _lodTextureHigh: Nullable<BaseTexture>;
  103602. /** @hidden */
  103603. _lodTextureMid: Nullable<BaseTexture>;
  103604. /** @hidden */
  103605. _lodTextureLow: Nullable<BaseTexture>;
  103606. /** @hidden */
  103607. _isRGBD: boolean;
  103608. /** @hidden */
  103609. _linearSpecularLOD: boolean;
  103610. /** @hidden */
  103611. _irradianceTexture: Nullable<BaseTexture>;
  103612. /** @hidden */
  103613. _webGLTexture: Nullable<WebGLTexture>;
  103614. /** @hidden */
  103615. _references: number;
  103616. private _engine;
  103617. /**
  103618. * Gets the Engine the texture belongs to.
  103619. * @returns The babylon engine
  103620. */
  103621. getEngine(): ThinEngine;
  103622. /**
  103623. * Gets the data source type of the texture
  103624. */
  103625. get source(): InternalTextureSource;
  103626. /**
  103627. * Creates a new InternalTexture
  103628. * @param engine defines the engine to use
  103629. * @param source defines the type of data that will be used
  103630. * @param delayAllocation if the texture allocation should be delayed (default: false)
  103631. */
  103632. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  103633. /**
  103634. * Increments the number of references (ie. the number of Texture that point to it)
  103635. */
  103636. incrementReferences(): void;
  103637. /**
  103638. * Change the size of the texture (not the size of the content)
  103639. * @param width defines the new width
  103640. * @param height defines the new height
  103641. * @param depth defines the new depth (1 by default)
  103642. */
  103643. updateSize(width: int, height: int, depth?: int): void;
  103644. /** @hidden */
  103645. _rebuild(): void;
  103646. /** @hidden */
  103647. _swapAndDie(target: InternalTexture): void;
  103648. /**
  103649. * Dispose the current allocated resources
  103650. */
  103651. dispose(): void;
  103652. }
  103653. }
  103654. declare module BABYLON {
  103655. /**
  103656. * Class used to work with sound analyzer using fast fourier transform (FFT)
  103657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103658. */
  103659. export class Analyser {
  103660. /**
  103661. * Gets or sets the smoothing
  103662. * @ignorenaming
  103663. */
  103664. SMOOTHING: number;
  103665. /**
  103666. * Gets or sets the FFT table size
  103667. * @ignorenaming
  103668. */
  103669. FFT_SIZE: number;
  103670. /**
  103671. * Gets or sets the bar graph amplitude
  103672. * @ignorenaming
  103673. */
  103674. BARGRAPHAMPLITUDE: number;
  103675. /**
  103676. * Gets or sets the position of the debug canvas
  103677. * @ignorenaming
  103678. */
  103679. DEBUGCANVASPOS: {
  103680. x: number;
  103681. y: number;
  103682. };
  103683. /**
  103684. * Gets or sets the debug canvas size
  103685. * @ignorenaming
  103686. */
  103687. DEBUGCANVASSIZE: {
  103688. width: number;
  103689. height: number;
  103690. };
  103691. private _byteFreqs;
  103692. private _byteTime;
  103693. private _floatFreqs;
  103694. private _webAudioAnalyser;
  103695. private _debugCanvas;
  103696. private _debugCanvasContext;
  103697. private _scene;
  103698. private _registerFunc;
  103699. private _audioEngine;
  103700. /**
  103701. * Creates a new analyser
  103702. * @param scene defines hosting scene
  103703. */
  103704. constructor(scene: Scene);
  103705. /**
  103706. * Get the number of data values you will have to play with for the visualization
  103707. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  103708. * @returns a number
  103709. */
  103710. getFrequencyBinCount(): number;
  103711. /**
  103712. * Gets the current frequency data as a byte array
  103713. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  103714. * @returns a Uint8Array
  103715. */
  103716. getByteFrequencyData(): Uint8Array;
  103717. /**
  103718. * Gets the current waveform as a byte array
  103719. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  103720. * @returns a Uint8Array
  103721. */
  103722. getByteTimeDomainData(): Uint8Array;
  103723. /**
  103724. * Gets the current frequency data as a float array
  103725. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  103726. * @returns a Float32Array
  103727. */
  103728. getFloatFrequencyData(): Float32Array;
  103729. /**
  103730. * Renders the debug canvas
  103731. */
  103732. drawDebugCanvas(): void;
  103733. /**
  103734. * Stops rendering the debug canvas and removes it
  103735. */
  103736. stopDebugCanvas(): void;
  103737. /**
  103738. * Connects two audio nodes
  103739. * @param inputAudioNode defines first node to connect
  103740. * @param outputAudioNode defines second node to connect
  103741. */
  103742. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  103743. /**
  103744. * Releases all associated resources
  103745. */
  103746. dispose(): void;
  103747. }
  103748. }
  103749. declare module BABYLON {
  103750. /**
  103751. * This represents an audio engine and it is responsible
  103752. * to play, synchronize and analyse sounds throughout the application.
  103753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103754. */
  103755. export interface IAudioEngine extends IDisposable {
  103756. /**
  103757. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  103758. */
  103759. readonly canUseWebAudio: boolean;
  103760. /**
  103761. * Gets the current AudioContext if available.
  103762. */
  103763. readonly audioContext: Nullable<AudioContext>;
  103764. /**
  103765. * The master gain node defines the global audio volume of your audio engine.
  103766. */
  103767. readonly masterGain: GainNode;
  103768. /**
  103769. * Gets whether or not mp3 are supported by your browser.
  103770. */
  103771. readonly isMP3supported: boolean;
  103772. /**
  103773. * Gets whether or not ogg are supported by your browser.
  103774. */
  103775. readonly isOGGsupported: boolean;
  103776. /**
  103777. * Defines if Babylon should emit a warning if WebAudio is not supported.
  103778. * @ignoreNaming
  103779. */
  103780. WarnedWebAudioUnsupported: boolean;
  103781. /**
  103782. * Defines if the audio engine relies on a custom unlocked button.
  103783. * In this case, the embedded button will not be displayed.
  103784. */
  103785. useCustomUnlockedButton: boolean;
  103786. /**
  103787. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  103788. */
  103789. readonly unlocked: boolean;
  103790. /**
  103791. * Event raised when audio has been unlocked on the browser.
  103792. */
  103793. onAudioUnlockedObservable: Observable<AudioEngine>;
  103794. /**
  103795. * Event raised when audio has been locked on the browser.
  103796. */
  103797. onAudioLockedObservable: Observable<AudioEngine>;
  103798. /**
  103799. * Flags the audio engine in Locked state.
  103800. * This happens due to new browser policies preventing audio to autoplay.
  103801. */
  103802. lock(): void;
  103803. /**
  103804. * Unlocks the audio engine once a user action has been done on the dom.
  103805. * This is helpful to resume play once browser policies have been satisfied.
  103806. */
  103807. unlock(): void;
  103808. }
  103809. /**
  103810. * This represents the default audio engine used in babylon.
  103811. * It is responsible to play, synchronize and analyse sounds throughout the application.
  103812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103813. */
  103814. export class AudioEngine implements IAudioEngine {
  103815. private _audioContext;
  103816. private _audioContextInitialized;
  103817. private _muteButton;
  103818. private _hostElement;
  103819. /**
  103820. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  103821. */
  103822. canUseWebAudio: boolean;
  103823. /**
  103824. * The master gain node defines the global audio volume of your audio engine.
  103825. */
  103826. masterGain: GainNode;
  103827. /**
  103828. * Defines if Babylon should emit a warning if WebAudio is not supported.
  103829. * @ignoreNaming
  103830. */
  103831. WarnedWebAudioUnsupported: boolean;
  103832. /**
  103833. * Gets whether or not mp3 are supported by your browser.
  103834. */
  103835. isMP3supported: boolean;
  103836. /**
  103837. * Gets whether or not ogg are supported by your browser.
  103838. */
  103839. isOGGsupported: boolean;
  103840. /**
  103841. * Gets whether audio has been unlocked on the device.
  103842. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  103843. * a user interaction has happened.
  103844. */
  103845. unlocked: boolean;
  103846. /**
  103847. * Defines if the audio engine relies on a custom unlocked button.
  103848. * In this case, the embedded button will not be displayed.
  103849. */
  103850. useCustomUnlockedButton: boolean;
  103851. /**
  103852. * Event raised when audio has been unlocked on the browser.
  103853. */
  103854. onAudioUnlockedObservable: Observable<AudioEngine>;
  103855. /**
  103856. * Event raised when audio has been locked on the browser.
  103857. */
  103858. onAudioLockedObservable: Observable<AudioEngine>;
  103859. /**
  103860. * Gets the current AudioContext if available.
  103861. */
  103862. get audioContext(): Nullable<AudioContext>;
  103863. private _connectedAnalyser;
  103864. /**
  103865. * Instantiates a new audio engine.
  103866. *
  103867. * There should be only one per page as some browsers restrict the number
  103868. * of audio contexts you can create.
  103869. * @param hostElement defines the host element where to display the mute icon if necessary
  103870. */
  103871. constructor(hostElement?: Nullable<HTMLElement>);
  103872. /**
  103873. * Flags the audio engine in Locked state.
  103874. * This happens due to new browser policies preventing audio to autoplay.
  103875. */
  103876. lock(): void;
  103877. /**
  103878. * Unlocks the audio engine once a user action has been done on the dom.
  103879. * This is helpful to resume play once browser policies have been satisfied.
  103880. */
  103881. unlock(): void;
  103882. private _resumeAudioContext;
  103883. private _initializeAudioContext;
  103884. private _tryToRun;
  103885. private _triggerRunningState;
  103886. private _triggerSuspendedState;
  103887. private _displayMuteButton;
  103888. private _moveButtonToTopLeft;
  103889. private _onResize;
  103890. private _hideMuteButton;
  103891. /**
  103892. * Destroy and release the resources associated with the audio ccontext.
  103893. */
  103894. dispose(): void;
  103895. /**
  103896. * Gets the global volume sets on the master gain.
  103897. * @returns the global volume if set or -1 otherwise
  103898. */
  103899. getGlobalVolume(): number;
  103900. /**
  103901. * Sets the global volume of your experience (sets on the master gain).
  103902. * @param newVolume Defines the new global volume of the application
  103903. */
  103904. setGlobalVolume(newVolume: number): void;
  103905. /**
  103906. * Connect the audio engine to an audio analyser allowing some amazing
  103907. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103909. * @param analyser The analyser to connect to the engine
  103910. */
  103911. connectToAnalyser(analyser: Analyser): void;
  103912. }
  103913. }
  103914. declare module BABYLON {
  103915. /**
  103916. * Interface used to present a loading screen while loading a scene
  103917. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103918. */
  103919. export interface ILoadingScreen {
  103920. /**
  103921. * Function called to display the loading screen
  103922. */
  103923. displayLoadingUI: () => void;
  103924. /**
  103925. * Function called to hide the loading screen
  103926. */
  103927. hideLoadingUI: () => void;
  103928. /**
  103929. * Gets or sets the color to use for the background
  103930. */
  103931. loadingUIBackgroundColor: string;
  103932. /**
  103933. * Gets or sets the text to display while loading
  103934. */
  103935. loadingUIText: string;
  103936. }
  103937. /**
  103938. * Class used for the default loading screen
  103939. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103940. */
  103941. export class DefaultLoadingScreen implements ILoadingScreen {
  103942. private _renderingCanvas;
  103943. private _loadingText;
  103944. private _loadingDivBackgroundColor;
  103945. private _loadingDiv;
  103946. private _loadingTextDiv;
  103947. /** Gets or sets the logo url to use for the default loading screen */
  103948. static DefaultLogoUrl: string;
  103949. /** Gets or sets the spinner url to use for the default loading screen */
  103950. static DefaultSpinnerUrl: string;
  103951. /**
  103952. * Creates a new default loading screen
  103953. * @param _renderingCanvas defines the canvas used to render the scene
  103954. * @param _loadingText defines the default text to display
  103955. * @param _loadingDivBackgroundColor defines the default background color
  103956. */
  103957. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  103958. /**
  103959. * Function called to display the loading screen
  103960. */
  103961. displayLoadingUI(): void;
  103962. /**
  103963. * Function called to hide the loading screen
  103964. */
  103965. hideLoadingUI(): void;
  103966. /**
  103967. * Gets or sets the text to display while loading
  103968. */
  103969. set loadingUIText(text: string);
  103970. get loadingUIText(): string;
  103971. /**
  103972. * Gets or sets the color to use for the background
  103973. */
  103974. get loadingUIBackgroundColor(): string;
  103975. set loadingUIBackgroundColor(color: string);
  103976. private _resizeLoadingUI;
  103977. }
  103978. }
  103979. declare module BABYLON {
  103980. /**
  103981. * Interface for any object that can request an animation frame
  103982. */
  103983. export interface ICustomAnimationFrameRequester {
  103984. /**
  103985. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  103986. */
  103987. renderFunction?: Function;
  103988. /**
  103989. * Called to request the next frame to render to
  103990. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  103991. */
  103992. requestAnimationFrame: Function;
  103993. /**
  103994. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  103995. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  103996. */
  103997. requestID?: number;
  103998. }
  103999. }
  104000. declare module BABYLON {
  104001. /**
  104002. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  104003. */
  104004. export class PerformanceMonitor {
  104005. private _enabled;
  104006. private _rollingFrameTime;
  104007. private _lastFrameTimeMs;
  104008. /**
  104009. * constructor
  104010. * @param frameSampleSize The number of samples required to saturate the sliding window
  104011. */
  104012. constructor(frameSampleSize?: number);
  104013. /**
  104014. * Samples current frame
  104015. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  104016. */
  104017. sampleFrame(timeMs?: number): void;
  104018. /**
  104019. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  104020. */
  104021. get averageFrameTime(): number;
  104022. /**
  104023. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  104024. */
  104025. get averageFrameTimeVariance(): number;
  104026. /**
  104027. * Returns the frame time of the most recent frame
  104028. */
  104029. get instantaneousFrameTime(): number;
  104030. /**
  104031. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  104032. */
  104033. get averageFPS(): number;
  104034. /**
  104035. * Returns the average framerate in frames per second using the most recent frame time
  104036. */
  104037. get instantaneousFPS(): number;
  104038. /**
  104039. * Returns true if enough samples have been taken to completely fill the sliding window
  104040. */
  104041. get isSaturated(): boolean;
  104042. /**
  104043. * Enables contributions to the sliding window sample set
  104044. */
  104045. enable(): void;
  104046. /**
  104047. * Disables contributions to the sliding window sample set
  104048. * Samples will not be interpolated over the disabled period
  104049. */
  104050. disable(): void;
  104051. /**
  104052. * Returns true if sampling is enabled
  104053. */
  104054. get isEnabled(): boolean;
  104055. /**
  104056. * Resets performance monitor
  104057. */
  104058. reset(): void;
  104059. }
  104060. /**
  104061. * RollingAverage
  104062. *
  104063. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  104064. */
  104065. export class RollingAverage {
  104066. /**
  104067. * Current average
  104068. */
  104069. average: number;
  104070. /**
  104071. * Current variance
  104072. */
  104073. variance: number;
  104074. protected _samples: Array<number>;
  104075. protected _sampleCount: number;
  104076. protected _pos: number;
  104077. protected _m2: number;
  104078. /**
  104079. * constructor
  104080. * @param length The number of samples required to saturate the sliding window
  104081. */
  104082. constructor(length: number);
  104083. /**
  104084. * Adds a sample to the sample set
  104085. * @param v The sample value
  104086. */
  104087. add(v: number): void;
  104088. /**
  104089. * Returns previously added values or null if outside of history or outside the sliding window domain
  104090. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  104091. * @return Value previously recorded with add() or null if outside of range
  104092. */
  104093. history(i: number): number;
  104094. /**
  104095. * Returns true if enough samples have been taken to completely fill the sliding window
  104096. * @return true if sample-set saturated
  104097. */
  104098. isSaturated(): boolean;
  104099. /**
  104100. * Resets the rolling average (equivalent to 0 samples taken so far)
  104101. */
  104102. reset(): void;
  104103. /**
  104104. * Wraps a value around the sample range boundaries
  104105. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  104106. * @return Wrapped position in sample range
  104107. */
  104108. protected _wrapPosition(i: number): number;
  104109. }
  104110. }
  104111. declare module BABYLON {
  104112. /**
  104113. * This class is used to track a performance counter which is number based.
  104114. * The user has access to many properties which give statistics of different nature.
  104115. *
  104116. * The implementer can track two kinds of Performance Counter: time and count.
  104117. * 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.
  104118. * 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.
  104119. */
  104120. export class PerfCounter {
  104121. /**
  104122. * Gets or sets a global boolean to turn on and off all the counters
  104123. */
  104124. static Enabled: boolean;
  104125. /**
  104126. * Returns the smallest value ever
  104127. */
  104128. get min(): number;
  104129. /**
  104130. * Returns the biggest value ever
  104131. */
  104132. get max(): number;
  104133. /**
  104134. * Returns the average value since the performance counter is running
  104135. */
  104136. get average(): number;
  104137. /**
  104138. * Returns the average value of the last second the counter was monitored
  104139. */
  104140. get lastSecAverage(): number;
  104141. /**
  104142. * Returns the current value
  104143. */
  104144. get current(): number;
  104145. /**
  104146. * Gets the accumulated total
  104147. */
  104148. get total(): number;
  104149. /**
  104150. * Gets the total value count
  104151. */
  104152. get count(): number;
  104153. /**
  104154. * Creates a new counter
  104155. */
  104156. constructor();
  104157. /**
  104158. * Call this method to start monitoring a new frame.
  104159. * 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.
  104160. */
  104161. fetchNewFrame(): void;
  104162. /**
  104163. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  104164. * @param newCount the count value to add to the monitored count
  104165. * @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.
  104166. */
  104167. addCount(newCount: number, fetchResult: boolean): void;
  104168. /**
  104169. * Start monitoring this performance counter
  104170. */
  104171. beginMonitoring(): void;
  104172. /**
  104173. * Compute the time lapsed since the previous beginMonitoring() call.
  104174. * @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
  104175. */
  104176. endMonitoring(newFrame?: boolean): void;
  104177. private _fetchResult;
  104178. private _startMonitoringTime;
  104179. private _min;
  104180. private _max;
  104181. private _average;
  104182. private _current;
  104183. private _totalValueCount;
  104184. private _totalAccumulated;
  104185. private _lastSecAverage;
  104186. private _lastSecAccumulated;
  104187. private _lastSecTime;
  104188. private _lastSecValueCount;
  104189. }
  104190. }
  104191. declare module BABYLON {
  104192. interface ThinEngine {
  104193. /**
  104194. * Sets alpha constants used by some alpha blending modes
  104195. * @param r defines the red component
  104196. * @param g defines the green component
  104197. * @param b defines the blue component
  104198. * @param a defines the alpha component
  104199. */
  104200. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  104201. /**
  104202. * Sets the current alpha mode
  104203. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  104204. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  104205. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  104206. */
  104207. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104208. /**
  104209. * Gets the current alpha mode
  104210. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  104211. * @returns the current alpha mode
  104212. */
  104213. getAlphaMode(): number;
  104214. /**
  104215. * Sets the current alpha equation
  104216. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  104217. */
  104218. setAlphaEquation(equation: number): void;
  104219. /**
  104220. * Gets the current alpha equation.
  104221. * @returns the current alpha equation
  104222. */
  104223. getAlphaEquation(): number;
  104224. }
  104225. }
  104226. declare module BABYLON {
  104227. /**
  104228. * Defines the interface used by display changed events
  104229. */
  104230. export interface IDisplayChangedEventArgs {
  104231. /** Gets the vrDisplay object (if any) */
  104232. vrDisplay: Nullable<any>;
  104233. /** Gets a boolean indicating if webVR is supported */
  104234. vrSupported: boolean;
  104235. }
  104236. /**
  104237. * Defines the interface used by objects containing a viewport (like a camera)
  104238. */
  104239. interface IViewportOwnerLike {
  104240. /**
  104241. * Gets or sets the viewport
  104242. */
  104243. viewport: IViewportLike;
  104244. }
  104245. /**
  104246. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  104247. */
  104248. export class Engine extends ThinEngine {
  104249. /** Defines that alpha blending is disabled */
  104250. static readonly ALPHA_DISABLE: number;
  104251. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  104252. static readonly ALPHA_ADD: number;
  104253. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  104254. static readonly ALPHA_COMBINE: number;
  104255. /** Defines that alpha blending to DEST - SRC * DEST */
  104256. static readonly ALPHA_SUBTRACT: number;
  104257. /** Defines that alpha blending to SRC * DEST */
  104258. static readonly ALPHA_MULTIPLY: number;
  104259. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  104260. static readonly ALPHA_MAXIMIZED: number;
  104261. /** Defines that alpha blending to SRC + DEST */
  104262. static readonly ALPHA_ONEONE: number;
  104263. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  104264. static readonly ALPHA_PREMULTIPLIED: number;
  104265. /**
  104266. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  104267. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  104268. */
  104269. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  104270. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  104271. static readonly ALPHA_INTERPOLATE: number;
  104272. /**
  104273. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  104274. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  104275. */
  104276. static readonly ALPHA_SCREENMODE: number;
  104277. /** Defines that the ressource is not delayed*/
  104278. static readonly DELAYLOADSTATE_NONE: number;
  104279. /** Defines that the ressource was successfully delay loaded */
  104280. static readonly DELAYLOADSTATE_LOADED: number;
  104281. /** Defines that the ressource is currently delay loading */
  104282. static readonly DELAYLOADSTATE_LOADING: number;
  104283. /** Defines that the ressource is delayed and has not started loading */
  104284. static readonly DELAYLOADSTATE_NOTLOADED: number;
  104285. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  104286. static readonly NEVER: number;
  104287. /** 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 */
  104288. static readonly ALWAYS: number;
  104289. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  104290. static readonly LESS: number;
  104291. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  104292. static readonly EQUAL: number;
  104293. /** 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 */
  104294. static readonly LEQUAL: number;
  104295. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  104296. static readonly GREATER: number;
  104297. /** 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 */
  104298. static readonly GEQUAL: number;
  104299. /** 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 */
  104300. static readonly NOTEQUAL: number;
  104301. /** Passed to stencilOperation to specify that stencil value must be kept */
  104302. static readonly KEEP: number;
  104303. /** Passed to stencilOperation to specify that stencil value must be replaced */
  104304. static readonly REPLACE: number;
  104305. /** Passed to stencilOperation to specify that stencil value must be incremented */
  104306. static readonly INCR: number;
  104307. /** Passed to stencilOperation to specify that stencil value must be decremented */
  104308. static readonly DECR: number;
  104309. /** Passed to stencilOperation to specify that stencil value must be inverted */
  104310. static readonly INVERT: number;
  104311. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  104312. static readonly INCR_WRAP: number;
  104313. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  104314. static readonly DECR_WRAP: number;
  104315. /** Texture is not repeating outside of 0..1 UVs */
  104316. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  104317. /** Texture is repeating outside of 0..1 UVs */
  104318. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  104319. /** Texture is repeating and mirrored */
  104320. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  104321. /** ALPHA */
  104322. static readonly TEXTUREFORMAT_ALPHA: number;
  104323. /** LUMINANCE */
  104324. static readonly TEXTUREFORMAT_LUMINANCE: number;
  104325. /** LUMINANCE_ALPHA */
  104326. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  104327. /** RGB */
  104328. static readonly TEXTUREFORMAT_RGB: number;
  104329. /** RGBA */
  104330. static readonly TEXTUREFORMAT_RGBA: number;
  104331. /** RED */
  104332. static readonly TEXTUREFORMAT_RED: number;
  104333. /** RED (2nd reference) */
  104334. static readonly TEXTUREFORMAT_R: number;
  104335. /** RG */
  104336. static readonly TEXTUREFORMAT_RG: number;
  104337. /** RED_INTEGER */
  104338. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  104339. /** RED_INTEGER (2nd reference) */
  104340. static readonly TEXTUREFORMAT_R_INTEGER: number;
  104341. /** RG_INTEGER */
  104342. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  104343. /** RGB_INTEGER */
  104344. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  104345. /** RGBA_INTEGER */
  104346. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  104347. /** UNSIGNED_BYTE */
  104348. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  104349. /** UNSIGNED_BYTE (2nd reference) */
  104350. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  104351. /** FLOAT */
  104352. static readonly TEXTURETYPE_FLOAT: number;
  104353. /** HALF_FLOAT */
  104354. static readonly TEXTURETYPE_HALF_FLOAT: number;
  104355. /** BYTE */
  104356. static readonly TEXTURETYPE_BYTE: number;
  104357. /** SHORT */
  104358. static readonly TEXTURETYPE_SHORT: number;
  104359. /** UNSIGNED_SHORT */
  104360. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  104361. /** INT */
  104362. static readonly TEXTURETYPE_INT: number;
  104363. /** UNSIGNED_INT */
  104364. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  104365. /** UNSIGNED_SHORT_4_4_4_4 */
  104366. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  104367. /** UNSIGNED_SHORT_5_5_5_1 */
  104368. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  104369. /** UNSIGNED_SHORT_5_6_5 */
  104370. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  104371. /** UNSIGNED_INT_2_10_10_10_REV */
  104372. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  104373. /** UNSIGNED_INT_24_8 */
  104374. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  104375. /** UNSIGNED_INT_10F_11F_11F_REV */
  104376. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  104377. /** UNSIGNED_INT_5_9_9_9_REV */
  104378. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  104379. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  104380. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  104381. /** nearest is mag = nearest and min = nearest and mip = linear */
  104382. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  104383. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104384. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  104385. /** Trilinear is mag = linear and min = linear and mip = linear */
  104386. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  104387. /** nearest is mag = nearest and min = nearest and mip = linear */
  104388. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  104389. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104390. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  104391. /** Trilinear is mag = linear and min = linear and mip = linear */
  104392. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  104393. /** mag = nearest and min = nearest and mip = nearest */
  104394. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  104395. /** mag = nearest and min = linear and mip = nearest */
  104396. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  104397. /** mag = nearest and min = linear and mip = linear */
  104398. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  104399. /** mag = nearest and min = linear and mip = none */
  104400. static readonly TEXTURE_NEAREST_LINEAR: number;
  104401. /** mag = nearest and min = nearest and mip = none */
  104402. static readonly TEXTURE_NEAREST_NEAREST: number;
  104403. /** mag = linear and min = nearest and mip = nearest */
  104404. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  104405. /** mag = linear and min = nearest and mip = linear */
  104406. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  104407. /** mag = linear and min = linear and mip = none */
  104408. static readonly TEXTURE_LINEAR_LINEAR: number;
  104409. /** mag = linear and min = nearest and mip = none */
  104410. static readonly TEXTURE_LINEAR_NEAREST: number;
  104411. /** Explicit coordinates mode */
  104412. static readonly TEXTURE_EXPLICIT_MODE: number;
  104413. /** Spherical coordinates mode */
  104414. static readonly TEXTURE_SPHERICAL_MODE: number;
  104415. /** Planar coordinates mode */
  104416. static readonly TEXTURE_PLANAR_MODE: number;
  104417. /** Cubic coordinates mode */
  104418. static readonly TEXTURE_CUBIC_MODE: number;
  104419. /** Projection coordinates mode */
  104420. static readonly TEXTURE_PROJECTION_MODE: number;
  104421. /** Skybox coordinates mode */
  104422. static readonly TEXTURE_SKYBOX_MODE: number;
  104423. /** Inverse Cubic coordinates mode */
  104424. static readonly TEXTURE_INVCUBIC_MODE: number;
  104425. /** Equirectangular coordinates mode */
  104426. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  104427. /** Equirectangular Fixed coordinates mode */
  104428. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  104429. /** Equirectangular Fixed Mirrored coordinates mode */
  104430. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  104431. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  104432. static readonly SCALEMODE_FLOOR: number;
  104433. /** Defines that texture rescaling will look for the nearest power of 2 size */
  104434. static readonly SCALEMODE_NEAREST: number;
  104435. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  104436. static readonly SCALEMODE_CEILING: number;
  104437. /**
  104438. * Returns the current npm package of the sdk
  104439. */
  104440. static get NpmPackage(): string;
  104441. /**
  104442. * Returns the current version of the framework
  104443. */
  104444. static get Version(): string;
  104445. /** Gets the list of created engines */
  104446. static get Instances(): Engine[];
  104447. /**
  104448. * Gets the latest created engine
  104449. */
  104450. static get LastCreatedEngine(): Nullable<Engine>;
  104451. /**
  104452. * Gets the latest created scene
  104453. */
  104454. static get LastCreatedScene(): Nullable<Scene>;
  104455. /**
  104456. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  104457. * @param flag defines which part of the materials must be marked as dirty
  104458. * @param predicate defines a predicate used to filter which materials should be affected
  104459. */
  104460. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  104461. /**
  104462. * Method called to create the default loading screen.
  104463. * This can be overriden in your own app.
  104464. * @param canvas The rendering canvas element
  104465. * @returns The loading screen
  104466. */
  104467. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  104468. /**
  104469. * Method called to create the default rescale post process on each engine.
  104470. */
  104471. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  104472. /**
  104473. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  104474. **/
  104475. enableOfflineSupport: boolean;
  104476. /**
  104477. * 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)
  104478. **/
  104479. disableManifestCheck: boolean;
  104480. /**
  104481. * Gets the list of created scenes
  104482. */
  104483. scenes: Scene[];
  104484. /**
  104485. * Event raised when a new scene is created
  104486. */
  104487. onNewSceneAddedObservable: Observable<Scene>;
  104488. /**
  104489. * Gets the list of created postprocesses
  104490. */
  104491. postProcesses: PostProcess[];
  104492. /**
  104493. * Gets a boolean indicating if the pointer is currently locked
  104494. */
  104495. isPointerLock: boolean;
  104496. /**
  104497. * Observable event triggered each time the rendering canvas is resized
  104498. */
  104499. onResizeObservable: Observable<Engine>;
  104500. /**
  104501. * Observable event triggered each time the canvas loses focus
  104502. */
  104503. onCanvasBlurObservable: Observable<Engine>;
  104504. /**
  104505. * Observable event triggered each time the canvas gains focus
  104506. */
  104507. onCanvasFocusObservable: Observable<Engine>;
  104508. /**
  104509. * Observable event triggered each time the canvas receives pointerout event
  104510. */
  104511. onCanvasPointerOutObservable: Observable<PointerEvent>;
  104512. /**
  104513. * Observable raised when the engine begins a new frame
  104514. */
  104515. onBeginFrameObservable: Observable<Engine>;
  104516. /**
  104517. * If set, will be used to request the next animation frame for the render loop
  104518. */
  104519. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  104520. /**
  104521. * Observable raised when the engine ends the current frame
  104522. */
  104523. onEndFrameObservable: Observable<Engine>;
  104524. /**
  104525. * Observable raised when the engine is about to compile a shader
  104526. */
  104527. onBeforeShaderCompilationObservable: Observable<Engine>;
  104528. /**
  104529. * Observable raised when the engine has jsut compiled a shader
  104530. */
  104531. onAfterShaderCompilationObservable: Observable<Engine>;
  104532. /**
  104533. * Gets the audio engine
  104534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104535. * @ignorenaming
  104536. */
  104537. static audioEngine: IAudioEngine;
  104538. /**
  104539. * Default AudioEngine factory responsible of creating the Audio Engine.
  104540. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  104541. */
  104542. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  104543. /**
  104544. * Default offline support factory responsible of creating a tool used to store data locally.
  104545. * By default, this will create a Database object if the workload has been embedded.
  104546. */
  104547. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  104548. private _loadingScreen;
  104549. private _pointerLockRequested;
  104550. private _dummyFramebuffer;
  104551. private _rescalePostProcess;
  104552. private _deterministicLockstep;
  104553. private _lockstepMaxSteps;
  104554. private _timeStep;
  104555. protected get _supportsHardwareTextureRescaling(): boolean;
  104556. private _fps;
  104557. private _deltaTime;
  104558. /** @hidden */
  104559. _drawCalls: PerfCounter;
  104560. /**
  104561. * Turn this value on if you want to pause FPS computation when in background
  104562. */
  104563. disablePerformanceMonitorInBackground: boolean;
  104564. private _performanceMonitor;
  104565. /**
  104566. * Gets the performance monitor attached to this engine
  104567. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  104568. */
  104569. get performanceMonitor(): PerformanceMonitor;
  104570. private _onFocus;
  104571. private _onBlur;
  104572. private _onCanvasPointerOut;
  104573. private _onCanvasBlur;
  104574. private _onCanvasFocus;
  104575. private _onFullscreenChange;
  104576. private _onPointerLockChange;
  104577. /**
  104578. * Gets the HTML element used to attach event listeners
  104579. * @returns a HTML element
  104580. */
  104581. getInputElement(): Nullable<HTMLElement>;
  104582. /**
  104583. * Creates a new engine
  104584. * @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
  104585. * @param antialias defines enable antialiasing (default: false)
  104586. * @param options defines further options to be sent to the getContext() function
  104587. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104588. */
  104589. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104590. /**
  104591. * Gets current aspect ratio
  104592. * @param viewportOwner defines the camera to use to get the aspect ratio
  104593. * @param useScreen defines if screen size must be used (or the current render target if any)
  104594. * @returns a number defining the aspect ratio
  104595. */
  104596. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  104597. /**
  104598. * Gets current screen aspect ratio
  104599. * @returns a number defining the aspect ratio
  104600. */
  104601. getScreenAspectRatio(): number;
  104602. /**
  104603. * Gets the client rect of the HTML canvas attached with the current webGL context
  104604. * @returns a client rectanglee
  104605. */
  104606. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  104607. /**
  104608. * Gets the client rect of the HTML element used for events
  104609. * @returns a client rectanglee
  104610. */
  104611. getInputElementClientRect(): Nullable<ClientRect>;
  104612. /**
  104613. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  104614. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104615. * @returns true if engine is in deterministic lock step mode
  104616. */
  104617. isDeterministicLockStep(): boolean;
  104618. /**
  104619. * Gets the max steps when engine is running in deterministic lock step
  104620. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104621. * @returns the max steps
  104622. */
  104623. getLockstepMaxSteps(): number;
  104624. /**
  104625. * Returns the time in ms between steps when using deterministic lock step.
  104626. * @returns time step in (ms)
  104627. */
  104628. getTimeStep(): number;
  104629. /**
  104630. * Force the mipmap generation for the given render target texture
  104631. * @param texture defines the render target texture to use
  104632. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  104633. */
  104634. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  104635. /** States */
  104636. /**
  104637. * Set various states to the webGL context
  104638. * @param culling defines backface culling state
  104639. * @param zOffset defines the value to apply to zOffset (0 by default)
  104640. * @param force defines if states must be applied even if cache is up to date
  104641. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  104642. */
  104643. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104644. /**
  104645. * Set the z offset to apply to current rendering
  104646. * @param value defines the offset to apply
  104647. */
  104648. setZOffset(value: number): void;
  104649. /**
  104650. * Gets the current value of the zOffset
  104651. * @returns the current zOffset state
  104652. */
  104653. getZOffset(): number;
  104654. /**
  104655. * Enable or disable depth buffering
  104656. * @param enable defines the state to set
  104657. */
  104658. setDepthBuffer(enable: boolean): void;
  104659. /**
  104660. * Gets a boolean indicating if depth writing is enabled
  104661. * @returns the current depth writing state
  104662. */
  104663. getDepthWrite(): boolean;
  104664. /**
  104665. * Enable or disable depth writing
  104666. * @param enable defines the state to set
  104667. */
  104668. setDepthWrite(enable: boolean): void;
  104669. /**
  104670. * Gets a boolean indicating if stencil buffer is enabled
  104671. * @returns the current stencil buffer state
  104672. */
  104673. getStencilBuffer(): boolean;
  104674. /**
  104675. * Enable or disable the stencil buffer
  104676. * @param enable defines if the stencil buffer must be enabled or disabled
  104677. */
  104678. setStencilBuffer(enable: boolean): void;
  104679. /**
  104680. * Gets the current stencil mask
  104681. * @returns a number defining the new stencil mask to use
  104682. */
  104683. getStencilMask(): number;
  104684. /**
  104685. * Sets the current stencil mask
  104686. * @param mask defines the new stencil mask to use
  104687. */
  104688. setStencilMask(mask: number): void;
  104689. /**
  104690. * Gets the current stencil function
  104691. * @returns a number defining the stencil function to use
  104692. */
  104693. getStencilFunction(): number;
  104694. /**
  104695. * Gets the current stencil reference value
  104696. * @returns a number defining the stencil reference value to use
  104697. */
  104698. getStencilFunctionReference(): number;
  104699. /**
  104700. * Gets the current stencil mask
  104701. * @returns a number defining the stencil mask to use
  104702. */
  104703. getStencilFunctionMask(): number;
  104704. /**
  104705. * Sets the current stencil function
  104706. * @param stencilFunc defines the new stencil function to use
  104707. */
  104708. setStencilFunction(stencilFunc: number): void;
  104709. /**
  104710. * Sets the current stencil reference
  104711. * @param reference defines the new stencil reference to use
  104712. */
  104713. setStencilFunctionReference(reference: number): void;
  104714. /**
  104715. * Sets the current stencil mask
  104716. * @param mask defines the new stencil mask to use
  104717. */
  104718. setStencilFunctionMask(mask: number): void;
  104719. /**
  104720. * Gets the current stencil operation when stencil fails
  104721. * @returns a number defining stencil operation to use when stencil fails
  104722. */
  104723. getStencilOperationFail(): number;
  104724. /**
  104725. * Gets the current stencil operation when depth fails
  104726. * @returns a number defining stencil operation to use when depth fails
  104727. */
  104728. getStencilOperationDepthFail(): number;
  104729. /**
  104730. * Gets the current stencil operation when stencil passes
  104731. * @returns a number defining stencil operation to use when stencil passes
  104732. */
  104733. getStencilOperationPass(): number;
  104734. /**
  104735. * Sets the stencil operation to use when stencil fails
  104736. * @param operation defines the stencil operation to use when stencil fails
  104737. */
  104738. setStencilOperationFail(operation: number): void;
  104739. /**
  104740. * Sets the stencil operation to use when depth fails
  104741. * @param operation defines the stencil operation to use when depth fails
  104742. */
  104743. setStencilOperationDepthFail(operation: number): void;
  104744. /**
  104745. * Sets the stencil operation to use when stencil passes
  104746. * @param operation defines the stencil operation to use when stencil passes
  104747. */
  104748. setStencilOperationPass(operation: number): void;
  104749. /**
  104750. * Sets a boolean indicating if the dithering state is enabled or disabled
  104751. * @param value defines the dithering state
  104752. */
  104753. setDitheringState(value: boolean): void;
  104754. /**
  104755. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  104756. * @param value defines the rasterizer state
  104757. */
  104758. setRasterizerState(value: boolean): void;
  104759. /**
  104760. * Gets the current depth function
  104761. * @returns a number defining the depth function
  104762. */
  104763. getDepthFunction(): Nullable<number>;
  104764. /**
  104765. * Sets the current depth function
  104766. * @param depthFunc defines the function to use
  104767. */
  104768. setDepthFunction(depthFunc: number): void;
  104769. /**
  104770. * Sets the current depth function to GREATER
  104771. */
  104772. setDepthFunctionToGreater(): void;
  104773. /**
  104774. * Sets the current depth function to GEQUAL
  104775. */
  104776. setDepthFunctionToGreaterOrEqual(): void;
  104777. /**
  104778. * Sets the current depth function to LESS
  104779. */
  104780. setDepthFunctionToLess(): void;
  104781. /**
  104782. * Sets the current depth function to LEQUAL
  104783. */
  104784. setDepthFunctionToLessOrEqual(): void;
  104785. private _cachedStencilBuffer;
  104786. private _cachedStencilFunction;
  104787. private _cachedStencilMask;
  104788. private _cachedStencilOperationPass;
  104789. private _cachedStencilOperationFail;
  104790. private _cachedStencilOperationDepthFail;
  104791. private _cachedStencilReference;
  104792. /**
  104793. * Caches the the state of the stencil buffer
  104794. */
  104795. cacheStencilState(): void;
  104796. /**
  104797. * Restores the state of the stencil buffer
  104798. */
  104799. restoreStencilState(): void;
  104800. /**
  104801. * Directly set the WebGL Viewport
  104802. * @param x defines the x coordinate of the viewport (in screen space)
  104803. * @param y defines the y coordinate of the viewport (in screen space)
  104804. * @param width defines the width of the viewport (in screen space)
  104805. * @param height defines the height of the viewport (in screen space)
  104806. * @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
  104807. */
  104808. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  104809. /**
  104810. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  104811. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104812. * @param y defines the y-coordinate of the corner of the clear rectangle
  104813. * @param width defines the width of the clear rectangle
  104814. * @param height defines the height of the clear rectangle
  104815. * @param clearColor defines the clear color
  104816. */
  104817. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  104818. /**
  104819. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  104820. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104821. * @param y defines the y-coordinate of the corner of the clear rectangle
  104822. * @param width defines the width of the clear rectangle
  104823. * @param height defines the height of the clear rectangle
  104824. */
  104825. enableScissor(x: number, y: number, width: number, height: number): void;
  104826. /**
  104827. * Disable previously set scissor test rectangle
  104828. */
  104829. disableScissor(): void;
  104830. protected _reportDrawCall(): void;
  104831. /**
  104832. * Initializes a webVR display and starts listening to display change events
  104833. * The onVRDisplayChangedObservable will be notified upon these changes
  104834. * @returns The onVRDisplayChangedObservable
  104835. */
  104836. initWebVR(): Observable<IDisplayChangedEventArgs>;
  104837. /** @hidden */
  104838. _prepareVRComponent(): void;
  104839. /** @hidden */
  104840. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  104841. /** @hidden */
  104842. _submitVRFrame(): void;
  104843. /**
  104844. * Call this function to leave webVR mode
  104845. * Will do nothing if webVR is not supported or if there is no webVR device
  104846. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104847. */
  104848. disableVR(): void;
  104849. /**
  104850. * Gets a boolean indicating that the system is in VR mode and is presenting
  104851. * @returns true if VR mode is engaged
  104852. */
  104853. isVRPresenting(): boolean;
  104854. /** @hidden */
  104855. _requestVRFrame(): void;
  104856. /** @hidden */
  104857. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  104858. /**
  104859. * Gets the source code of the vertex shader associated with a specific webGL program
  104860. * @param program defines the program to use
  104861. * @returns a string containing the source code of the vertex shader associated with the program
  104862. */
  104863. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  104864. /**
  104865. * Gets the source code of the fragment shader associated with a specific webGL program
  104866. * @param program defines the program to use
  104867. * @returns a string containing the source code of the fragment shader associated with the program
  104868. */
  104869. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  104870. /**
  104871. * Sets a depth stencil texture from a render target to the according uniform.
  104872. * @param channel The texture channel
  104873. * @param uniform The uniform to set
  104874. * @param texture The render target texture containing the depth stencil texture to apply
  104875. */
  104876. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  104877. /**
  104878. * Sets a texture to the webGL context from a postprocess
  104879. * @param channel defines the channel to use
  104880. * @param postProcess defines the source postprocess
  104881. */
  104882. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  104883. /**
  104884. * Binds the output of the passed in post process to the texture channel specified
  104885. * @param channel The channel the texture should be bound to
  104886. * @param postProcess The post process which's output should be bound
  104887. */
  104888. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  104889. /** @hidden */
  104890. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  104891. protected _rebuildBuffers(): void;
  104892. /** @hidden */
  104893. _renderFrame(): void;
  104894. _renderLoop(): void;
  104895. /** @hidden */
  104896. _renderViews(): boolean;
  104897. /**
  104898. * Toggle full screen mode
  104899. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104900. */
  104901. switchFullscreen(requestPointerLock: boolean): void;
  104902. /**
  104903. * Enters full screen mode
  104904. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104905. */
  104906. enterFullscreen(requestPointerLock: boolean): void;
  104907. /**
  104908. * Exits full screen mode
  104909. */
  104910. exitFullscreen(): void;
  104911. /**
  104912. * Enters Pointerlock mode
  104913. */
  104914. enterPointerlock(): void;
  104915. /**
  104916. * Exits Pointerlock mode
  104917. */
  104918. exitPointerlock(): void;
  104919. /**
  104920. * Begin a new frame
  104921. */
  104922. beginFrame(): void;
  104923. /**
  104924. * Enf the current frame
  104925. */
  104926. endFrame(): void;
  104927. resize(): void;
  104928. /**
  104929. * Set the compressed texture format to use, based on the formats you have, and the formats
  104930. * supported by the hardware / browser.
  104931. *
  104932. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  104933. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  104934. * to API arguments needed to compressed textures. This puts the burden on the container
  104935. * generator to house the arcane code for determining these for current & future formats.
  104936. *
  104937. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104938. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104939. *
  104940. * Note: The result of this call is not taken into account when a texture is base64.
  104941. *
  104942. * @param formatsAvailable defines the list of those format families you have created
  104943. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  104944. *
  104945. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  104946. * @returns The extension selected.
  104947. */
  104948. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  104949. /**
  104950. * Set the compressed texture extensions or file names to skip.
  104951. *
  104952. * @param skippedFiles defines the list of those texture files you want to skip
  104953. * Example: [".dds", ".env", "myfile.png"]
  104954. */
  104955. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  104956. /**
  104957. * Force a specific size of the canvas
  104958. * @param width defines the new canvas' width
  104959. * @param height defines the new canvas' height
  104960. */
  104961. setSize(width: number, height: number): void;
  104962. /**
  104963. * Updates a dynamic vertex buffer.
  104964. * @param vertexBuffer the vertex buffer to update
  104965. * @param data the data used to update the vertex buffer
  104966. * @param byteOffset the byte offset of the data
  104967. * @param byteLength the byte length of the data
  104968. */
  104969. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  104970. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104971. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104972. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104973. _releaseTexture(texture: InternalTexture): void;
  104974. /**
  104975. * @hidden
  104976. * Rescales a texture
  104977. * @param source input texutre
  104978. * @param destination destination texture
  104979. * @param scene scene to use to render the resize
  104980. * @param internalFormat format to use when resizing
  104981. * @param onComplete callback to be called when resize has completed
  104982. */
  104983. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104984. /**
  104985. * Gets the current framerate
  104986. * @returns a number representing the framerate
  104987. */
  104988. getFps(): number;
  104989. /**
  104990. * Gets the time spent between current and previous frame
  104991. * @returns a number representing the delta time in ms
  104992. */
  104993. getDeltaTime(): number;
  104994. private _measureFps;
  104995. /** @hidden */
  104996. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  104997. /**
  104998. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  104999. * @param renderTarget The render target to set the frame buffer for
  105000. */
  105001. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  105002. /**
  105003. * Update a dynamic index buffer
  105004. * @param indexBuffer defines the target index buffer
  105005. * @param indices defines the data to update
  105006. * @param offset defines the offset in the target index buffer where update should start
  105007. */
  105008. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  105009. /**
  105010. * Updates the sample count of a render target texture
  105011. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  105012. * @param texture defines the texture to update
  105013. * @param samples defines the sample count to set
  105014. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  105015. */
  105016. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  105017. /**
  105018. * Updates a depth texture Comparison Mode and Function.
  105019. * If the comparison Function is equal to 0, the mode will be set to none.
  105020. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  105021. * @param texture The texture to set the comparison function for
  105022. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  105023. */
  105024. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  105025. /**
  105026. * Creates a webGL buffer to use with instanciation
  105027. * @param capacity defines the size of the buffer
  105028. * @returns the webGL buffer
  105029. */
  105030. createInstancesBuffer(capacity: number): DataBuffer;
  105031. /**
  105032. * Delete a webGL buffer used with instanciation
  105033. * @param buffer defines the webGL buffer to delete
  105034. */
  105035. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  105036. /** @hidden */
  105037. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  105038. dispose(): void;
  105039. private _disableTouchAction;
  105040. /**
  105041. * Display the loading screen
  105042. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105043. */
  105044. displayLoadingUI(): void;
  105045. /**
  105046. * Hide the loading screen
  105047. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105048. */
  105049. hideLoadingUI(): void;
  105050. /**
  105051. * Gets the current loading screen object
  105052. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105053. */
  105054. get loadingScreen(): ILoadingScreen;
  105055. /**
  105056. * Sets the current loading screen object
  105057. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105058. */
  105059. set loadingScreen(loadingScreen: ILoadingScreen);
  105060. /**
  105061. * Sets the current loading screen text
  105062. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105063. */
  105064. set loadingUIText(text: string);
  105065. /**
  105066. * Sets the current loading screen background color
  105067. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105068. */
  105069. set loadingUIBackgroundColor(color: string);
  105070. /** Pointerlock and fullscreen */
  105071. /**
  105072. * Ask the browser to promote the current element to pointerlock mode
  105073. * @param element defines the DOM element to promote
  105074. */
  105075. static _RequestPointerlock(element: HTMLElement): void;
  105076. /**
  105077. * Asks the browser to exit pointerlock mode
  105078. */
  105079. static _ExitPointerlock(): void;
  105080. /**
  105081. * Ask the browser to promote the current element to fullscreen rendering mode
  105082. * @param element defines the DOM element to promote
  105083. */
  105084. static _RequestFullscreen(element: HTMLElement): void;
  105085. /**
  105086. * Asks the browser to exit fullscreen mode
  105087. */
  105088. static _ExitFullscreen(): void;
  105089. }
  105090. }
  105091. declare module BABYLON {
  105092. /**
  105093. * The engine store class is responsible to hold all the instances of Engine and Scene created
  105094. * during the life time of the application.
  105095. */
  105096. export class EngineStore {
  105097. /** Gets the list of created engines */
  105098. static Instances: Engine[];
  105099. /** @hidden */
  105100. static _LastCreatedScene: Nullable<Scene>;
  105101. /**
  105102. * Gets the latest created engine
  105103. */
  105104. static get LastCreatedEngine(): Nullable<Engine>;
  105105. /**
  105106. * Gets the latest created scene
  105107. */
  105108. static get LastCreatedScene(): Nullable<Scene>;
  105109. /**
  105110. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  105111. * @ignorenaming
  105112. */
  105113. static UseFallbackTexture: boolean;
  105114. /**
  105115. * Texture content used if a texture cannot loaded
  105116. * @ignorenaming
  105117. */
  105118. static FallbackTexture: string;
  105119. }
  105120. }
  105121. declare module BABYLON {
  105122. /**
  105123. * Helper class that provides a small promise polyfill
  105124. */
  105125. export class PromisePolyfill {
  105126. /**
  105127. * Static function used to check if the polyfill is required
  105128. * If this is the case then the function will inject the polyfill to window.Promise
  105129. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  105130. */
  105131. static Apply(force?: boolean): void;
  105132. }
  105133. }
  105134. declare module BABYLON {
  105135. /**
  105136. * Interface for screenshot methods with describe argument called `size` as object with options
  105137. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  105138. */
  105139. export interface IScreenshotSize {
  105140. /**
  105141. * number in pixels for canvas height
  105142. */
  105143. height?: number;
  105144. /**
  105145. * multiplier allowing render at a higher or lower resolution
  105146. * If value is defined then height and width will be ignored and taken from camera
  105147. */
  105148. precision?: number;
  105149. /**
  105150. * number in pixels for canvas width
  105151. */
  105152. width?: number;
  105153. }
  105154. }
  105155. declare module BABYLON {
  105156. interface IColor4Like {
  105157. r: float;
  105158. g: float;
  105159. b: float;
  105160. a: float;
  105161. }
  105162. /**
  105163. * Class containing a set of static utilities functions
  105164. */
  105165. export class Tools {
  105166. /**
  105167. * Gets or sets the base URL to use to load assets
  105168. */
  105169. static get BaseUrl(): string;
  105170. static set BaseUrl(value: string);
  105171. /**
  105172. * Enable/Disable Custom HTTP Request Headers globally.
  105173. * default = false
  105174. * @see CustomRequestHeaders
  105175. */
  105176. static UseCustomRequestHeaders: boolean;
  105177. /**
  105178. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  105179. * i.e. when loading files, where the server/service expects an Authorization header
  105180. */
  105181. static CustomRequestHeaders: {
  105182. [key: string]: string;
  105183. };
  105184. /**
  105185. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  105186. */
  105187. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  105188. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  105189. /**
  105190. * Default behaviour for cors in the application.
  105191. * It can be a string if the expected behavior is identical in the entire app.
  105192. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  105193. */
  105194. static CorsBehavior: string | ((url: string | string[]) => string);
  105195. /**
  105196. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  105197. * @ignorenaming
  105198. */
  105199. static get UseFallbackTexture(): boolean;
  105200. static set UseFallbackTexture(value: boolean);
  105201. /**
  105202. * Use this object to register external classes like custom textures or material
  105203. * to allow the laoders to instantiate them
  105204. */
  105205. static get RegisteredExternalClasses(): {
  105206. [key: string]: Object;
  105207. };
  105208. static set RegisteredExternalClasses(classes: {
  105209. [key: string]: Object;
  105210. });
  105211. /**
  105212. * Texture content used if a texture cannot loaded
  105213. * @ignorenaming
  105214. */
  105215. static get fallbackTexture(): string;
  105216. static set fallbackTexture(value: string);
  105217. /**
  105218. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  105219. * @param u defines the coordinate on X axis
  105220. * @param v defines the coordinate on Y axis
  105221. * @param width defines the width of the source data
  105222. * @param height defines the height of the source data
  105223. * @param pixels defines the source byte array
  105224. * @param color defines the output color
  105225. */
  105226. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  105227. /**
  105228. * Interpolates between a and b via alpha
  105229. * @param a The lower value (returned when alpha = 0)
  105230. * @param b The upper value (returned when alpha = 1)
  105231. * @param alpha The interpolation-factor
  105232. * @return The mixed value
  105233. */
  105234. static Mix(a: number, b: number, alpha: number): number;
  105235. /**
  105236. * Tries to instantiate a new object from a given class name
  105237. * @param className defines the class name to instantiate
  105238. * @returns the new object or null if the system was not able to do the instantiation
  105239. */
  105240. static Instantiate(className: string): any;
  105241. /**
  105242. * Provides a slice function that will work even on IE
  105243. * @param data defines the array to slice
  105244. * @param start defines the start of the data (optional)
  105245. * @param end defines the end of the data (optional)
  105246. * @returns the new sliced array
  105247. */
  105248. static Slice<T>(data: T, start?: number, end?: number): T;
  105249. /**
  105250. * Polyfill for setImmediate
  105251. * @param action defines the action to execute after the current execution block
  105252. */
  105253. static SetImmediate(action: () => void): void;
  105254. /**
  105255. * Function indicating if a number is an exponent of 2
  105256. * @param value defines the value to test
  105257. * @returns true if the value is an exponent of 2
  105258. */
  105259. static IsExponentOfTwo(value: number): boolean;
  105260. private static _tmpFloatArray;
  105261. /**
  105262. * Returns the nearest 32-bit single precision float representation of a Number
  105263. * @param value A Number. If the parameter is of a different type, it will get converted
  105264. * to a number or to NaN if it cannot be converted
  105265. * @returns number
  105266. */
  105267. static FloatRound(value: number): number;
  105268. /**
  105269. * Extracts the filename from a path
  105270. * @param path defines the path to use
  105271. * @returns the filename
  105272. */
  105273. static GetFilename(path: string): string;
  105274. /**
  105275. * Extracts the "folder" part of a path (everything before the filename).
  105276. * @param uri The URI to extract the info from
  105277. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  105278. * @returns The "folder" part of the path
  105279. */
  105280. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  105281. /**
  105282. * Extracts text content from a DOM element hierarchy
  105283. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  105284. */
  105285. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  105286. /**
  105287. * Convert an angle in radians to degrees
  105288. * @param angle defines the angle to convert
  105289. * @returns the angle in degrees
  105290. */
  105291. static ToDegrees(angle: number): number;
  105292. /**
  105293. * Convert an angle in degrees to radians
  105294. * @param angle defines the angle to convert
  105295. * @returns the angle in radians
  105296. */
  105297. static ToRadians(angle: number): number;
  105298. /**
  105299. * Returns an array if obj is not an array
  105300. * @param obj defines the object to evaluate as an array
  105301. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  105302. * @returns either obj directly if obj is an array or a new array containing obj
  105303. */
  105304. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  105305. /**
  105306. * Gets the pointer prefix to use
  105307. * @returns "pointer" if touch is enabled. Else returns "mouse"
  105308. */
  105309. static GetPointerPrefix(): string;
  105310. /**
  105311. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  105312. * @param url define the url we are trying
  105313. * @param element define the dom element where to configure the cors policy
  105314. */
  105315. static SetCorsBehavior(url: string | string[], element: {
  105316. crossOrigin: string | null;
  105317. }): void;
  105318. /**
  105319. * Removes unwanted characters from an url
  105320. * @param url defines the url to clean
  105321. * @returns the cleaned url
  105322. */
  105323. static CleanUrl(url: string): string;
  105324. /**
  105325. * Gets or sets a function used to pre-process url before using them to load assets
  105326. */
  105327. static get PreprocessUrl(): (url: string) => string;
  105328. static set PreprocessUrl(processor: (url: string) => string);
  105329. /**
  105330. * Loads an image as an HTMLImageElement.
  105331. * @param input url string, ArrayBuffer, or Blob to load
  105332. * @param onLoad callback called when the image successfully loads
  105333. * @param onError callback called when the image fails to load
  105334. * @param offlineProvider offline provider for caching
  105335. * @param mimeType optional mime type
  105336. * @returns the HTMLImageElement of the loaded image
  105337. */
  105338. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  105339. /**
  105340. * Loads a file from a url
  105341. * @param url url string, ArrayBuffer, or Blob to load
  105342. * @param onSuccess callback called when the file successfully loads
  105343. * @param onProgress callback called while file is loading (if the server supports this mode)
  105344. * @param offlineProvider defines the offline provider for caching
  105345. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105346. * @param onError callback called when the file fails to load
  105347. * @returns a file request object
  105348. */
  105349. 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;
  105350. /**
  105351. * Loads a file from a url
  105352. * @param url the file url to load
  105353. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  105354. */
  105355. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  105356. /**
  105357. * Load a script (identified by an url). When the url returns, the
  105358. * content of this file is added into a new script element, attached to the DOM (body element)
  105359. * @param scriptUrl defines the url of the script to laod
  105360. * @param onSuccess defines the callback called when the script is loaded
  105361. * @param onError defines the callback to call if an error occurs
  105362. * @param scriptId defines the id of the script element
  105363. */
  105364. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  105365. /**
  105366. * Load an asynchronous script (identified by an url). When the url returns, the
  105367. * content of this file is added into a new script element, attached to the DOM (body element)
  105368. * @param scriptUrl defines the url of the script to laod
  105369. * @param scriptId defines the id of the script element
  105370. * @returns a promise request object
  105371. */
  105372. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  105373. /**
  105374. * Loads a file from a blob
  105375. * @param fileToLoad defines the blob to use
  105376. * @param callback defines the callback to call when data is loaded
  105377. * @param progressCallback defines the callback to call during loading process
  105378. * @returns a file request object
  105379. */
  105380. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  105381. /**
  105382. * Reads a file from a File object
  105383. * @param file defines the file to load
  105384. * @param onSuccess defines the callback to call when data is loaded
  105385. * @param onProgress defines the callback to call during loading process
  105386. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  105387. * @param onError defines the callback to call when an error occurs
  105388. * @returns a file request object
  105389. */
  105390. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  105391. /**
  105392. * Creates a data url from a given string content
  105393. * @param content defines the content to convert
  105394. * @returns the new data url link
  105395. */
  105396. static FileAsURL(content: string): string;
  105397. /**
  105398. * Format the given number to a specific decimal format
  105399. * @param value defines the number to format
  105400. * @param decimals defines the number of decimals to use
  105401. * @returns the formatted string
  105402. */
  105403. static Format(value: number, decimals?: number): string;
  105404. /**
  105405. * Tries to copy an object by duplicating every property
  105406. * @param source defines the source object
  105407. * @param destination defines the target object
  105408. * @param doNotCopyList defines a list of properties to avoid
  105409. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  105410. */
  105411. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  105412. /**
  105413. * Gets a boolean indicating if the given object has no own property
  105414. * @param obj defines the object to test
  105415. * @returns true if object has no own property
  105416. */
  105417. static IsEmpty(obj: any): boolean;
  105418. /**
  105419. * Function used to register events at window level
  105420. * @param windowElement defines the Window object to use
  105421. * @param events defines the events to register
  105422. */
  105423. static RegisterTopRootEvents(windowElement: Window, events: {
  105424. name: string;
  105425. handler: Nullable<(e: FocusEvent) => any>;
  105426. }[]): void;
  105427. /**
  105428. * Function used to unregister events from window level
  105429. * @param windowElement defines the Window object to use
  105430. * @param events defines the events to unregister
  105431. */
  105432. static UnregisterTopRootEvents(windowElement: Window, events: {
  105433. name: string;
  105434. handler: Nullable<(e: FocusEvent) => any>;
  105435. }[]): void;
  105436. /**
  105437. * @ignore
  105438. */
  105439. static _ScreenshotCanvas: HTMLCanvasElement;
  105440. /**
  105441. * Dumps the current bound framebuffer
  105442. * @param width defines the rendering width
  105443. * @param height defines the rendering height
  105444. * @param engine defines the hosting engine
  105445. * @param successCallback defines the callback triggered once the data are available
  105446. * @param mimeType defines the mime type of the result
  105447. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  105448. */
  105449. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  105450. /**
  105451. * Converts the canvas data to blob.
  105452. * This acts as a polyfill for browsers not supporting the to blob function.
  105453. * @param canvas Defines the canvas to extract the data from
  105454. * @param successCallback Defines the callback triggered once the data are available
  105455. * @param mimeType Defines the mime type of the result
  105456. */
  105457. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  105458. /**
  105459. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  105460. * @param successCallback defines the callback triggered once the data are available
  105461. * @param mimeType defines the mime type of the result
  105462. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  105463. */
  105464. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  105465. /**
  105466. * Downloads a blob in the browser
  105467. * @param blob defines the blob to download
  105468. * @param fileName defines the name of the downloaded file
  105469. */
  105470. static Download(blob: Blob, fileName: string): void;
  105471. /**
  105472. * Captures a screenshot of the current rendering
  105473. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  105474. * @param engine defines the rendering engine
  105475. * @param camera defines the source camera
  105476. * @param size This parameter can be set to a single number or to an object with the
  105477. * following (optional) properties: precision, width, height. If a single number is passed,
  105478. * it will be used for both width and height. If an object is passed, the screenshot size
  105479. * will be derived from the parameters. The precision property is a multiplier allowing
  105480. * rendering at a higher or lower resolution
  105481. * @param successCallback defines the callback receives a single parameter which contains the
  105482. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  105483. * src parameter of an <img> to display it
  105484. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  105485. * Check your browser for supported MIME types
  105486. */
  105487. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  105488. /**
  105489. * Captures a screenshot of the current rendering
  105490. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  105491. * @param engine defines the rendering engine
  105492. * @param camera defines the source camera
  105493. * @param size This parameter can be set to a single number or to an object with the
  105494. * following (optional) properties: precision, width, height. If a single number is passed,
  105495. * it will be used for both width and height. If an object is passed, the screenshot size
  105496. * will be derived from the parameters. The precision property is a multiplier allowing
  105497. * rendering at a higher or lower resolution
  105498. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  105499. * Check your browser for supported MIME types
  105500. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  105501. * to the src parameter of an <img> to display it
  105502. */
  105503. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  105504. /**
  105505. * Generates an image screenshot from the specified camera.
  105506. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  105507. * @param engine The engine to use for rendering
  105508. * @param camera The camera to use for rendering
  105509. * @param size This parameter can be set to a single number or to an object with the
  105510. * following (optional) properties: precision, width, height. If a single number is passed,
  105511. * it will be used for both width and height. If an object is passed, the screenshot size
  105512. * will be derived from the parameters. The precision property is a multiplier allowing
  105513. * rendering at a higher or lower resolution
  105514. * @param successCallback The callback receives a single parameter which contains the
  105515. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  105516. * src parameter of an <img> to display it
  105517. * @param mimeType The MIME type of the screenshot image (default: image/png).
  105518. * Check your browser for supported MIME types
  105519. * @param samples Texture samples (default: 1)
  105520. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  105521. * @param fileName A name for for the downloaded file.
  105522. */
  105523. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  105524. /**
  105525. * Generates an image screenshot from the specified camera.
  105526. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  105527. * @param engine The engine to use for rendering
  105528. * @param camera The camera to use for rendering
  105529. * @param size This parameter can be set to a single number or to an object with the
  105530. * following (optional) properties: precision, width, height. If a single number is passed,
  105531. * it will be used for both width and height. If an object is passed, the screenshot size
  105532. * will be derived from the parameters. The precision property is a multiplier allowing
  105533. * rendering at a higher or lower resolution
  105534. * @param mimeType The MIME type of the screenshot image (default: image/png).
  105535. * Check your browser for supported MIME types
  105536. * @param samples Texture samples (default: 1)
  105537. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  105538. * @param fileName A name for for the downloaded file.
  105539. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  105540. * to the src parameter of an <img> to display it
  105541. */
  105542. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  105543. /**
  105544. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105545. * Be aware Math.random() could cause collisions, but:
  105546. * "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"
  105547. * @returns a pseudo random id
  105548. */
  105549. static RandomId(): string;
  105550. /**
  105551. * Test if the given uri is a base64 string
  105552. * @param uri The uri to test
  105553. * @return True if the uri is a base64 string or false otherwise
  105554. */
  105555. static IsBase64(uri: string): boolean;
  105556. /**
  105557. * Decode the given base64 uri.
  105558. * @param uri The uri to decode
  105559. * @return The decoded base64 data.
  105560. */
  105561. static DecodeBase64(uri: string): ArrayBuffer;
  105562. /**
  105563. * Gets the absolute url.
  105564. * @param url the input url
  105565. * @return the absolute url
  105566. */
  105567. static GetAbsoluteUrl(url: string): string;
  105568. /**
  105569. * No log
  105570. */
  105571. static readonly NoneLogLevel: number;
  105572. /**
  105573. * Only message logs
  105574. */
  105575. static readonly MessageLogLevel: number;
  105576. /**
  105577. * Only warning logs
  105578. */
  105579. static readonly WarningLogLevel: number;
  105580. /**
  105581. * Only error logs
  105582. */
  105583. static readonly ErrorLogLevel: number;
  105584. /**
  105585. * All logs
  105586. */
  105587. static readonly AllLogLevel: number;
  105588. /**
  105589. * Gets a value indicating the number of loading errors
  105590. * @ignorenaming
  105591. */
  105592. static get errorsCount(): number;
  105593. /**
  105594. * Callback called when a new log is added
  105595. */
  105596. static OnNewCacheEntry: (entry: string) => void;
  105597. /**
  105598. * Log a message to the console
  105599. * @param message defines the message to log
  105600. */
  105601. static Log(message: string): void;
  105602. /**
  105603. * Write a warning message to the console
  105604. * @param message defines the message to log
  105605. */
  105606. static Warn(message: string): void;
  105607. /**
  105608. * Write an error message to the console
  105609. * @param message defines the message to log
  105610. */
  105611. static Error(message: string): void;
  105612. /**
  105613. * Gets current log cache (list of logs)
  105614. */
  105615. static get LogCache(): string;
  105616. /**
  105617. * Clears the log cache
  105618. */
  105619. static ClearLogCache(): void;
  105620. /**
  105621. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  105622. */
  105623. static set LogLevels(level: number);
  105624. /**
  105625. * Checks if the window object exists
  105626. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  105627. */
  105628. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  105629. /**
  105630. * No performance log
  105631. */
  105632. static readonly PerformanceNoneLogLevel: number;
  105633. /**
  105634. * Use user marks to log performance
  105635. */
  105636. static readonly PerformanceUserMarkLogLevel: number;
  105637. /**
  105638. * Log performance to the console
  105639. */
  105640. static readonly PerformanceConsoleLogLevel: number;
  105641. private static _performance;
  105642. /**
  105643. * Sets the current performance log level
  105644. */
  105645. static set PerformanceLogLevel(level: number);
  105646. private static _StartPerformanceCounterDisabled;
  105647. private static _EndPerformanceCounterDisabled;
  105648. private static _StartUserMark;
  105649. private static _EndUserMark;
  105650. private static _StartPerformanceConsole;
  105651. private static _EndPerformanceConsole;
  105652. /**
  105653. * Starts a performance counter
  105654. */
  105655. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  105656. /**
  105657. * Ends a specific performance coutner
  105658. */
  105659. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  105660. /**
  105661. * Gets either window.performance.now() if supported or Date.now() else
  105662. */
  105663. static get Now(): number;
  105664. /**
  105665. * This method will return the name of the class used to create the instance of the given object.
  105666. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  105667. * @param object the object to get the class name from
  105668. * @param isType defines if the object is actually a type
  105669. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  105670. */
  105671. static GetClassName(object: any, isType?: boolean): string;
  105672. /**
  105673. * Gets the first element of an array satisfying a given predicate
  105674. * @param array defines the array to browse
  105675. * @param predicate defines the predicate to use
  105676. * @returns null if not found or the element
  105677. */
  105678. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  105679. /**
  105680. * This method will return the name of the full name of the class, including its owning module (if any).
  105681. * 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).
  105682. * @param object the object to get the class name from
  105683. * @param isType defines if the object is actually a type
  105684. * @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.
  105685. * @ignorenaming
  105686. */
  105687. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  105688. /**
  105689. * Returns a promise that resolves after the given amount of time.
  105690. * @param delay Number of milliseconds to delay
  105691. * @returns Promise that resolves after the given amount of time
  105692. */
  105693. static DelayAsync(delay: number): Promise<void>;
  105694. /**
  105695. * Utility function to detect if the current user agent is Safari
  105696. * @returns whether or not the current user agent is safari
  105697. */
  105698. static IsSafari(): boolean;
  105699. }
  105700. /**
  105701. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  105702. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  105703. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  105704. * @param name The name of the class, case should be preserved
  105705. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  105706. */
  105707. export function className(name: string, module?: string): (target: Object) => void;
  105708. /**
  105709. * An implementation of a loop for asynchronous functions.
  105710. */
  105711. export class AsyncLoop {
  105712. /**
  105713. * Defines the number of iterations for the loop
  105714. */
  105715. iterations: number;
  105716. /**
  105717. * Defines the current index of the loop.
  105718. */
  105719. index: number;
  105720. private _done;
  105721. private _fn;
  105722. private _successCallback;
  105723. /**
  105724. * Constructor.
  105725. * @param iterations the number of iterations.
  105726. * @param func the function to run each iteration
  105727. * @param successCallback the callback that will be called upon succesful execution
  105728. * @param offset starting offset.
  105729. */
  105730. constructor(
  105731. /**
  105732. * Defines the number of iterations for the loop
  105733. */
  105734. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  105735. /**
  105736. * Execute the next iteration. Must be called after the last iteration was finished.
  105737. */
  105738. executeNext(): void;
  105739. /**
  105740. * Break the loop and run the success callback.
  105741. */
  105742. breakLoop(): void;
  105743. /**
  105744. * Create and run an async loop.
  105745. * @param iterations the number of iterations.
  105746. * @param fn the function to run each iteration
  105747. * @param successCallback the callback that will be called upon succesful execution
  105748. * @param offset starting offset.
  105749. * @returns the created async loop object
  105750. */
  105751. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  105752. /**
  105753. * A for-loop that will run a given number of iterations synchronous and the rest async.
  105754. * @param iterations total number of iterations
  105755. * @param syncedIterations number of synchronous iterations in each async iteration.
  105756. * @param fn the function to call each iteration.
  105757. * @param callback a success call back that will be called when iterating stops.
  105758. * @param breakFunction a break condition (optional)
  105759. * @param timeout timeout settings for the setTimeout function. default - 0.
  105760. * @returns the created async loop object
  105761. */
  105762. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  105763. }
  105764. }
  105765. declare module BABYLON {
  105766. /**
  105767. * This class implement a typical dictionary using a string as key and the generic type T as value.
  105768. * The underlying implementation relies on an associative array to ensure the best performances.
  105769. * The value can be anything including 'null' but except 'undefined'
  105770. */
  105771. export class StringDictionary<T> {
  105772. /**
  105773. * This will clear this dictionary and copy the content from the 'source' one.
  105774. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  105775. * @param source the dictionary to take the content from and copy to this dictionary
  105776. */
  105777. copyFrom(source: StringDictionary<T>): void;
  105778. /**
  105779. * Get a value based from its key
  105780. * @param key the given key to get the matching value from
  105781. * @return the value if found, otherwise undefined is returned
  105782. */
  105783. get(key: string): T | undefined;
  105784. /**
  105785. * Get a value from its key or add it if it doesn't exist.
  105786. * This method will ensure you that a given key/data will be present in the dictionary.
  105787. * @param key the given key to get the matching value from
  105788. * @param factory the factory that will create the value if the key is not present in the dictionary.
  105789. * The factory will only be invoked if there's no data for the given key.
  105790. * @return the value corresponding to the key.
  105791. */
  105792. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  105793. /**
  105794. * Get a value from its key if present in the dictionary otherwise add it
  105795. * @param key the key to get the value from
  105796. * @param val if there's no such key/value pair in the dictionary add it with this value
  105797. * @return the value corresponding to the key
  105798. */
  105799. getOrAdd(key: string, val: T): T;
  105800. /**
  105801. * Check if there's a given key in the dictionary
  105802. * @param key the key to check for
  105803. * @return true if the key is present, false otherwise
  105804. */
  105805. contains(key: string): boolean;
  105806. /**
  105807. * Add a new key and its corresponding value
  105808. * @param key the key to add
  105809. * @param value the value corresponding to the key
  105810. * @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
  105811. */
  105812. add(key: string, value: T): boolean;
  105813. /**
  105814. * Update a specific value associated to a key
  105815. * @param key defines the key to use
  105816. * @param value defines the value to store
  105817. * @returns true if the value was updated (or false if the key was not found)
  105818. */
  105819. set(key: string, value: T): boolean;
  105820. /**
  105821. * Get the element of the given key and remove it from the dictionary
  105822. * @param key defines the key to search
  105823. * @returns the value associated with the key or null if not found
  105824. */
  105825. getAndRemove(key: string): Nullable<T>;
  105826. /**
  105827. * Remove a key/value from the dictionary.
  105828. * @param key the key to remove
  105829. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  105830. */
  105831. remove(key: string): boolean;
  105832. /**
  105833. * Clear the whole content of the dictionary
  105834. */
  105835. clear(): void;
  105836. /**
  105837. * Gets the current count
  105838. */
  105839. get count(): number;
  105840. /**
  105841. * Execute a callback on each key/val of the dictionary.
  105842. * Note that you can remove any element in this dictionary in the callback implementation
  105843. * @param callback the callback to execute on a given key/value pair
  105844. */
  105845. forEach(callback: (key: string, val: T) => void): void;
  105846. /**
  105847. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  105848. * If the callback returns null or undefined the method will iterate to the next key/value pair
  105849. * Note that you can remove any element in this dictionary in the callback implementation
  105850. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  105851. * @returns the first item
  105852. */
  105853. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  105854. private _count;
  105855. private _data;
  105856. }
  105857. }
  105858. declare module BABYLON {
  105859. /** @hidden */
  105860. export interface ICollisionCoordinator {
  105861. createCollider(): Collider;
  105862. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105863. init(scene: Scene): void;
  105864. }
  105865. /** @hidden */
  105866. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  105867. private _scene;
  105868. private _scaledPosition;
  105869. private _scaledVelocity;
  105870. private _finalPosition;
  105871. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105872. createCollider(): Collider;
  105873. init(scene: Scene): void;
  105874. private _collideWithWorld;
  105875. }
  105876. }
  105877. declare module BABYLON {
  105878. /**
  105879. * Class used to manage all inputs for the scene.
  105880. */
  105881. export class InputManager {
  105882. /** The distance in pixel that you have to move to prevent some events */
  105883. static DragMovementThreshold: number;
  105884. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  105885. static LongPressDelay: number;
  105886. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  105887. static DoubleClickDelay: number;
  105888. /** If you need to check double click without raising a single click at first click, enable this flag */
  105889. static ExclusiveDoubleClickMode: boolean;
  105890. private _wheelEventName;
  105891. private _onPointerMove;
  105892. private _onPointerDown;
  105893. private _onPointerUp;
  105894. private _initClickEvent;
  105895. private _initActionManager;
  105896. private _delayedSimpleClick;
  105897. private _delayedSimpleClickTimeout;
  105898. private _previousDelayedSimpleClickTimeout;
  105899. private _meshPickProceed;
  105900. private _previousButtonPressed;
  105901. private _currentPickResult;
  105902. private _previousPickResult;
  105903. private _totalPointersPressed;
  105904. private _doubleClickOccured;
  105905. private _pointerOverMesh;
  105906. private _pickedDownMesh;
  105907. private _pickedUpMesh;
  105908. private _pointerX;
  105909. private _pointerY;
  105910. private _unTranslatedPointerX;
  105911. private _unTranslatedPointerY;
  105912. private _startingPointerPosition;
  105913. private _previousStartingPointerPosition;
  105914. private _startingPointerTime;
  105915. private _previousStartingPointerTime;
  105916. private _pointerCaptures;
  105917. private _onKeyDown;
  105918. private _onKeyUp;
  105919. private _onCanvasFocusObserver;
  105920. private _onCanvasBlurObserver;
  105921. private _scene;
  105922. /**
  105923. * Creates a new InputManager
  105924. * @param scene defines the hosting scene
  105925. */
  105926. constructor(scene: Scene);
  105927. /**
  105928. * Gets the mesh that is currently under the pointer
  105929. */
  105930. get meshUnderPointer(): Nullable<AbstractMesh>;
  105931. /**
  105932. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  105933. */
  105934. get unTranslatedPointer(): Vector2;
  105935. /**
  105936. * Gets or sets the current on-screen X position of the pointer
  105937. */
  105938. get pointerX(): number;
  105939. set pointerX(value: number);
  105940. /**
  105941. * Gets or sets the current on-screen Y position of the pointer
  105942. */
  105943. get pointerY(): number;
  105944. set pointerY(value: number);
  105945. private _updatePointerPosition;
  105946. private _processPointerMove;
  105947. private _setRayOnPointerInfo;
  105948. private _checkPrePointerObservable;
  105949. /**
  105950. * Use this method to simulate a pointer move on a mesh
  105951. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105952. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105953. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105954. */
  105955. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105956. /**
  105957. * Use this method to simulate a pointer down on a mesh
  105958. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105959. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105960. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105961. */
  105962. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105963. private _processPointerDown;
  105964. /** @hidden */
  105965. _isPointerSwiping(): boolean;
  105966. /**
  105967. * Use this method to simulate a pointer up on a mesh
  105968. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105969. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105970. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105971. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  105972. */
  105973. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  105974. private _processPointerUp;
  105975. /**
  105976. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  105977. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  105978. * @returns true if the pointer was captured
  105979. */
  105980. isPointerCaptured(pointerId?: number): boolean;
  105981. /**
  105982. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  105983. * @param attachUp defines if you want to attach events to pointerup
  105984. * @param attachDown defines if you want to attach events to pointerdown
  105985. * @param attachMove defines if you want to attach events to pointermove
  105986. */
  105987. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  105988. /**
  105989. * Detaches all event handlers
  105990. */
  105991. detachControl(): void;
  105992. /**
  105993. * Force the value of meshUnderPointer
  105994. * @param mesh defines the mesh to use
  105995. */
  105996. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105997. /**
  105998. * Gets the mesh under the pointer
  105999. * @returns a Mesh or null if no mesh is under the pointer
  106000. */
  106001. getPointerOverMesh(): Nullable<AbstractMesh>;
  106002. }
  106003. }
  106004. declare module BABYLON {
  106005. /**
  106006. * Helper class used to generate session unique ID
  106007. */
  106008. export class UniqueIdGenerator {
  106009. private static _UniqueIdCounter;
  106010. /**
  106011. * Gets an unique (relatively to the current scene) Id
  106012. */
  106013. static get UniqueId(): number;
  106014. }
  106015. }
  106016. declare module BABYLON {
  106017. /**
  106018. * This class defines the direct association between an animation and a target
  106019. */
  106020. export class TargetedAnimation {
  106021. /**
  106022. * Animation to perform
  106023. */
  106024. animation: Animation;
  106025. /**
  106026. * Target to animate
  106027. */
  106028. target: any;
  106029. /**
  106030. * Serialize the object
  106031. * @returns the JSON object representing the current entity
  106032. */
  106033. serialize(): any;
  106034. }
  106035. /**
  106036. * Use this class to create coordinated animations on multiple targets
  106037. */
  106038. export class AnimationGroup implements IDisposable {
  106039. /** The name of the animation group */
  106040. name: string;
  106041. private _scene;
  106042. private _targetedAnimations;
  106043. private _animatables;
  106044. private _from;
  106045. private _to;
  106046. private _isStarted;
  106047. private _isPaused;
  106048. private _speedRatio;
  106049. private _loopAnimation;
  106050. /**
  106051. * Gets or sets the unique id of the node
  106052. */
  106053. uniqueId: number;
  106054. /**
  106055. * This observable will notify when one animation have ended
  106056. */
  106057. onAnimationEndObservable: Observable<TargetedAnimation>;
  106058. /**
  106059. * Observer raised when one animation loops
  106060. */
  106061. onAnimationLoopObservable: Observable<TargetedAnimation>;
  106062. /**
  106063. * Observer raised when all animations have looped
  106064. */
  106065. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  106066. /**
  106067. * This observable will notify when all animations have ended.
  106068. */
  106069. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  106070. /**
  106071. * This observable will notify when all animations have paused.
  106072. */
  106073. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  106074. /**
  106075. * This observable will notify when all animations are playing.
  106076. */
  106077. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  106078. /**
  106079. * Gets the first frame
  106080. */
  106081. get from(): number;
  106082. /**
  106083. * Gets the last frame
  106084. */
  106085. get to(): number;
  106086. /**
  106087. * Define if the animations are started
  106088. */
  106089. get isStarted(): boolean;
  106090. /**
  106091. * Gets a value indicating that the current group is playing
  106092. */
  106093. get isPlaying(): boolean;
  106094. /**
  106095. * Gets or sets the speed ratio to use for all animations
  106096. */
  106097. get speedRatio(): number;
  106098. /**
  106099. * Gets or sets the speed ratio to use for all animations
  106100. */
  106101. set speedRatio(value: number);
  106102. /**
  106103. * Gets or sets if all animations should loop or not
  106104. */
  106105. get loopAnimation(): boolean;
  106106. set loopAnimation(value: boolean);
  106107. /**
  106108. * Gets the targeted animations for this animation group
  106109. */
  106110. get targetedAnimations(): Array<TargetedAnimation>;
  106111. /**
  106112. * returning the list of animatables controlled by this animation group.
  106113. */
  106114. get animatables(): Array<Animatable>;
  106115. /**
  106116. * Instantiates a new Animation Group.
  106117. * This helps managing several animations at once.
  106118. * @see http://doc.babylonjs.com/how_to/group
  106119. * @param name Defines the name of the group
  106120. * @param scene Defines the scene the group belongs to
  106121. */
  106122. constructor(
  106123. /** The name of the animation group */
  106124. name: string, scene?: Nullable<Scene>);
  106125. /**
  106126. * Add an animation (with its target) in the group
  106127. * @param animation defines the animation we want to add
  106128. * @param target defines the target of the animation
  106129. * @returns the TargetedAnimation object
  106130. */
  106131. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  106132. /**
  106133. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  106134. * It can add constant keys at begin or end
  106135. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  106136. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  106137. * @returns the animation group
  106138. */
  106139. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  106140. private _animationLoopCount;
  106141. private _animationLoopFlags;
  106142. private _processLoop;
  106143. /**
  106144. * Start all animations on given targets
  106145. * @param loop defines if animations must loop
  106146. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  106147. * @param from defines the from key (optional)
  106148. * @param to defines the to key (optional)
  106149. * @returns the current animation group
  106150. */
  106151. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  106152. /**
  106153. * Pause all animations
  106154. * @returns the animation group
  106155. */
  106156. pause(): AnimationGroup;
  106157. /**
  106158. * Play all animations to initial state
  106159. * This function will start() the animations if they were not started or will restart() them if they were paused
  106160. * @param loop defines if animations must loop
  106161. * @returns the animation group
  106162. */
  106163. play(loop?: boolean): AnimationGroup;
  106164. /**
  106165. * Reset all animations to initial state
  106166. * @returns the animation group
  106167. */
  106168. reset(): AnimationGroup;
  106169. /**
  106170. * Restart animations from key 0
  106171. * @returns the animation group
  106172. */
  106173. restart(): AnimationGroup;
  106174. /**
  106175. * Stop all animations
  106176. * @returns the animation group
  106177. */
  106178. stop(): AnimationGroup;
  106179. /**
  106180. * Set animation weight for all animatables
  106181. * @param weight defines the weight to use
  106182. * @return the animationGroup
  106183. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  106184. */
  106185. setWeightForAllAnimatables(weight: number): AnimationGroup;
  106186. /**
  106187. * Synchronize and normalize all animatables with a source animatable
  106188. * @param root defines the root animatable to synchronize with
  106189. * @return the animationGroup
  106190. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  106191. */
  106192. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  106193. /**
  106194. * Goes to a specific frame in this animation group
  106195. * @param frame the frame number to go to
  106196. * @return the animationGroup
  106197. */
  106198. goToFrame(frame: number): AnimationGroup;
  106199. /**
  106200. * Dispose all associated resources
  106201. */
  106202. dispose(): void;
  106203. private _checkAnimationGroupEnded;
  106204. /**
  106205. * Clone the current animation group and returns a copy
  106206. * @param newName defines the name of the new group
  106207. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  106208. * @returns the new aniamtion group
  106209. */
  106210. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  106211. /**
  106212. * Serializes the animationGroup to an object
  106213. * @returns Serialized object
  106214. */
  106215. serialize(): any;
  106216. /**
  106217. * Returns a new AnimationGroup object parsed from the source provided.
  106218. * @param parsedAnimationGroup defines the source
  106219. * @param scene defines the scene that will receive the animationGroup
  106220. * @returns a new AnimationGroup
  106221. */
  106222. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  106223. /**
  106224. * Returns the string "AnimationGroup"
  106225. * @returns "AnimationGroup"
  106226. */
  106227. getClassName(): string;
  106228. /**
  106229. * Creates a detailled string about the object
  106230. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  106231. * @returns a string representing the object
  106232. */
  106233. toString(fullDetails?: boolean): string;
  106234. }
  106235. }
  106236. declare module BABYLON {
  106237. /**
  106238. * Define an interface for all classes that will hold resources
  106239. */
  106240. export interface IDisposable {
  106241. /**
  106242. * Releases all held resources
  106243. */
  106244. dispose(): void;
  106245. }
  106246. /** Interface defining initialization parameters for Scene class */
  106247. export interface SceneOptions {
  106248. /**
  106249. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  106250. * It will improve performance when the number of geometries becomes important.
  106251. */
  106252. useGeometryUniqueIdsMap?: boolean;
  106253. /**
  106254. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  106255. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  106256. */
  106257. useMaterialMeshMap?: boolean;
  106258. /**
  106259. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  106260. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  106261. */
  106262. useClonedMeshMap?: boolean;
  106263. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  106264. virtual?: boolean;
  106265. }
  106266. /**
  106267. * Represents a scene to be rendered by the engine.
  106268. * @see http://doc.babylonjs.com/features/scene
  106269. */
  106270. export class Scene extends AbstractScene implements IAnimatable {
  106271. /** The fog is deactivated */
  106272. static readonly FOGMODE_NONE: number;
  106273. /** The fog density is following an exponential function */
  106274. static readonly FOGMODE_EXP: number;
  106275. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  106276. static readonly FOGMODE_EXP2: number;
  106277. /** The fog density is following a linear function. */
  106278. static readonly FOGMODE_LINEAR: number;
  106279. /**
  106280. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  106281. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106282. */
  106283. static MinDeltaTime: number;
  106284. /**
  106285. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  106286. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106287. */
  106288. static MaxDeltaTime: number;
  106289. /**
  106290. * Factory used to create the default material.
  106291. * @param name The name of the material to create
  106292. * @param scene The scene to create the material for
  106293. * @returns The default material
  106294. */
  106295. static DefaultMaterialFactory(scene: Scene): Material;
  106296. /**
  106297. * Factory used to create the a collision coordinator.
  106298. * @returns The collision coordinator
  106299. */
  106300. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  106301. /** @hidden */
  106302. _inputManager: InputManager;
  106303. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  106304. cameraToUseForPointers: Nullable<Camera>;
  106305. /** @hidden */
  106306. readonly _isScene: boolean;
  106307. /**
  106308. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  106309. */
  106310. autoClear: boolean;
  106311. /**
  106312. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  106313. */
  106314. autoClearDepthAndStencil: boolean;
  106315. /**
  106316. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  106317. */
  106318. clearColor: Color4;
  106319. /**
  106320. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  106321. */
  106322. ambientColor: Color3;
  106323. /**
  106324. * This is use to store the default BRDF lookup for PBR materials in your scene.
  106325. * It should only be one of the following (if not the default embedded one):
  106326. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  106327. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  106328. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  106329. * The material properties need to be setup according to the type of texture in use.
  106330. */
  106331. environmentBRDFTexture: BaseTexture;
  106332. /** @hidden */
  106333. protected _environmentTexture: Nullable<BaseTexture>;
  106334. /**
  106335. * Texture used in all pbr material as the reflection texture.
  106336. * As in the majority of the scene they are the same (exception for multi room and so on),
  106337. * this is easier to reference from here than from all the materials.
  106338. */
  106339. get environmentTexture(): Nullable<BaseTexture>;
  106340. /**
  106341. * Texture used in all pbr material as the reflection texture.
  106342. * As in the majority of the scene they are the same (exception for multi room and so on),
  106343. * this is easier to set here than in all the materials.
  106344. */
  106345. set environmentTexture(value: Nullable<BaseTexture>);
  106346. /** @hidden */
  106347. protected _environmentIntensity: number;
  106348. /**
  106349. * Intensity of the environment in all pbr material.
  106350. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  106351. * As in the majority of the scene they are the same (exception for multi room and so on),
  106352. * this is easier to reference from here than from all the materials.
  106353. */
  106354. get environmentIntensity(): number;
  106355. /**
  106356. * Intensity of the environment in all pbr material.
  106357. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  106358. * As in the majority of the scene they are the same (exception for multi room and so on),
  106359. * this is easier to set here than in all the materials.
  106360. */
  106361. set environmentIntensity(value: number);
  106362. /** @hidden */
  106363. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106364. /**
  106365. * Default image processing configuration used either in the rendering
  106366. * Forward main pass or through the imageProcessingPostProcess if present.
  106367. * As in the majority of the scene they are the same (exception for multi camera),
  106368. * this is easier to reference from here than from all the materials and post process.
  106369. *
  106370. * No setter as we it is a shared configuration, you can set the values instead.
  106371. */
  106372. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  106373. private _forceWireframe;
  106374. /**
  106375. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  106376. */
  106377. set forceWireframe(value: boolean);
  106378. get forceWireframe(): boolean;
  106379. private _skipFrustumClipping;
  106380. /**
  106381. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  106382. */
  106383. set skipFrustumClipping(value: boolean);
  106384. get skipFrustumClipping(): boolean;
  106385. private _forcePointsCloud;
  106386. /**
  106387. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  106388. */
  106389. set forcePointsCloud(value: boolean);
  106390. get forcePointsCloud(): boolean;
  106391. /**
  106392. * Gets or sets the active clipplane 1
  106393. */
  106394. clipPlane: Nullable<Plane>;
  106395. /**
  106396. * Gets or sets the active clipplane 2
  106397. */
  106398. clipPlane2: Nullable<Plane>;
  106399. /**
  106400. * Gets or sets the active clipplane 3
  106401. */
  106402. clipPlane3: Nullable<Plane>;
  106403. /**
  106404. * Gets or sets the active clipplane 4
  106405. */
  106406. clipPlane4: Nullable<Plane>;
  106407. /**
  106408. * Gets or sets the active clipplane 5
  106409. */
  106410. clipPlane5: Nullable<Plane>;
  106411. /**
  106412. * Gets or sets the active clipplane 6
  106413. */
  106414. clipPlane6: Nullable<Plane>;
  106415. /**
  106416. * Gets or sets a boolean indicating if animations are enabled
  106417. */
  106418. animationsEnabled: boolean;
  106419. private _animationPropertiesOverride;
  106420. /**
  106421. * Gets or sets the animation properties override
  106422. */
  106423. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106424. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106425. /**
  106426. * Gets or sets a boolean indicating if a constant deltatime has to be used
  106427. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  106428. */
  106429. useConstantAnimationDeltaTime: boolean;
  106430. /**
  106431. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  106432. * Please note that it requires to run a ray cast through the scene on every frame
  106433. */
  106434. constantlyUpdateMeshUnderPointer: boolean;
  106435. /**
  106436. * Defines the HTML cursor to use when hovering over interactive elements
  106437. */
  106438. hoverCursor: string;
  106439. /**
  106440. * Defines the HTML default cursor to use (empty by default)
  106441. */
  106442. defaultCursor: string;
  106443. /**
  106444. * Defines wether cursors are handled by the scene.
  106445. */
  106446. doNotHandleCursors: boolean;
  106447. /**
  106448. * This is used to call preventDefault() on pointer down
  106449. * in order to block unwanted artifacts like system double clicks
  106450. */
  106451. preventDefaultOnPointerDown: boolean;
  106452. /**
  106453. * This is used to call preventDefault() on pointer up
  106454. * in order to block unwanted artifacts like system double clicks
  106455. */
  106456. preventDefaultOnPointerUp: boolean;
  106457. /**
  106458. * Gets or sets user defined metadata
  106459. */
  106460. metadata: any;
  106461. /**
  106462. * For internal use only. Please do not use.
  106463. */
  106464. reservedDataStore: any;
  106465. /**
  106466. * Gets the name of the plugin used to load this scene (null by default)
  106467. */
  106468. loadingPluginName: string;
  106469. /**
  106470. * Use this array to add regular expressions used to disable offline support for specific urls
  106471. */
  106472. disableOfflineSupportExceptionRules: RegExp[];
  106473. /**
  106474. * An event triggered when the scene is disposed.
  106475. */
  106476. onDisposeObservable: Observable<Scene>;
  106477. private _onDisposeObserver;
  106478. /** Sets a function to be executed when this scene is disposed. */
  106479. set onDispose(callback: () => void);
  106480. /**
  106481. * An event triggered before rendering the scene (right after animations and physics)
  106482. */
  106483. onBeforeRenderObservable: Observable<Scene>;
  106484. private _onBeforeRenderObserver;
  106485. /** Sets a function to be executed before rendering this scene */
  106486. set beforeRender(callback: Nullable<() => void>);
  106487. /**
  106488. * An event triggered after rendering the scene
  106489. */
  106490. onAfterRenderObservable: Observable<Scene>;
  106491. /**
  106492. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  106493. */
  106494. onAfterRenderCameraObservable: Observable<Camera>;
  106495. private _onAfterRenderObserver;
  106496. /** Sets a function to be executed after rendering this scene */
  106497. set afterRender(callback: Nullable<() => void>);
  106498. /**
  106499. * An event triggered before animating the scene
  106500. */
  106501. onBeforeAnimationsObservable: Observable<Scene>;
  106502. /**
  106503. * An event triggered after animations processing
  106504. */
  106505. onAfterAnimationsObservable: Observable<Scene>;
  106506. /**
  106507. * An event triggered before draw calls are ready to be sent
  106508. */
  106509. onBeforeDrawPhaseObservable: Observable<Scene>;
  106510. /**
  106511. * An event triggered after draw calls have been sent
  106512. */
  106513. onAfterDrawPhaseObservable: Observable<Scene>;
  106514. /**
  106515. * An event triggered when the scene is ready
  106516. */
  106517. onReadyObservable: Observable<Scene>;
  106518. /**
  106519. * An event triggered before rendering a camera
  106520. */
  106521. onBeforeCameraRenderObservable: Observable<Camera>;
  106522. private _onBeforeCameraRenderObserver;
  106523. /** Sets a function to be executed before rendering a camera*/
  106524. set beforeCameraRender(callback: () => void);
  106525. /**
  106526. * An event triggered after rendering a camera
  106527. */
  106528. onAfterCameraRenderObservable: Observable<Camera>;
  106529. private _onAfterCameraRenderObserver;
  106530. /** Sets a function to be executed after rendering a camera*/
  106531. set afterCameraRender(callback: () => void);
  106532. /**
  106533. * An event triggered when active meshes evaluation is about to start
  106534. */
  106535. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  106536. /**
  106537. * An event triggered when active meshes evaluation is done
  106538. */
  106539. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  106540. /**
  106541. * An event triggered when particles rendering is about to start
  106542. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  106543. */
  106544. onBeforeParticlesRenderingObservable: Observable<Scene>;
  106545. /**
  106546. * An event triggered when particles rendering is done
  106547. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  106548. */
  106549. onAfterParticlesRenderingObservable: Observable<Scene>;
  106550. /**
  106551. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  106552. */
  106553. onDataLoadedObservable: Observable<Scene>;
  106554. /**
  106555. * An event triggered when a camera is created
  106556. */
  106557. onNewCameraAddedObservable: Observable<Camera>;
  106558. /**
  106559. * An event triggered when a camera is removed
  106560. */
  106561. onCameraRemovedObservable: Observable<Camera>;
  106562. /**
  106563. * An event triggered when a light is created
  106564. */
  106565. onNewLightAddedObservable: Observable<Light>;
  106566. /**
  106567. * An event triggered when a light is removed
  106568. */
  106569. onLightRemovedObservable: Observable<Light>;
  106570. /**
  106571. * An event triggered when a geometry is created
  106572. */
  106573. onNewGeometryAddedObservable: Observable<Geometry>;
  106574. /**
  106575. * An event triggered when a geometry is removed
  106576. */
  106577. onGeometryRemovedObservable: Observable<Geometry>;
  106578. /**
  106579. * An event triggered when a transform node is created
  106580. */
  106581. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  106582. /**
  106583. * An event triggered when a transform node is removed
  106584. */
  106585. onTransformNodeRemovedObservable: Observable<TransformNode>;
  106586. /**
  106587. * An event triggered when a mesh is created
  106588. */
  106589. onNewMeshAddedObservable: Observable<AbstractMesh>;
  106590. /**
  106591. * An event triggered when a mesh is removed
  106592. */
  106593. onMeshRemovedObservable: Observable<AbstractMesh>;
  106594. /**
  106595. * An event triggered when a skeleton is created
  106596. */
  106597. onNewSkeletonAddedObservable: Observable<Skeleton>;
  106598. /**
  106599. * An event triggered when a skeleton is removed
  106600. */
  106601. onSkeletonRemovedObservable: Observable<Skeleton>;
  106602. /**
  106603. * An event triggered when a material is created
  106604. */
  106605. onNewMaterialAddedObservable: Observable<Material>;
  106606. /**
  106607. * An event triggered when a material is removed
  106608. */
  106609. onMaterialRemovedObservable: Observable<Material>;
  106610. /**
  106611. * An event triggered when a texture is created
  106612. */
  106613. onNewTextureAddedObservable: Observable<BaseTexture>;
  106614. /**
  106615. * An event triggered when a texture is removed
  106616. */
  106617. onTextureRemovedObservable: Observable<BaseTexture>;
  106618. /**
  106619. * An event triggered when render targets are about to be rendered
  106620. * Can happen multiple times per frame.
  106621. */
  106622. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  106623. /**
  106624. * An event triggered when render targets were rendered.
  106625. * Can happen multiple times per frame.
  106626. */
  106627. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  106628. /**
  106629. * An event triggered before calculating deterministic simulation step
  106630. */
  106631. onBeforeStepObservable: Observable<Scene>;
  106632. /**
  106633. * An event triggered after calculating deterministic simulation step
  106634. */
  106635. onAfterStepObservable: Observable<Scene>;
  106636. /**
  106637. * An event triggered when the activeCamera property is updated
  106638. */
  106639. onActiveCameraChanged: Observable<Scene>;
  106640. /**
  106641. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  106642. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  106643. * 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)
  106644. */
  106645. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  106646. /**
  106647. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  106648. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  106649. * 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)
  106650. */
  106651. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  106652. /**
  106653. * This Observable will when a mesh has been imported into the scene.
  106654. */
  106655. onMeshImportedObservable: Observable<AbstractMesh>;
  106656. /**
  106657. * This Observable will when an animation file has been imported into the scene.
  106658. */
  106659. onAnimationFileImportedObservable: Observable<Scene>;
  106660. /**
  106661. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  106662. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  106663. */
  106664. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  106665. /** @hidden */
  106666. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  106667. /**
  106668. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  106669. */
  106670. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  106671. /**
  106672. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  106673. */
  106674. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  106675. /**
  106676. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  106677. */
  106678. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  106679. /** Callback called when a pointer move is detected */
  106680. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  106681. /** Callback called when a pointer down is detected */
  106682. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  106683. /** Callback called when a pointer up is detected */
  106684. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  106685. /** Callback called when a pointer pick is detected */
  106686. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  106687. /**
  106688. * 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).
  106689. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  106690. */
  106691. onPrePointerObservable: Observable<PointerInfoPre>;
  106692. /**
  106693. * Observable event triggered each time an input event is received from the rendering canvas
  106694. */
  106695. onPointerObservable: Observable<PointerInfo>;
  106696. /**
  106697. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  106698. */
  106699. get unTranslatedPointer(): Vector2;
  106700. /**
  106701. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  106702. */
  106703. static get DragMovementThreshold(): number;
  106704. static set DragMovementThreshold(value: number);
  106705. /**
  106706. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  106707. */
  106708. static get LongPressDelay(): number;
  106709. static set LongPressDelay(value: number);
  106710. /**
  106711. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  106712. */
  106713. static get DoubleClickDelay(): number;
  106714. static set DoubleClickDelay(value: number);
  106715. /** If you need to check double click without raising a single click at first click, enable this flag */
  106716. static get ExclusiveDoubleClickMode(): boolean;
  106717. static set ExclusiveDoubleClickMode(value: boolean);
  106718. /** @hidden */
  106719. _mirroredCameraPosition: Nullable<Vector3>;
  106720. /**
  106721. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  106722. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  106723. */
  106724. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  106725. /**
  106726. * Observable event triggered each time an keyboard event is received from the hosting window
  106727. */
  106728. onKeyboardObservable: Observable<KeyboardInfo>;
  106729. private _useRightHandedSystem;
  106730. /**
  106731. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  106732. */
  106733. set useRightHandedSystem(value: boolean);
  106734. get useRightHandedSystem(): boolean;
  106735. private _timeAccumulator;
  106736. private _currentStepId;
  106737. private _currentInternalStep;
  106738. /**
  106739. * Sets the step Id used by deterministic lock step
  106740. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106741. * @param newStepId defines the step Id
  106742. */
  106743. setStepId(newStepId: number): void;
  106744. /**
  106745. * Gets the step Id used by deterministic lock step
  106746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106747. * @returns the step Id
  106748. */
  106749. getStepId(): number;
  106750. /**
  106751. * Gets the internal step used by deterministic lock step
  106752. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106753. * @returns the internal step
  106754. */
  106755. getInternalStep(): number;
  106756. private _fogEnabled;
  106757. /**
  106758. * Gets or sets a boolean indicating if fog is enabled on this scene
  106759. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106760. * (Default is true)
  106761. */
  106762. set fogEnabled(value: boolean);
  106763. get fogEnabled(): boolean;
  106764. private _fogMode;
  106765. /**
  106766. * Gets or sets the fog mode to use
  106767. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106768. * | mode | value |
  106769. * | --- | --- |
  106770. * | FOGMODE_NONE | 0 |
  106771. * | FOGMODE_EXP | 1 |
  106772. * | FOGMODE_EXP2 | 2 |
  106773. * | FOGMODE_LINEAR | 3 |
  106774. */
  106775. set fogMode(value: number);
  106776. get fogMode(): number;
  106777. /**
  106778. * Gets or sets the fog color to use
  106779. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106780. * (Default is Color3(0.2, 0.2, 0.3))
  106781. */
  106782. fogColor: Color3;
  106783. /**
  106784. * Gets or sets the fog density to use
  106785. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106786. * (Default is 0.1)
  106787. */
  106788. fogDensity: number;
  106789. /**
  106790. * Gets or sets the fog start distance to use
  106791. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106792. * (Default is 0)
  106793. */
  106794. fogStart: number;
  106795. /**
  106796. * Gets or sets the fog end distance to use
  106797. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106798. * (Default is 1000)
  106799. */
  106800. fogEnd: number;
  106801. private _shadowsEnabled;
  106802. /**
  106803. * Gets or sets a boolean indicating if shadows are enabled on this scene
  106804. */
  106805. set shadowsEnabled(value: boolean);
  106806. get shadowsEnabled(): boolean;
  106807. private _lightsEnabled;
  106808. /**
  106809. * Gets or sets a boolean indicating if lights are enabled on this scene
  106810. */
  106811. set lightsEnabled(value: boolean);
  106812. get lightsEnabled(): boolean;
  106813. /** All of the active cameras added to this scene. */
  106814. activeCameras: Camera[];
  106815. /** @hidden */
  106816. _activeCamera: Nullable<Camera>;
  106817. /** Gets or sets the current active camera */
  106818. get activeCamera(): Nullable<Camera>;
  106819. set activeCamera(value: Nullable<Camera>);
  106820. private _defaultMaterial;
  106821. /** The default material used on meshes when no material is affected */
  106822. get defaultMaterial(): Material;
  106823. /** The default material used on meshes when no material is affected */
  106824. set defaultMaterial(value: Material);
  106825. private _texturesEnabled;
  106826. /**
  106827. * Gets or sets a boolean indicating if textures are enabled on this scene
  106828. */
  106829. set texturesEnabled(value: boolean);
  106830. get texturesEnabled(): boolean;
  106831. /**
  106832. * Gets or sets a boolean indicating if particles are enabled on this scene
  106833. */
  106834. particlesEnabled: boolean;
  106835. /**
  106836. * Gets or sets a boolean indicating if sprites are enabled on this scene
  106837. */
  106838. spritesEnabled: boolean;
  106839. private _skeletonsEnabled;
  106840. /**
  106841. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  106842. */
  106843. set skeletonsEnabled(value: boolean);
  106844. get skeletonsEnabled(): boolean;
  106845. /**
  106846. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  106847. */
  106848. lensFlaresEnabled: boolean;
  106849. /**
  106850. * Gets or sets a boolean indicating if collisions are enabled on this scene
  106851. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106852. */
  106853. collisionsEnabled: boolean;
  106854. private _collisionCoordinator;
  106855. /** @hidden */
  106856. get collisionCoordinator(): ICollisionCoordinator;
  106857. /**
  106858. * Defines the gravity applied to this scene (used only for collisions)
  106859. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106860. */
  106861. gravity: Vector3;
  106862. /**
  106863. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  106864. */
  106865. postProcessesEnabled: boolean;
  106866. /**
  106867. * The list of postprocesses added to the scene
  106868. */
  106869. postProcesses: PostProcess[];
  106870. /**
  106871. * Gets the current postprocess manager
  106872. */
  106873. postProcessManager: PostProcessManager;
  106874. /**
  106875. * Gets or sets a boolean indicating if render targets are enabled on this scene
  106876. */
  106877. renderTargetsEnabled: boolean;
  106878. /**
  106879. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  106880. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  106881. */
  106882. dumpNextRenderTargets: boolean;
  106883. /**
  106884. * The list of user defined render targets added to the scene
  106885. */
  106886. customRenderTargets: RenderTargetTexture[];
  106887. /**
  106888. * Defines if texture loading must be delayed
  106889. * If true, textures will only be loaded when they need to be rendered
  106890. */
  106891. useDelayedTextureLoading: boolean;
  106892. /**
  106893. * Gets the list of meshes imported to the scene through SceneLoader
  106894. */
  106895. importedMeshesFiles: String[];
  106896. /**
  106897. * Gets or sets a boolean indicating if probes are enabled on this scene
  106898. */
  106899. probesEnabled: boolean;
  106900. /**
  106901. * Gets or sets the current offline provider to use to store scene data
  106902. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106903. */
  106904. offlineProvider: IOfflineProvider;
  106905. /**
  106906. * Gets or sets the action manager associated with the scene
  106907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106908. */
  106909. actionManager: AbstractActionManager;
  106910. private _meshesForIntersections;
  106911. /**
  106912. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  106913. */
  106914. proceduralTexturesEnabled: boolean;
  106915. private _engine;
  106916. private _totalVertices;
  106917. /** @hidden */
  106918. _activeIndices: PerfCounter;
  106919. /** @hidden */
  106920. _activeParticles: PerfCounter;
  106921. /** @hidden */
  106922. _activeBones: PerfCounter;
  106923. private _animationRatio;
  106924. /** @hidden */
  106925. _animationTimeLast: number;
  106926. /** @hidden */
  106927. _animationTime: number;
  106928. /**
  106929. * Gets or sets a general scale for animation speed
  106930. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  106931. */
  106932. animationTimeScale: number;
  106933. /** @hidden */
  106934. _cachedMaterial: Nullable<Material>;
  106935. /** @hidden */
  106936. _cachedEffect: Nullable<Effect>;
  106937. /** @hidden */
  106938. _cachedVisibility: Nullable<number>;
  106939. private _renderId;
  106940. private _frameId;
  106941. private _executeWhenReadyTimeoutId;
  106942. private _intermediateRendering;
  106943. private _viewUpdateFlag;
  106944. private _projectionUpdateFlag;
  106945. /** @hidden */
  106946. _toBeDisposed: Nullable<IDisposable>[];
  106947. private _activeRequests;
  106948. /** @hidden */
  106949. _pendingData: any[];
  106950. private _isDisposed;
  106951. /**
  106952. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  106953. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  106954. */
  106955. dispatchAllSubMeshesOfActiveMeshes: boolean;
  106956. private _activeMeshes;
  106957. private _processedMaterials;
  106958. private _renderTargets;
  106959. /** @hidden */
  106960. _activeParticleSystems: SmartArray<IParticleSystem>;
  106961. private _activeSkeletons;
  106962. private _softwareSkinnedMeshes;
  106963. private _renderingManager;
  106964. /** @hidden */
  106965. _activeAnimatables: Animatable[];
  106966. private _transformMatrix;
  106967. private _sceneUbo;
  106968. /** @hidden */
  106969. _viewMatrix: Matrix;
  106970. private _projectionMatrix;
  106971. /** @hidden */
  106972. _forcedViewPosition: Nullable<Vector3>;
  106973. /** @hidden */
  106974. _frustumPlanes: Plane[];
  106975. /**
  106976. * Gets the list of frustum planes (built from the active camera)
  106977. */
  106978. get frustumPlanes(): Plane[];
  106979. /**
  106980. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  106981. * This is useful if there are more lights that the maximum simulteanous authorized
  106982. */
  106983. requireLightSorting: boolean;
  106984. /** @hidden */
  106985. readonly useMaterialMeshMap: boolean;
  106986. /** @hidden */
  106987. readonly useClonedMeshMap: boolean;
  106988. private _externalData;
  106989. private _uid;
  106990. /**
  106991. * @hidden
  106992. * Backing store of defined scene components.
  106993. */
  106994. _components: ISceneComponent[];
  106995. /**
  106996. * @hidden
  106997. * Backing store of defined scene components.
  106998. */
  106999. _serializableComponents: ISceneSerializableComponent[];
  107000. /**
  107001. * List of components to register on the next registration step.
  107002. */
  107003. private _transientComponents;
  107004. /**
  107005. * Registers the transient components if needed.
  107006. */
  107007. private _registerTransientComponents;
  107008. /**
  107009. * @hidden
  107010. * Add a component to the scene.
  107011. * Note that the ccomponent could be registered on th next frame if this is called after
  107012. * the register component stage.
  107013. * @param component Defines the component to add to the scene
  107014. */
  107015. _addComponent(component: ISceneComponent): void;
  107016. /**
  107017. * @hidden
  107018. * Gets a component from the scene.
  107019. * @param name defines the name of the component to retrieve
  107020. * @returns the component or null if not present
  107021. */
  107022. _getComponent(name: string): Nullable<ISceneComponent>;
  107023. /**
  107024. * @hidden
  107025. * Defines the actions happening before camera updates.
  107026. */
  107027. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  107028. /**
  107029. * @hidden
  107030. * Defines the actions happening before clear the canvas.
  107031. */
  107032. _beforeClearStage: Stage<SimpleStageAction>;
  107033. /**
  107034. * @hidden
  107035. * Defines the actions when collecting render targets for the frame.
  107036. */
  107037. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  107038. /**
  107039. * @hidden
  107040. * Defines the actions happening for one camera in the frame.
  107041. */
  107042. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  107043. /**
  107044. * @hidden
  107045. * Defines the actions happening during the per mesh ready checks.
  107046. */
  107047. _isReadyForMeshStage: Stage<MeshStageAction>;
  107048. /**
  107049. * @hidden
  107050. * Defines the actions happening before evaluate active mesh checks.
  107051. */
  107052. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  107053. /**
  107054. * @hidden
  107055. * Defines the actions happening during the evaluate sub mesh checks.
  107056. */
  107057. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  107058. /**
  107059. * @hidden
  107060. * Defines the actions happening during the active mesh stage.
  107061. */
  107062. _activeMeshStage: Stage<ActiveMeshStageAction>;
  107063. /**
  107064. * @hidden
  107065. * Defines the actions happening during the per camera render target step.
  107066. */
  107067. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  107068. /**
  107069. * @hidden
  107070. * Defines the actions happening just before the active camera is drawing.
  107071. */
  107072. _beforeCameraDrawStage: Stage<CameraStageAction>;
  107073. /**
  107074. * @hidden
  107075. * Defines the actions happening just before a render target is drawing.
  107076. */
  107077. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  107078. /**
  107079. * @hidden
  107080. * Defines the actions happening just before a rendering group is drawing.
  107081. */
  107082. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  107083. /**
  107084. * @hidden
  107085. * Defines the actions happening just before a mesh is drawing.
  107086. */
  107087. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  107088. /**
  107089. * @hidden
  107090. * Defines the actions happening just after a mesh has been drawn.
  107091. */
  107092. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  107093. /**
  107094. * @hidden
  107095. * Defines the actions happening just after a rendering group has been drawn.
  107096. */
  107097. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  107098. /**
  107099. * @hidden
  107100. * Defines the actions happening just after the active camera has been drawn.
  107101. */
  107102. _afterCameraDrawStage: Stage<CameraStageAction>;
  107103. /**
  107104. * @hidden
  107105. * Defines the actions happening just after a render target has been drawn.
  107106. */
  107107. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  107108. /**
  107109. * @hidden
  107110. * Defines the actions happening just after rendering all cameras and computing intersections.
  107111. */
  107112. _afterRenderStage: Stage<SimpleStageAction>;
  107113. /**
  107114. * @hidden
  107115. * Defines the actions happening when a pointer move event happens.
  107116. */
  107117. _pointerMoveStage: Stage<PointerMoveStageAction>;
  107118. /**
  107119. * @hidden
  107120. * Defines the actions happening when a pointer down event happens.
  107121. */
  107122. _pointerDownStage: Stage<PointerUpDownStageAction>;
  107123. /**
  107124. * @hidden
  107125. * Defines the actions happening when a pointer up event happens.
  107126. */
  107127. _pointerUpStage: Stage<PointerUpDownStageAction>;
  107128. /**
  107129. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  107130. */
  107131. private geometriesByUniqueId;
  107132. /**
  107133. * Creates a new Scene
  107134. * @param engine defines the engine to use to render this scene
  107135. * @param options defines the scene options
  107136. */
  107137. constructor(engine: Engine, options?: SceneOptions);
  107138. /**
  107139. * Gets a string idenfifying the name of the class
  107140. * @returns "Scene" string
  107141. */
  107142. getClassName(): string;
  107143. private _defaultMeshCandidates;
  107144. /**
  107145. * @hidden
  107146. */
  107147. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  107148. private _defaultSubMeshCandidates;
  107149. /**
  107150. * @hidden
  107151. */
  107152. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  107153. /**
  107154. * Sets the default candidate providers for the scene.
  107155. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  107156. * and getCollidingSubMeshCandidates to their default function
  107157. */
  107158. setDefaultCandidateProviders(): void;
  107159. /**
  107160. * Gets the mesh that is currently under the pointer
  107161. */
  107162. get meshUnderPointer(): Nullable<AbstractMesh>;
  107163. /**
  107164. * Gets or sets the current on-screen X position of the pointer
  107165. */
  107166. get pointerX(): number;
  107167. set pointerX(value: number);
  107168. /**
  107169. * Gets or sets the current on-screen Y position of the pointer
  107170. */
  107171. get pointerY(): number;
  107172. set pointerY(value: number);
  107173. /**
  107174. * Gets the cached material (ie. the latest rendered one)
  107175. * @returns the cached material
  107176. */
  107177. getCachedMaterial(): Nullable<Material>;
  107178. /**
  107179. * Gets the cached effect (ie. the latest rendered one)
  107180. * @returns the cached effect
  107181. */
  107182. getCachedEffect(): Nullable<Effect>;
  107183. /**
  107184. * Gets the cached visibility state (ie. the latest rendered one)
  107185. * @returns the cached visibility state
  107186. */
  107187. getCachedVisibility(): Nullable<number>;
  107188. /**
  107189. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  107190. * @param material defines the current material
  107191. * @param effect defines the current effect
  107192. * @param visibility defines the current visibility state
  107193. * @returns true if one parameter is not cached
  107194. */
  107195. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  107196. /**
  107197. * Gets the engine associated with the scene
  107198. * @returns an Engine
  107199. */
  107200. getEngine(): Engine;
  107201. /**
  107202. * Gets the total number of vertices rendered per frame
  107203. * @returns the total number of vertices rendered per frame
  107204. */
  107205. getTotalVertices(): number;
  107206. /**
  107207. * Gets the performance counter for total vertices
  107208. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  107209. */
  107210. get totalVerticesPerfCounter(): PerfCounter;
  107211. /**
  107212. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  107213. * @returns the total number of active indices rendered per frame
  107214. */
  107215. getActiveIndices(): number;
  107216. /**
  107217. * Gets the performance counter for active indices
  107218. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  107219. */
  107220. get totalActiveIndicesPerfCounter(): PerfCounter;
  107221. /**
  107222. * Gets the total number of active particles rendered per frame
  107223. * @returns the total number of active particles rendered per frame
  107224. */
  107225. getActiveParticles(): number;
  107226. /**
  107227. * Gets the performance counter for active particles
  107228. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  107229. */
  107230. get activeParticlesPerfCounter(): PerfCounter;
  107231. /**
  107232. * Gets the total number of active bones rendered per frame
  107233. * @returns the total number of active bones rendered per frame
  107234. */
  107235. getActiveBones(): number;
  107236. /**
  107237. * Gets the performance counter for active bones
  107238. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  107239. */
  107240. get activeBonesPerfCounter(): PerfCounter;
  107241. /**
  107242. * Gets the array of active meshes
  107243. * @returns an array of AbstractMesh
  107244. */
  107245. getActiveMeshes(): SmartArray<AbstractMesh>;
  107246. /**
  107247. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  107248. * @returns a number
  107249. */
  107250. getAnimationRatio(): number;
  107251. /**
  107252. * Gets an unique Id for the current render phase
  107253. * @returns a number
  107254. */
  107255. getRenderId(): number;
  107256. /**
  107257. * Gets an unique Id for the current frame
  107258. * @returns a number
  107259. */
  107260. getFrameId(): number;
  107261. /** Call this function if you want to manually increment the render Id*/
  107262. incrementRenderId(): void;
  107263. private _createUbo;
  107264. /**
  107265. * Use this method to simulate a pointer move on a mesh
  107266. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107267. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107268. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107269. * @returns the current scene
  107270. */
  107271. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  107272. /**
  107273. * Use this method to simulate a pointer down on a mesh
  107274. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107275. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107276. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107277. * @returns the current scene
  107278. */
  107279. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  107280. /**
  107281. * Use this method to simulate a pointer up on a mesh
  107282. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107283. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107284. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107285. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107286. * @returns the current scene
  107287. */
  107288. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  107289. /**
  107290. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107291. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107292. * @returns true if the pointer was captured
  107293. */
  107294. isPointerCaptured(pointerId?: number): boolean;
  107295. /**
  107296. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107297. * @param attachUp defines if you want to attach events to pointerup
  107298. * @param attachDown defines if you want to attach events to pointerdown
  107299. * @param attachMove defines if you want to attach events to pointermove
  107300. */
  107301. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  107302. /** Detaches all event handlers*/
  107303. detachControl(): void;
  107304. /**
  107305. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  107306. * Delay loaded resources are not taking in account
  107307. * @return true if all required resources are ready
  107308. */
  107309. isReady(): boolean;
  107310. /** Resets all cached information relative to material (including effect and visibility) */
  107311. resetCachedMaterial(): void;
  107312. /**
  107313. * Registers a function to be called before every frame render
  107314. * @param func defines the function to register
  107315. */
  107316. registerBeforeRender(func: () => void): void;
  107317. /**
  107318. * Unregisters a function called before every frame render
  107319. * @param func defines the function to unregister
  107320. */
  107321. unregisterBeforeRender(func: () => void): void;
  107322. /**
  107323. * Registers a function to be called after every frame render
  107324. * @param func defines the function to register
  107325. */
  107326. registerAfterRender(func: () => void): void;
  107327. /**
  107328. * Unregisters a function called after every frame render
  107329. * @param func defines the function to unregister
  107330. */
  107331. unregisterAfterRender(func: () => void): void;
  107332. private _executeOnceBeforeRender;
  107333. /**
  107334. * The provided function will run before render once and will be disposed afterwards.
  107335. * A timeout delay can be provided so that the function will be executed in N ms.
  107336. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  107337. * @param func The function to be executed.
  107338. * @param timeout optional delay in ms
  107339. */
  107340. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  107341. /** @hidden */
  107342. _addPendingData(data: any): void;
  107343. /** @hidden */
  107344. _removePendingData(data: any): void;
  107345. /**
  107346. * Returns the number of items waiting to be loaded
  107347. * @returns the number of items waiting to be loaded
  107348. */
  107349. getWaitingItemsCount(): number;
  107350. /**
  107351. * Returns a boolean indicating if the scene is still loading data
  107352. */
  107353. get isLoading(): boolean;
  107354. /**
  107355. * Registers a function to be executed when the scene is ready
  107356. * @param {Function} func - the function to be executed
  107357. */
  107358. executeWhenReady(func: () => void): void;
  107359. /**
  107360. * Returns a promise that resolves when the scene is ready
  107361. * @returns A promise that resolves when the scene is ready
  107362. */
  107363. whenReadyAsync(): Promise<void>;
  107364. /** @hidden */
  107365. _checkIsReady(): void;
  107366. /**
  107367. * Gets all animatable attached to the scene
  107368. */
  107369. get animatables(): Animatable[];
  107370. /**
  107371. * Resets the last animation time frame.
  107372. * Useful to override when animations start running when loading a scene for the first time.
  107373. */
  107374. resetLastAnimationTimeFrame(): void;
  107375. /**
  107376. * Gets the current view matrix
  107377. * @returns a Matrix
  107378. */
  107379. getViewMatrix(): Matrix;
  107380. /**
  107381. * Gets the current projection matrix
  107382. * @returns a Matrix
  107383. */
  107384. getProjectionMatrix(): Matrix;
  107385. /**
  107386. * Gets the current transform matrix
  107387. * @returns a Matrix made of View * Projection
  107388. */
  107389. getTransformMatrix(): Matrix;
  107390. /**
  107391. * Sets the current transform matrix
  107392. * @param viewL defines the View matrix to use
  107393. * @param projectionL defines the Projection matrix to use
  107394. * @param viewR defines the right View matrix to use (if provided)
  107395. * @param projectionR defines the right Projection matrix to use (if provided)
  107396. */
  107397. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  107398. /**
  107399. * Gets the uniform buffer used to store scene data
  107400. * @returns a UniformBuffer
  107401. */
  107402. getSceneUniformBuffer(): UniformBuffer;
  107403. /**
  107404. * Gets an unique (relatively to the current scene) Id
  107405. * @returns an unique number for the scene
  107406. */
  107407. getUniqueId(): number;
  107408. /**
  107409. * Add a mesh to the list of scene's meshes
  107410. * @param newMesh defines the mesh to add
  107411. * @param recursive if all child meshes should also be added to the scene
  107412. */
  107413. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  107414. /**
  107415. * Remove a mesh for the list of scene's meshes
  107416. * @param toRemove defines the mesh to remove
  107417. * @param recursive if all child meshes should also be removed from the scene
  107418. * @returns the index where the mesh was in the mesh list
  107419. */
  107420. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  107421. /**
  107422. * Add a transform node to the list of scene's transform nodes
  107423. * @param newTransformNode defines the transform node to add
  107424. */
  107425. addTransformNode(newTransformNode: TransformNode): void;
  107426. /**
  107427. * Remove a transform node for the list of scene's transform nodes
  107428. * @param toRemove defines the transform node to remove
  107429. * @returns the index where the transform node was in the transform node list
  107430. */
  107431. removeTransformNode(toRemove: TransformNode): number;
  107432. /**
  107433. * Remove a skeleton for the list of scene's skeletons
  107434. * @param toRemove defines the skeleton to remove
  107435. * @returns the index where the skeleton was in the skeleton list
  107436. */
  107437. removeSkeleton(toRemove: Skeleton): number;
  107438. /**
  107439. * Remove a morph target for the list of scene's morph targets
  107440. * @param toRemove defines the morph target to remove
  107441. * @returns the index where the morph target was in the morph target list
  107442. */
  107443. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  107444. /**
  107445. * Remove a light for the list of scene's lights
  107446. * @param toRemove defines the light to remove
  107447. * @returns the index where the light was in the light list
  107448. */
  107449. removeLight(toRemove: Light): number;
  107450. /**
  107451. * Remove a camera for the list of scene's cameras
  107452. * @param toRemove defines the camera to remove
  107453. * @returns the index where the camera was in the camera list
  107454. */
  107455. removeCamera(toRemove: Camera): number;
  107456. /**
  107457. * Remove a particle system for the list of scene's particle systems
  107458. * @param toRemove defines the particle system to remove
  107459. * @returns the index where the particle system was in the particle system list
  107460. */
  107461. removeParticleSystem(toRemove: IParticleSystem): number;
  107462. /**
  107463. * Remove a animation for the list of scene's animations
  107464. * @param toRemove defines the animation to remove
  107465. * @returns the index where the animation was in the animation list
  107466. */
  107467. removeAnimation(toRemove: Animation): number;
  107468. /**
  107469. * Will stop the animation of the given target
  107470. * @param target - the target
  107471. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  107472. * @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)
  107473. */
  107474. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  107475. /**
  107476. * Removes the given animation group from this scene.
  107477. * @param toRemove The animation group to remove
  107478. * @returns The index of the removed animation group
  107479. */
  107480. removeAnimationGroup(toRemove: AnimationGroup): number;
  107481. /**
  107482. * Removes the given multi-material from this scene.
  107483. * @param toRemove The multi-material to remove
  107484. * @returns The index of the removed multi-material
  107485. */
  107486. removeMultiMaterial(toRemove: MultiMaterial): number;
  107487. /**
  107488. * Removes the given material from this scene.
  107489. * @param toRemove The material to remove
  107490. * @returns The index of the removed material
  107491. */
  107492. removeMaterial(toRemove: Material): number;
  107493. /**
  107494. * Removes the given action manager from this scene.
  107495. * @param toRemove The action manager to remove
  107496. * @returns The index of the removed action manager
  107497. */
  107498. removeActionManager(toRemove: AbstractActionManager): number;
  107499. /**
  107500. * Removes the given texture from this scene.
  107501. * @param toRemove The texture to remove
  107502. * @returns The index of the removed texture
  107503. */
  107504. removeTexture(toRemove: BaseTexture): number;
  107505. /**
  107506. * Adds the given light to this scene
  107507. * @param newLight The light to add
  107508. */
  107509. addLight(newLight: Light): void;
  107510. /**
  107511. * Sorts the list list based on light priorities
  107512. */
  107513. sortLightsByPriority(): void;
  107514. /**
  107515. * Adds the given camera to this scene
  107516. * @param newCamera The camera to add
  107517. */
  107518. addCamera(newCamera: Camera): void;
  107519. /**
  107520. * Adds the given skeleton to this scene
  107521. * @param newSkeleton The skeleton to add
  107522. */
  107523. addSkeleton(newSkeleton: Skeleton): void;
  107524. /**
  107525. * Adds the given particle system to this scene
  107526. * @param newParticleSystem The particle system to add
  107527. */
  107528. addParticleSystem(newParticleSystem: IParticleSystem): void;
  107529. /**
  107530. * Adds the given animation to this scene
  107531. * @param newAnimation The animation to add
  107532. */
  107533. addAnimation(newAnimation: Animation): void;
  107534. /**
  107535. * Adds the given animation group to this scene.
  107536. * @param newAnimationGroup The animation group to add
  107537. */
  107538. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  107539. /**
  107540. * Adds the given multi-material to this scene
  107541. * @param newMultiMaterial The multi-material to add
  107542. */
  107543. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  107544. /**
  107545. * Adds the given material to this scene
  107546. * @param newMaterial The material to add
  107547. */
  107548. addMaterial(newMaterial: Material): void;
  107549. /**
  107550. * Adds the given morph target to this scene
  107551. * @param newMorphTargetManager The morph target to add
  107552. */
  107553. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  107554. /**
  107555. * Adds the given geometry to this scene
  107556. * @param newGeometry The geometry to add
  107557. */
  107558. addGeometry(newGeometry: Geometry): void;
  107559. /**
  107560. * Adds the given action manager to this scene
  107561. * @param newActionManager The action manager to add
  107562. */
  107563. addActionManager(newActionManager: AbstractActionManager): void;
  107564. /**
  107565. * Adds the given texture to this scene.
  107566. * @param newTexture The texture to add
  107567. */
  107568. addTexture(newTexture: BaseTexture): void;
  107569. /**
  107570. * Switch active camera
  107571. * @param newCamera defines the new active camera
  107572. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  107573. */
  107574. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  107575. /**
  107576. * sets the active camera of the scene using its ID
  107577. * @param id defines the camera's ID
  107578. * @return the new active camera or null if none found.
  107579. */
  107580. setActiveCameraByID(id: string): Nullable<Camera>;
  107581. /**
  107582. * sets the active camera of the scene using its name
  107583. * @param name defines the camera's name
  107584. * @returns the new active camera or null if none found.
  107585. */
  107586. setActiveCameraByName(name: string): Nullable<Camera>;
  107587. /**
  107588. * get an animation group using its name
  107589. * @param name defines the material's name
  107590. * @return the animation group or null if none found.
  107591. */
  107592. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  107593. /**
  107594. * Get a material using its unique id
  107595. * @param uniqueId defines the material's unique id
  107596. * @return the material or null if none found.
  107597. */
  107598. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  107599. /**
  107600. * get a material using its id
  107601. * @param id defines the material's ID
  107602. * @return the material or null if none found.
  107603. */
  107604. getMaterialByID(id: string): Nullable<Material>;
  107605. /**
  107606. * Gets a the last added material using a given id
  107607. * @param id defines the material's ID
  107608. * @return the last material with the given id or null if none found.
  107609. */
  107610. getLastMaterialByID(id: string): Nullable<Material>;
  107611. /**
  107612. * Gets a material using its name
  107613. * @param name defines the material's name
  107614. * @return the material or null if none found.
  107615. */
  107616. getMaterialByName(name: string): Nullable<Material>;
  107617. /**
  107618. * Get a texture using its unique id
  107619. * @param uniqueId defines the texture's unique id
  107620. * @return the texture or null if none found.
  107621. */
  107622. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  107623. /**
  107624. * Gets a camera using its id
  107625. * @param id defines the id to look for
  107626. * @returns the camera or null if not found
  107627. */
  107628. getCameraByID(id: string): Nullable<Camera>;
  107629. /**
  107630. * Gets a camera using its unique id
  107631. * @param uniqueId defines the unique id to look for
  107632. * @returns the camera or null if not found
  107633. */
  107634. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  107635. /**
  107636. * Gets a camera using its name
  107637. * @param name defines the camera's name
  107638. * @return the camera or null if none found.
  107639. */
  107640. getCameraByName(name: string): Nullable<Camera>;
  107641. /**
  107642. * Gets a bone using its id
  107643. * @param id defines the bone's id
  107644. * @return the bone or null if not found
  107645. */
  107646. getBoneByID(id: string): Nullable<Bone>;
  107647. /**
  107648. * Gets a bone using its id
  107649. * @param name defines the bone's name
  107650. * @return the bone or null if not found
  107651. */
  107652. getBoneByName(name: string): Nullable<Bone>;
  107653. /**
  107654. * Gets a light node using its name
  107655. * @param name defines the the light's name
  107656. * @return the light or null if none found.
  107657. */
  107658. getLightByName(name: string): Nullable<Light>;
  107659. /**
  107660. * Gets a light node using its id
  107661. * @param id defines the light's id
  107662. * @return the light or null if none found.
  107663. */
  107664. getLightByID(id: string): Nullable<Light>;
  107665. /**
  107666. * Gets a light node using its scene-generated unique ID
  107667. * @param uniqueId defines the light's unique id
  107668. * @return the light or null if none found.
  107669. */
  107670. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  107671. /**
  107672. * Gets a particle system by id
  107673. * @param id defines the particle system id
  107674. * @return the corresponding system or null if none found
  107675. */
  107676. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  107677. /**
  107678. * Gets a geometry using its ID
  107679. * @param id defines the geometry's id
  107680. * @return the geometry or null if none found.
  107681. */
  107682. getGeometryByID(id: string): Nullable<Geometry>;
  107683. private _getGeometryByUniqueID;
  107684. /**
  107685. * Add a new geometry to this scene
  107686. * @param geometry defines the geometry to be added to the scene.
  107687. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  107688. * @return a boolean defining if the geometry was added or not
  107689. */
  107690. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  107691. /**
  107692. * Removes an existing geometry
  107693. * @param geometry defines the geometry to be removed from the scene
  107694. * @return a boolean defining if the geometry was removed or not
  107695. */
  107696. removeGeometry(geometry: Geometry): boolean;
  107697. /**
  107698. * Gets the list of geometries attached to the scene
  107699. * @returns an array of Geometry
  107700. */
  107701. getGeometries(): Geometry[];
  107702. /**
  107703. * Gets the first added mesh found of a given ID
  107704. * @param id defines the id to search for
  107705. * @return the mesh found or null if not found at all
  107706. */
  107707. getMeshByID(id: string): Nullable<AbstractMesh>;
  107708. /**
  107709. * Gets a list of meshes using their id
  107710. * @param id defines the id to search for
  107711. * @returns a list of meshes
  107712. */
  107713. getMeshesByID(id: string): Array<AbstractMesh>;
  107714. /**
  107715. * Gets the first added transform node found of a given ID
  107716. * @param id defines the id to search for
  107717. * @return the found transform node or null if not found at all.
  107718. */
  107719. getTransformNodeByID(id: string): Nullable<TransformNode>;
  107720. /**
  107721. * Gets a transform node with its auto-generated unique id
  107722. * @param uniqueId efines the unique id to search for
  107723. * @return the found transform node or null if not found at all.
  107724. */
  107725. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  107726. /**
  107727. * Gets a list of transform nodes using their id
  107728. * @param id defines the id to search for
  107729. * @returns a list of transform nodes
  107730. */
  107731. getTransformNodesByID(id: string): Array<TransformNode>;
  107732. /**
  107733. * Gets a mesh with its auto-generated unique id
  107734. * @param uniqueId defines the unique id to search for
  107735. * @return the found mesh or null if not found at all.
  107736. */
  107737. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  107738. /**
  107739. * Gets a the last added mesh using a given id
  107740. * @param id defines the id to search for
  107741. * @return the found mesh or null if not found at all.
  107742. */
  107743. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  107744. /**
  107745. * Gets a the last added node (Mesh, Camera, Light) using a given id
  107746. * @param id defines the id to search for
  107747. * @return the found node or null if not found at all
  107748. */
  107749. getLastEntryByID(id: string): Nullable<Node>;
  107750. /**
  107751. * Gets a node (Mesh, Camera, Light) using a given id
  107752. * @param id defines the id to search for
  107753. * @return the found node or null if not found at all
  107754. */
  107755. getNodeByID(id: string): Nullable<Node>;
  107756. /**
  107757. * Gets a node (Mesh, Camera, Light) using a given name
  107758. * @param name defines the name to search for
  107759. * @return the found node or null if not found at all.
  107760. */
  107761. getNodeByName(name: string): Nullable<Node>;
  107762. /**
  107763. * Gets a mesh using a given name
  107764. * @param name defines the name to search for
  107765. * @return the found mesh or null if not found at all.
  107766. */
  107767. getMeshByName(name: string): Nullable<AbstractMesh>;
  107768. /**
  107769. * Gets a transform node using a given name
  107770. * @param name defines the name to search for
  107771. * @return the found transform node or null if not found at all.
  107772. */
  107773. getTransformNodeByName(name: string): Nullable<TransformNode>;
  107774. /**
  107775. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  107776. * @param id defines the id to search for
  107777. * @return the found skeleton or null if not found at all.
  107778. */
  107779. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  107780. /**
  107781. * Gets a skeleton using a given auto generated unique id
  107782. * @param uniqueId defines the unique id to search for
  107783. * @return the found skeleton or null if not found at all.
  107784. */
  107785. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  107786. /**
  107787. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  107788. * @param id defines the id to search for
  107789. * @return the found skeleton or null if not found at all.
  107790. */
  107791. getSkeletonById(id: string): Nullable<Skeleton>;
  107792. /**
  107793. * Gets a skeleton using a given name
  107794. * @param name defines the name to search for
  107795. * @return the found skeleton or null if not found at all.
  107796. */
  107797. getSkeletonByName(name: string): Nullable<Skeleton>;
  107798. /**
  107799. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  107800. * @param id defines the id to search for
  107801. * @return the found morph target manager or null if not found at all.
  107802. */
  107803. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  107804. /**
  107805. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  107806. * @param id defines the id to search for
  107807. * @return the found morph target or null if not found at all.
  107808. */
  107809. getMorphTargetById(id: string): Nullable<MorphTarget>;
  107810. /**
  107811. * Gets a boolean indicating if the given mesh is active
  107812. * @param mesh defines the mesh to look for
  107813. * @returns true if the mesh is in the active list
  107814. */
  107815. isActiveMesh(mesh: AbstractMesh): boolean;
  107816. /**
  107817. * Return a unique id as a string which can serve as an identifier for the scene
  107818. */
  107819. get uid(): string;
  107820. /**
  107821. * Add an externaly attached data from its key.
  107822. * This method call will fail and return false, if such key already exists.
  107823. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  107824. * @param key the unique key that identifies the data
  107825. * @param data the data object to associate to the key for this Engine instance
  107826. * @return true if no such key were already present and the data was added successfully, false otherwise
  107827. */
  107828. addExternalData<T>(key: string, data: T): boolean;
  107829. /**
  107830. * Get an externaly attached data from its key
  107831. * @param key the unique key that identifies the data
  107832. * @return the associated data, if present (can be null), or undefined if not present
  107833. */
  107834. getExternalData<T>(key: string): Nullable<T>;
  107835. /**
  107836. * Get an externaly attached data from its key, create it using a factory if it's not already present
  107837. * @param key the unique key that identifies the data
  107838. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  107839. * @return the associated data, can be null if the factory returned null.
  107840. */
  107841. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  107842. /**
  107843. * Remove an externaly attached data from the Engine instance
  107844. * @param key the unique key that identifies the data
  107845. * @return true if the data was successfully removed, false if it doesn't exist
  107846. */
  107847. removeExternalData(key: string): boolean;
  107848. private _evaluateSubMesh;
  107849. /**
  107850. * Clear the processed materials smart array preventing retention point in material dispose.
  107851. */
  107852. freeProcessedMaterials(): void;
  107853. private _preventFreeActiveMeshesAndRenderingGroups;
  107854. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  107855. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  107856. * when disposing several meshes in a row or a hierarchy of meshes.
  107857. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  107858. */
  107859. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  107860. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  107861. /**
  107862. * Clear the active meshes smart array preventing retention point in mesh dispose.
  107863. */
  107864. freeActiveMeshes(): void;
  107865. /**
  107866. * Clear the info related to rendering groups preventing retention points during dispose.
  107867. */
  107868. freeRenderingGroups(): void;
  107869. /** @hidden */
  107870. _isInIntermediateRendering(): boolean;
  107871. /**
  107872. * Lambda returning the list of potentially active meshes.
  107873. */
  107874. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  107875. /**
  107876. * Lambda returning the list of potentially active sub meshes.
  107877. */
  107878. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  107879. /**
  107880. * Lambda returning the list of potentially intersecting sub meshes.
  107881. */
  107882. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  107883. /**
  107884. * Lambda returning the list of potentially colliding sub meshes.
  107885. */
  107886. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  107887. private _activeMeshesFrozen;
  107888. private _skipEvaluateActiveMeshesCompletely;
  107889. /**
  107890. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  107891. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  107892. * @returns the current scene
  107893. */
  107894. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  107895. /**
  107896. * Use this function to restart evaluating active meshes on every frame
  107897. * @returns the current scene
  107898. */
  107899. unfreezeActiveMeshes(): Scene;
  107900. private _evaluateActiveMeshes;
  107901. private _activeMesh;
  107902. /**
  107903. * Update the transform matrix to update from the current active camera
  107904. * @param force defines a boolean used to force the update even if cache is up to date
  107905. */
  107906. updateTransformMatrix(force?: boolean): void;
  107907. private _bindFrameBuffer;
  107908. /** @hidden */
  107909. _allowPostProcessClearColor: boolean;
  107910. /** @hidden */
  107911. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  107912. private _processSubCameras;
  107913. private _checkIntersections;
  107914. /** @hidden */
  107915. _advancePhysicsEngineStep(step: number): void;
  107916. /**
  107917. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  107918. */
  107919. getDeterministicFrameTime: () => number;
  107920. /** @hidden */
  107921. _animate(): void;
  107922. /** Execute all animations (for a frame) */
  107923. animate(): void;
  107924. /**
  107925. * Render the scene
  107926. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  107927. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  107928. */
  107929. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  107930. /**
  107931. * Freeze all materials
  107932. * A frozen material will not be updatable but should be faster to render
  107933. */
  107934. freezeMaterials(): void;
  107935. /**
  107936. * Unfreeze all materials
  107937. * A frozen material will not be updatable but should be faster to render
  107938. */
  107939. unfreezeMaterials(): void;
  107940. /**
  107941. * Releases all held ressources
  107942. */
  107943. dispose(): void;
  107944. /**
  107945. * Gets if the scene is already disposed
  107946. */
  107947. get isDisposed(): boolean;
  107948. /**
  107949. * Call this function to reduce memory footprint of the scene.
  107950. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  107951. */
  107952. clearCachedVertexData(): void;
  107953. /**
  107954. * This function will remove the local cached buffer data from texture.
  107955. * It will save memory but will prevent the texture from being rebuilt
  107956. */
  107957. cleanCachedTextureBuffer(): void;
  107958. /**
  107959. * Get the world extend vectors with an optional filter
  107960. *
  107961. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  107962. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  107963. */
  107964. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  107965. min: Vector3;
  107966. max: Vector3;
  107967. };
  107968. /**
  107969. * Creates a ray that can be used to pick in the scene
  107970. * @param x defines the x coordinate of the origin (on-screen)
  107971. * @param y defines the y coordinate of the origin (on-screen)
  107972. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107973. * @param camera defines the camera to use for the picking
  107974. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107975. * @returns a Ray
  107976. */
  107977. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  107978. /**
  107979. * Creates a ray that can be used to pick in the scene
  107980. * @param x defines the x coordinate of the origin (on-screen)
  107981. * @param y defines the y coordinate of the origin (on-screen)
  107982. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107983. * @param result defines the ray where to store the picking ray
  107984. * @param camera defines the camera to use for the picking
  107985. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107986. * @returns the current scene
  107987. */
  107988. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  107989. /**
  107990. * Creates a ray that can be used to pick in the scene
  107991. * @param x defines the x coordinate of the origin (on-screen)
  107992. * @param y defines the y coordinate of the origin (on-screen)
  107993. * @param camera defines the camera to use for the picking
  107994. * @returns a Ray
  107995. */
  107996. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  107997. /**
  107998. * Creates a ray that can be used to pick in the scene
  107999. * @param x defines the x coordinate of the origin (on-screen)
  108000. * @param y defines the y coordinate of the origin (on-screen)
  108001. * @param result defines the ray where to store the picking ray
  108002. * @param camera defines the camera to use for the picking
  108003. * @returns the current scene
  108004. */
  108005. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  108006. /** Launch a ray to try to pick a mesh in the scene
  108007. * @param x position on screen
  108008. * @param y position on screen
  108009. * @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
  108010. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  108011. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  108012. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  108013. * @returns a PickingInfo
  108014. */
  108015. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  108016. /** Use the given ray to pick a mesh in the scene
  108017. * @param ray The ray to use to pick meshes
  108018. * @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
  108019. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  108020. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  108021. * @returns a PickingInfo
  108022. */
  108023. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  108024. /**
  108025. * Launch a ray to try to pick a mesh in the scene
  108026. * @param x X position on screen
  108027. * @param y Y position on screen
  108028. * @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
  108029. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  108030. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  108031. * @returns an array of PickingInfo
  108032. */
  108033. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  108034. /**
  108035. * Launch a ray to try to pick a mesh in the scene
  108036. * @param ray Ray to use
  108037. * @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
  108038. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  108039. * @returns an array of PickingInfo
  108040. */
  108041. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  108042. /**
  108043. * Force the value of meshUnderPointer
  108044. * @param mesh defines the mesh to use
  108045. */
  108046. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108047. /**
  108048. * Gets the mesh under the pointer
  108049. * @returns a Mesh or null if no mesh is under the pointer
  108050. */
  108051. getPointerOverMesh(): Nullable<AbstractMesh>;
  108052. /** @hidden */
  108053. _rebuildGeometries(): void;
  108054. /** @hidden */
  108055. _rebuildTextures(): void;
  108056. private _getByTags;
  108057. /**
  108058. * Get a list of meshes by tags
  108059. * @param tagsQuery defines the tags query to use
  108060. * @param forEach defines a predicate used to filter results
  108061. * @returns an array of Mesh
  108062. */
  108063. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  108064. /**
  108065. * Get a list of cameras by tags
  108066. * @param tagsQuery defines the tags query to use
  108067. * @param forEach defines a predicate used to filter results
  108068. * @returns an array of Camera
  108069. */
  108070. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  108071. /**
  108072. * Get a list of lights by tags
  108073. * @param tagsQuery defines the tags query to use
  108074. * @param forEach defines a predicate used to filter results
  108075. * @returns an array of Light
  108076. */
  108077. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  108078. /**
  108079. * Get a list of materials by tags
  108080. * @param tagsQuery defines the tags query to use
  108081. * @param forEach defines a predicate used to filter results
  108082. * @returns an array of Material
  108083. */
  108084. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  108085. /**
  108086. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  108087. * This allowed control for front to back rendering or reversly depending of the special needs.
  108088. *
  108089. * @param renderingGroupId The rendering group id corresponding to its index
  108090. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  108091. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  108092. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  108093. */
  108094. 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;
  108095. /**
  108096. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  108097. *
  108098. * @param renderingGroupId The rendering group id corresponding to its index
  108099. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108100. * @param depth Automatically clears depth between groups if true and autoClear is true.
  108101. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  108102. */
  108103. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  108104. /**
  108105. * Gets the current auto clear configuration for one rendering group of the rendering
  108106. * manager.
  108107. * @param index the rendering group index to get the information for
  108108. * @returns The auto clear setup for the requested rendering group
  108109. */
  108110. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  108111. private _blockMaterialDirtyMechanism;
  108112. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  108113. get blockMaterialDirtyMechanism(): boolean;
  108114. set blockMaterialDirtyMechanism(value: boolean);
  108115. /**
  108116. * Will flag all materials as dirty to trigger new shader compilation
  108117. * @param flag defines the flag used to specify which material part must be marked as dirty
  108118. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  108119. */
  108120. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  108121. /** @hidden */
  108122. _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;
  108123. /** @hidden */
  108124. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108125. /** @hidden */
  108126. _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;
  108127. /** @hidden */
  108128. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  108129. /** @hidden */
  108130. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  108131. /** @hidden */
  108132. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108133. }
  108134. }
  108135. declare module BABYLON {
  108136. /**
  108137. * Set of assets to keep when moving a scene into an asset container.
  108138. */
  108139. export class KeepAssets extends AbstractScene {
  108140. }
  108141. /**
  108142. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  108143. */
  108144. export class InstantiatedEntries {
  108145. /**
  108146. * List of new root nodes (eg. nodes with no parent)
  108147. */
  108148. rootNodes: TransformNode[];
  108149. /**
  108150. * List of new skeletons
  108151. */
  108152. skeletons: Skeleton[];
  108153. /**
  108154. * List of new animation groups
  108155. */
  108156. animationGroups: AnimationGroup[];
  108157. }
  108158. /**
  108159. * Container with a set of assets that can be added or removed from a scene.
  108160. */
  108161. export class AssetContainer extends AbstractScene {
  108162. /**
  108163. * The scene the AssetContainer belongs to.
  108164. */
  108165. scene: Scene;
  108166. /**
  108167. * Instantiates an AssetContainer.
  108168. * @param scene The scene the AssetContainer belongs to.
  108169. */
  108170. constructor(scene: Scene);
  108171. /**
  108172. * Instantiate or clone all meshes and add the new ones to the scene.
  108173. * Skeletons and animation groups will all be cloned
  108174. * @param nameFunction defines an optional function used to get new names for clones
  108175. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  108176. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  108177. */
  108178. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  108179. /**
  108180. * Adds all the assets from the container to the scene.
  108181. */
  108182. addAllToScene(): void;
  108183. /**
  108184. * Removes all the assets in the container from the scene
  108185. */
  108186. removeAllFromScene(): void;
  108187. /**
  108188. * Disposes all the assets in the container
  108189. */
  108190. dispose(): void;
  108191. private _moveAssets;
  108192. /**
  108193. * Removes all the assets contained in the scene and adds them to the container.
  108194. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  108195. */
  108196. moveAllFromScene(keepAssets?: KeepAssets): void;
  108197. /**
  108198. * 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.
  108199. * @returns the root mesh
  108200. */
  108201. createRootMesh(): Mesh;
  108202. /**
  108203. * Merge animations from this asset container into a scene
  108204. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108205. * @param animatables set of animatables to retarget to a node from the scene
  108206. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  108207. */
  108208. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  108209. }
  108210. }
  108211. declare module BABYLON {
  108212. /**
  108213. * Defines how the parser contract is defined.
  108214. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  108215. */
  108216. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  108217. /**
  108218. * Defines how the individual parser contract is defined.
  108219. * These parser can parse an individual asset
  108220. */
  108221. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  108222. /**
  108223. * Base class of the scene acting as a container for the different elements composing a scene.
  108224. * This class is dynamically extended by the different components of the scene increasing
  108225. * flexibility and reducing coupling
  108226. */
  108227. export abstract class AbstractScene {
  108228. /**
  108229. * Stores the list of available parsers in the application.
  108230. */
  108231. private static _BabylonFileParsers;
  108232. /**
  108233. * Stores the list of available individual parsers in the application.
  108234. */
  108235. private static _IndividualBabylonFileParsers;
  108236. /**
  108237. * Adds a parser in the list of available ones
  108238. * @param name Defines the name of the parser
  108239. * @param parser Defines the parser to add
  108240. */
  108241. static AddParser(name: string, parser: BabylonFileParser): void;
  108242. /**
  108243. * Gets a general parser from the list of avaialble ones
  108244. * @param name Defines the name of the parser
  108245. * @returns the requested parser or null
  108246. */
  108247. static GetParser(name: string): Nullable<BabylonFileParser>;
  108248. /**
  108249. * Adds n individual parser in the list of available ones
  108250. * @param name Defines the name of the parser
  108251. * @param parser Defines the parser to add
  108252. */
  108253. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  108254. /**
  108255. * Gets an individual parser from the list of avaialble ones
  108256. * @param name Defines the name of the parser
  108257. * @returns the requested parser or null
  108258. */
  108259. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  108260. /**
  108261. * Parser json data and populate both a scene and its associated container object
  108262. * @param jsonData Defines the data to parse
  108263. * @param scene Defines the scene to parse the data for
  108264. * @param container Defines the container attached to the parsing sequence
  108265. * @param rootUrl Defines the root url of the data
  108266. */
  108267. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  108268. /**
  108269. * Gets the list of root nodes (ie. nodes with no parent)
  108270. */
  108271. rootNodes: Node[];
  108272. /** All of the cameras added to this scene
  108273. * @see http://doc.babylonjs.com/babylon101/cameras
  108274. */
  108275. cameras: Camera[];
  108276. /**
  108277. * All of the lights added to this scene
  108278. * @see http://doc.babylonjs.com/babylon101/lights
  108279. */
  108280. lights: Light[];
  108281. /**
  108282. * All of the (abstract) meshes added to this scene
  108283. */
  108284. meshes: AbstractMesh[];
  108285. /**
  108286. * The list of skeletons added to the scene
  108287. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  108288. */
  108289. skeletons: Skeleton[];
  108290. /**
  108291. * All of the particle systems added to this scene
  108292. * @see http://doc.babylonjs.com/babylon101/particles
  108293. */
  108294. particleSystems: IParticleSystem[];
  108295. /**
  108296. * Gets a list of Animations associated with the scene
  108297. */
  108298. animations: Animation[];
  108299. /**
  108300. * All of the animation groups added to this scene
  108301. * @see http://doc.babylonjs.com/how_to/group
  108302. */
  108303. animationGroups: AnimationGroup[];
  108304. /**
  108305. * All of the multi-materials added to this scene
  108306. * @see http://doc.babylonjs.com/how_to/multi_materials
  108307. */
  108308. multiMaterials: MultiMaterial[];
  108309. /**
  108310. * All of the materials added to this scene
  108311. * In the context of a Scene, it is not supposed to be modified manually.
  108312. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  108313. * Note also that the order of the Material within the array is not significant and might change.
  108314. * @see http://doc.babylonjs.com/babylon101/materials
  108315. */
  108316. materials: Material[];
  108317. /**
  108318. * The list of morph target managers added to the scene
  108319. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  108320. */
  108321. morphTargetManagers: MorphTargetManager[];
  108322. /**
  108323. * The list of geometries used in the scene.
  108324. */
  108325. geometries: Geometry[];
  108326. /**
  108327. * All of the tranform nodes added to this scene
  108328. * In the context of a Scene, it is not supposed to be modified manually.
  108329. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  108330. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  108331. * @see http://doc.babylonjs.com/how_to/transformnode
  108332. */
  108333. transformNodes: TransformNode[];
  108334. /**
  108335. * ActionManagers available on the scene.
  108336. */
  108337. actionManagers: AbstractActionManager[];
  108338. /**
  108339. * Textures to keep.
  108340. */
  108341. textures: BaseTexture[];
  108342. /**
  108343. * Environment texture for the scene
  108344. */
  108345. environmentTexture: Nullable<BaseTexture>;
  108346. /**
  108347. * @returns all meshes, lights, cameras, transformNodes and bones
  108348. */
  108349. getNodes(): Array<Node>;
  108350. }
  108351. }
  108352. declare module BABYLON {
  108353. /**
  108354. * Interface used to define options for Sound class
  108355. */
  108356. export interface ISoundOptions {
  108357. /**
  108358. * Does the sound autoplay once loaded.
  108359. */
  108360. autoplay?: boolean;
  108361. /**
  108362. * Does the sound loop after it finishes playing once.
  108363. */
  108364. loop?: boolean;
  108365. /**
  108366. * Sound's volume
  108367. */
  108368. volume?: number;
  108369. /**
  108370. * Is it a spatial sound?
  108371. */
  108372. spatialSound?: boolean;
  108373. /**
  108374. * Maximum distance to hear that sound
  108375. */
  108376. maxDistance?: number;
  108377. /**
  108378. * Uses user defined attenuation function
  108379. */
  108380. useCustomAttenuation?: boolean;
  108381. /**
  108382. * Define the roll off factor of spatial sounds.
  108383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108384. */
  108385. rolloffFactor?: number;
  108386. /**
  108387. * Define the reference distance the sound should be heard perfectly.
  108388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108389. */
  108390. refDistance?: number;
  108391. /**
  108392. * Define the distance attenuation model the sound will follow.
  108393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108394. */
  108395. distanceModel?: string;
  108396. /**
  108397. * Defines the playback speed (1 by default)
  108398. */
  108399. playbackRate?: number;
  108400. /**
  108401. * Defines if the sound is from a streaming source
  108402. */
  108403. streaming?: boolean;
  108404. /**
  108405. * Defines an optional length (in seconds) inside the sound file
  108406. */
  108407. length?: number;
  108408. /**
  108409. * Defines an optional offset (in seconds) inside the sound file
  108410. */
  108411. offset?: number;
  108412. /**
  108413. * If true, URLs will not be required to state the audio file codec to use.
  108414. */
  108415. skipCodecCheck?: boolean;
  108416. }
  108417. /**
  108418. * Defines a sound that can be played in the application.
  108419. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  108420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108421. */
  108422. export class Sound {
  108423. /**
  108424. * The name of the sound in the scene.
  108425. */
  108426. name: string;
  108427. /**
  108428. * Does the sound autoplay once loaded.
  108429. */
  108430. autoplay: boolean;
  108431. /**
  108432. * Does the sound loop after it finishes playing once.
  108433. */
  108434. loop: boolean;
  108435. /**
  108436. * Does the sound use a custom attenuation curve to simulate the falloff
  108437. * happening when the source gets further away from the camera.
  108438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  108439. */
  108440. useCustomAttenuation: boolean;
  108441. /**
  108442. * The sound track id this sound belongs to.
  108443. */
  108444. soundTrackId: number;
  108445. /**
  108446. * Is this sound currently played.
  108447. */
  108448. isPlaying: boolean;
  108449. /**
  108450. * Is this sound currently paused.
  108451. */
  108452. isPaused: boolean;
  108453. /**
  108454. * Does this sound enables spatial sound.
  108455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108456. */
  108457. spatialSound: boolean;
  108458. /**
  108459. * Define the reference distance the sound should be heard perfectly.
  108460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108461. */
  108462. refDistance: number;
  108463. /**
  108464. * Define the roll off factor of spatial sounds.
  108465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108466. */
  108467. rolloffFactor: number;
  108468. /**
  108469. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  108470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108471. */
  108472. maxDistance: number;
  108473. /**
  108474. * Define the distance attenuation model the sound will follow.
  108475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108476. */
  108477. distanceModel: string;
  108478. /**
  108479. * @hidden
  108480. * Back Compat
  108481. **/
  108482. onended: () => any;
  108483. /**
  108484. * Observable event when the current playing sound finishes.
  108485. */
  108486. onEndedObservable: Observable<Sound>;
  108487. private _panningModel;
  108488. private _playbackRate;
  108489. private _streaming;
  108490. private _startTime;
  108491. private _startOffset;
  108492. private _position;
  108493. /** @hidden */
  108494. _positionInEmitterSpace: boolean;
  108495. private _localDirection;
  108496. private _volume;
  108497. private _isReadyToPlay;
  108498. private _isDirectional;
  108499. private _readyToPlayCallback;
  108500. private _audioBuffer;
  108501. private _soundSource;
  108502. private _streamingSource;
  108503. private _soundPanner;
  108504. private _soundGain;
  108505. private _inputAudioNode;
  108506. private _outputAudioNode;
  108507. private _coneInnerAngle;
  108508. private _coneOuterAngle;
  108509. private _coneOuterGain;
  108510. private _scene;
  108511. private _connectedTransformNode;
  108512. private _customAttenuationFunction;
  108513. private _registerFunc;
  108514. private _isOutputConnected;
  108515. private _htmlAudioElement;
  108516. private _urlType;
  108517. private _length?;
  108518. private _offset?;
  108519. /** @hidden */
  108520. static _SceneComponentInitialization: (scene: Scene) => void;
  108521. /**
  108522. * Create a sound and attach it to a scene
  108523. * @param name Name of your sound
  108524. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  108525. * @param scene defines the scene the sound belongs to
  108526. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  108527. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  108528. */
  108529. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  108530. /**
  108531. * Release the sound and its associated resources
  108532. */
  108533. dispose(): void;
  108534. /**
  108535. * Gets if the sounds is ready to be played or not.
  108536. * @returns true if ready, otherwise false
  108537. */
  108538. isReady(): boolean;
  108539. private _soundLoaded;
  108540. /**
  108541. * Sets the data of the sound from an audiobuffer
  108542. * @param audioBuffer The audioBuffer containing the data
  108543. */
  108544. setAudioBuffer(audioBuffer: AudioBuffer): void;
  108545. /**
  108546. * Updates the current sounds options such as maxdistance, loop...
  108547. * @param options A JSON object containing values named as the object properties
  108548. */
  108549. updateOptions(options: ISoundOptions): void;
  108550. private _createSpatialParameters;
  108551. private _updateSpatialParameters;
  108552. /**
  108553. * Switch the panning model to HRTF:
  108554. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  108555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108556. */
  108557. switchPanningModelToHRTF(): void;
  108558. /**
  108559. * Switch the panning model to Equal Power:
  108560. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  108561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108562. */
  108563. switchPanningModelToEqualPower(): void;
  108564. private _switchPanningModel;
  108565. /**
  108566. * Connect this sound to a sound track audio node like gain...
  108567. * @param soundTrackAudioNode the sound track audio node to connect to
  108568. */
  108569. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  108570. /**
  108571. * Transform this sound into a directional source
  108572. * @param coneInnerAngle Size of the inner cone in degree
  108573. * @param coneOuterAngle Size of the outer cone in degree
  108574. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  108575. */
  108576. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  108577. /**
  108578. * Gets or sets the inner angle for the directional cone.
  108579. */
  108580. get directionalConeInnerAngle(): number;
  108581. /**
  108582. * Gets or sets the inner angle for the directional cone.
  108583. */
  108584. set directionalConeInnerAngle(value: number);
  108585. /**
  108586. * Gets or sets the outer angle for the directional cone.
  108587. */
  108588. get directionalConeOuterAngle(): number;
  108589. /**
  108590. * Gets or sets the outer angle for the directional cone.
  108591. */
  108592. set directionalConeOuterAngle(value: number);
  108593. /**
  108594. * Sets the position of the emitter if spatial sound is enabled
  108595. * @param newPosition Defines the new posisiton
  108596. */
  108597. setPosition(newPosition: Vector3): void;
  108598. /**
  108599. * Sets the local direction of the emitter if spatial sound is enabled
  108600. * @param newLocalDirection Defines the new local direction
  108601. */
  108602. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  108603. private _updateDirection;
  108604. /** @hidden */
  108605. updateDistanceFromListener(): void;
  108606. /**
  108607. * Sets a new custom attenuation function for the sound.
  108608. * @param callback Defines the function used for the attenuation
  108609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  108610. */
  108611. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  108612. /**
  108613. * Play the sound
  108614. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  108615. * @param offset (optional) Start the sound at a specific time in seconds
  108616. * @param length (optional) Sound duration (in seconds)
  108617. */
  108618. play(time?: number, offset?: number, length?: number): void;
  108619. private _onended;
  108620. /**
  108621. * Stop the sound
  108622. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  108623. */
  108624. stop(time?: number): void;
  108625. /**
  108626. * Put the sound in pause
  108627. */
  108628. pause(): void;
  108629. /**
  108630. * Sets a dedicated volume for this sounds
  108631. * @param newVolume Define the new volume of the sound
  108632. * @param time Define time for gradual change to new volume
  108633. */
  108634. setVolume(newVolume: number, time?: number): void;
  108635. /**
  108636. * Set the sound play back rate
  108637. * @param newPlaybackRate Define the playback rate the sound should be played at
  108638. */
  108639. setPlaybackRate(newPlaybackRate: number): void;
  108640. /**
  108641. * Gets the volume of the sound.
  108642. * @returns the volume of the sound
  108643. */
  108644. getVolume(): number;
  108645. /**
  108646. * Attach the sound to a dedicated mesh
  108647. * @param transformNode The transform node to connect the sound with
  108648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  108649. */
  108650. attachToMesh(transformNode: TransformNode): void;
  108651. /**
  108652. * Detach the sound from the previously attached mesh
  108653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  108654. */
  108655. detachFromMesh(): void;
  108656. private _onRegisterAfterWorldMatrixUpdate;
  108657. /**
  108658. * Clone the current sound in the scene.
  108659. * @returns the new sound clone
  108660. */
  108661. clone(): Nullable<Sound>;
  108662. /**
  108663. * Gets the current underlying audio buffer containing the data
  108664. * @returns the audio buffer
  108665. */
  108666. getAudioBuffer(): Nullable<AudioBuffer>;
  108667. /**
  108668. * Serializes the Sound in a JSON representation
  108669. * @returns the JSON representation of the sound
  108670. */
  108671. serialize(): any;
  108672. /**
  108673. * Parse a JSON representation of a sound to innstantiate in a given scene
  108674. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  108675. * @param scene Define the scene the new parsed sound should be created in
  108676. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  108677. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  108678. * @returns the newly parsed sound
  108679. */
  108680. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  108681. }
  108682. }
  108683. declare module BABYLON {
  108684. /**
  108685. * This defines an action helpful to play a defined sound on a triggered action.
  108686. */
  108687. export class PlaySoundAction extends Action {
  108688. private _sound;
  108689. /**
  108690. * Instantiate the action
  108691. * @param triggerOptions defines the trigger options
  108692. * @param sound defines the sound to play
  108693. * @param condition defines the trigger related conditions
  108694. */
  108695. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  108696. /** @hidden */
  108697. _prepare(): void;
  108698. /**
  108699. * Execute the action and play the sound.
  108700. */
  108701. execute(): void;
  108702. /**
  108703. * Serializes the actions and its related information.
  108704. * @param parent defines the object to serialize in
  108705. * @returns the serialized object
  108706. */
  108707. serialize(parent: any): any;
  108708. }
  108709. /**
  108710. * This defines an action helpful to stop a defined sound on a triggered action.
  108711. */
  108712. export class StopSoundAction extends Action {
  108713. private _sound;
  108714. /**
  108715. * Instantiate the action
  108716. * @param triggerOptions defines the trigger options
  108717. * @param sound defines the sound to stop
  108718. * @param condition defines the trigger related conditions
  108719. */
  108720. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  108721. /** @hidden */
  108722. _prepare(): void;
  108723. /**
  108724. * Execute the action and stop the sound.
  108725. */
  108726. execute(): void;
  108727. /**
  108728. * Serializes the actions and its related information.
  108729. * @param parent defines the object to serialize in
  108730. * @returns the serialized object
  108731. */
  108732. serialize(parent: any): any;
  108733. }
  108734. }
  108735. declare module BABYLON {
  108736. /**
  108737. * This defines an action responsible to change the value of a property
  108738. * by interpolating between its current value and the newly set one once triggered.
  108739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108740. */
  108741. export class InterpolateValueAction extends Action {
  108742. /**
  108743. * Defines the path of the property where the value should be interpolated
  108744. */
  108745. propertyPath: string;
  108746. /**
  108747. * Defines the target value at the end of the interpolation.
  108748. */
  108749. value: any;
  108750. /**
  108751. * Defines the time it will take for the property to interpolate to the value.
  108752. */
  108753. duration: number;
  108754. /**
  108755. * Defines if the other scene animations should be stopped when the action has been triggered
  108756. */
  108757. stopOtherAnimations?: boolean;
  108758. /**
  108759. * Defines a callback raised once the interpolation animation has been done.
  108760. */
  108761. onInterpolationDone?: () => void;
  108762. /**
  108763. * Observable triggered once the interpolation animation has been done.
  108764. */
  108765. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  108766. private _target;
  108767. private _effectiveTarget;
  108768. private _property;
  108769. /**
  108770. * Instantiate the action
  108771. * @param triggerOptions defines the trigger options
  108772. * @param target defines the object containing the value to interpolate
  108773. * @param propertyPath defines the path to the property in the target object
  108774. * @param value defines the target value at the end of the interpolation
  108775. * @param duration deines the time it will take for the property to interpolate to the value.
  108776. * @param condition defines the trigger related conditions
  108777. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  108778. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  108779. */
  108780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  108781. /** @hidden */
  108782. _prepare(): void;
  108783. /**
  108784. * Execute the action starts the value interpolation.
  108785. */
  108786. execute(): void;
  108787. /**
  108788. * Serializes the actions and its related information.
  108789. * @param parent defines the object to serialize in
  108790. * @returns the serialized object
  108791. */
  108792. serialize(parent: any): any;
  108793. }
  108794. }
  108795. declare module BABYLON {
  108796. /**
  108797. * Options allowed during the creation of a sound track.
  108798. */
  108799. export interface ISoundTrackOptions {
  108800. /**
  108801. * The volume the sound track should take during creation
  108802. */
  108803. volume?: number;
  108804. /**
  108805. * Define if the sound track is the main sound track of the scene
  108806. */
  108807. mainTrack?: boolean;
  108808. }
  108809. /**
  108810. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  108811. * It will be also used in a future release to apply effects on a specific track.
  108812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108813. */
  108814. export class SoundTrack {
  108815. /**
  108816. * The unique identifier of the sound track in the scene.
  108817. */
  108818. id: number;
  108819. /**
  108820. * The list of sounds included in the sound track.
  108821. */
  108822. soundCollection: Array<Sound>;
  108823. private _outputAudioNode;
  108824. private _scene;
  108825. private _connectedAnalyser;
  108826. private _options;
  108827. private _isInitialized;
  108828. /**
  108829. * Creates a new sound track.
  108830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108831. * @param scene Define the scene the sound track belongs to
  108832. * @param options
  108833. */
  108834. constructor(scene: Scene, options?: ISoundTrackOptions);
  108835. private _initializeSoundTrackAudioGraph;
  108836. /**
  108837. * Release the sound track and its associated resources
  108838. */
  108839. dispose(): void;
  108840. /**
  108841. * Adds a sound to this sound track
  108842. * @param sound define the cound to add
  108843. * @ignoreNaming
  108844. */
  108845. AddSound(sound: Sound): void;
  108846. /**
  108847. * Removes a sound to this sound track
  108848. * @param sound define the cound to remove
  108849. * @ignoreNaming
  108850. */
  108851. RemoveSound(sound: Sound): void;
  108852. /**
  108853. * Set a global volume for the full sound track.
  108854. * @param newVolume Define the new volume of the sound track
  108855. */
  108856. setVolume(newVolume: number): void;
  108857. /**
  108858. * Switch the panning model to HRTF:
  108859. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  108860. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108861. */
  108862. switchPanningModelToHRTF(): void;
  108863. /**
  108864. * Switch the panning model to Equal Power:
  108865. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  108866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108867. */
  108868. switchPanningModelToEqualPower(): void;
  108869. /**
  108870. * Connect the sound track to an audio analyser allowing some amazing
  108871. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  108872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  108873. * @param analyser The analyser to connect to the engine
  108874. */
  108875. connectToAnalyser(analyser: Analyser): void;
  108876. }
  108877. }
  108878. declare module BABYLON {
  108879. interface AbstractScene {
  108880. /**
  108881. * The list of sounds used in the scene.
  108882. */
  108883. sounds: Nullable<Array<Sound>>;
  108884. }
  108885. interface Scene {
  108886. /**
  108887. * @hidden
  108888. * Backing field
  108889. */
  108890. _mainSoundTrack: SoundTrack;
  108891. /**
  108892. * The main sound track played by the scene.
  108893. * It cotains your primary collection of sounds.
  108894. */
  108895. mainSoundTrack: SoundTrack;
  108896. /**
  108897. * The list of sound tracks added to the scene
  108898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108899. */
  108900. soundTracks: Nullable<Array<SoundTrack>>;
  108901. /**
  108902. * Gets a sound using a given name
  108903. * @param name defines the name to search for
  108904. * @return the found sound or null if not found at all.
  108905. */
  108906. getSoundByName(name: string): Nullable<Sound>;
  108907. /**
  108908. * Gets or sets if audio support is enabled
  108909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108910. */
  108911. audioEnabled: boolean;
  108912. /**
  108913. * Gets or sets if audio will be output to headphones
  108914. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108915. */
  108916. headphone: boolean;
  108917. /**
  108918. * Gets or sets custom audio listener position provider
  108919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108920. */
  108921. audioListenerPositionProvider: Nullable<() => Vector3>;
  108922. /**
  108923. * Gets or sets a refresh rate when using 3D audio positioning
  108924. */
  108925. audioPositioningRefreshRate: number;
  108926. }
  108927. /**
  108928. * Defines the sound scene component responsible to manage any sounds
  108929. * in a given scene.
  108930. */
  108931. export class AudioSceneComponent implements ISceneSerializableComponent {
  108932. /**
  108933. * The component name helpfull to identify the component in the list of scene components.
  108934. */
  108935. readonly name: string;
  108936. /**
  108937. * The scene the component belongs to.
  108938. */
  108939. scene: Scene;
  108940. private _audioEnabled;
  108941. /**
  108942. * Gets whether audio is enabled or not.
  108943. * Please use related enable/disable method to switch state.
  108944. */
  108945. get audioEnabled(): boolean;
  108946. private _headphone;
  108947. /**
  108948. * Gets whether audio is outputing to headphone or not.
  108949. * Please use the according Switch methods to change output.
  108950. */
  108951. get headphone(): boolean;
  108952. /**
  108953. * Gets or sets a refresh rate when using 3D audio positioning
  108954. */
  108955. audioPositioningRefreshRate: number;
  108956. private _audioListenerPositionProvider;
  108957. /**
  108958. * Gets the current audio listener position provider
  108959. */
  108960. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  108961. /**
  108962. * Sets a custom listener position for all sounds in the scene
  108963. * By default, this is the position of the first active camera
  108964. */
  108965. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  108966. /**
  108967. * Creates a new instance of the component for the given scene
  108968. * @param scene Defines the scene to register the component in
  108969. */
  108970. constructor(scene: Scene);
  108971. /**
  108972. * Registers the component in a given scene
  108973. */
  108974. register(): void;
  108975. /**
  108976. * Rebuilds the elements related to this component in case of
  108977. * context lost for instance.
  108978. */
  108979. rebuild(): void;
  108980. /**
  108981. * Serializes the component data to the specified json object
  108982. * @param serializationObject The object to serialize to
  108983. */
  108984. serialize(serializationObject: any): void;
  108985. /**
  108986. * Adds all the elements from the container to the scene
  108987. * @param container the container holding the elements
  108988. */
  108989. addFromContainer(container: AbstractScene): void;
  108990. /**
  108991. * Removes all the elements in the container from the scene
  108992. * @param container contains the elements to remove
  108993. * @param dispose if the removed element should be disposed (default: false)
  108994. */
  108995. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108996. /**
  108997. * Disposes the component and the associated ressources.
  108998. */
  108999. dispose(): void;
  109000. /**
  109001. * Disables audio in the associated scene.
  109002. */
  109003. disableAudio(): void;
  109004. /**
  109005. * Enables audio in the associated scene.
  109006. */
  109007. enableAudio(): void;
  109008. /**
  109009. * Switch audio to headphone output.
  109010. */
  109011. switchAudioModeForHeadphones(): void;
  109012. /**
  109013. * Switch audio to normal speakers.
  109014. */
  109015. switchAudioModeForNormalSpeakers(): void;
  109016. private _cachedCameraDirection;
  109017. private _cachedCameraPosition;
  109018. private _lastCheck;
  109019. private _afterRender;
  109020. }
  109021. }
  109022. declare module BABYLON {
  109023. /**
  109024. * Wraps one or more Sound objects and selects one with random weight for playback.
  109025. */
  109026. export class WeightedSound {
  109027. /** When true a Sound will be selected and played when the current playing Sound completes. */
  109028. loop: boolean;
  109029. private _coneInnerAngle;
  109030. private _coneOuterAngle;
  109031. private _volume;
  109032. /** A Sound is currently playing. */
  109033. isPlaying: boolean;
  109034. /** A Sound is currently paused. */
  109035. isPaused: boolean;
  109036. private _sounds;
  109037. private _weights;
  109038. private _currentIndex?;
  109039. /**
  109040. * Creates a new WeightedSound from the list of sounds given.
  109041. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  109042. * @param sounds Array of Sounds that will be selected from.
  109043. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  109044. */
  109045. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  109046. /**
  109047. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  109048. */
  109049. get directionalConeInnerAngle(): number;
  109050. /**
  109051. * The size of cone in degress for a directional sound in which there will be no attenuation.
  109052. */
  109053. set directionalConeInnerAngle(value: number);
  109054. /**
  109055. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  109056. * Listener angles between innerAngle and outerAngle will falloff linearly.
  109057. */
  109058. get directionalConeOuterAngle(): number;
  109059. /**
  109060. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  109061. * Listener angles between innerAngle and outerAngle will falloff linearly.
  109062. */
  109063. set directionalConeOuterAngle(value: number);
  109064. /**
  109065. * Playback volume.
  109066. */
  109067. get volume(): number;
  109068. /**
  109069. * Playback volume.
  109070. */
  109071. set volume(value: number);
  109072. private _onended;
  109073. /**
  109074. * Suspend playback
  109075. */
  109076. pause(): void;
  109077. /**
  109078. * Stop playback
  109079. */
  109080. stop(): void;
  109081. /**
  109082. * Start playback.
  109083. * @param startOffset Position the clip head at a specific time in seconds.
  109084. */
  109085. play(startOffset?: number): void;
  109086. }
  109087. }
  109088. declare module BABYLON {
  109089. /**
  109090. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  109091. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109092. */
  109093. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  109094. /**
  109095. * Gets the name of the behavior.
  109096. */
  109097. get name(): string;
  109098. /**
  109099. * The easing function used by animations
  109100. */
  109101. static EasingFunction: BackEase;
  109102. /**
  109103. * The easing mode used by animations
  109104. */
  109105. static EasingMode: number;
  109106. /**
  109107. * The duration of the animation, in milliseconds
  109108. */
  109109. transitionDuration: number;
  109110. /**
  109111. * Length of the distance animated by the transition when lower radius is reached
  109112. */
  109113. lowerRadiusTransitionRange: number;
  109114. /**
  109115. * Length of the distance animated by the transition when upper radius is reached
  109116. */
  109117. upperRadiusTransitionRange: number;
  109118. private _autoTransitionRange;
  109119. /**
  109120. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  109121. */
  109122. get autoTransitionRange(): boolean;
  109123. /**
  109124. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  109125. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  109126. */
  109127. set autoTransitionRange(value: boolean);
  109128. private _attachedCamera;
  109129. private _onAfterCheckInputsObserver;
  109130. private _onMeshTargetChangedObserver;
  109131. /**
  109132. * Initializes the behavior.
  109133. */
  109134. init(): void;
  109135. /**
  109136. * Attaches the behavior to its arc rotate camera.
  109137. * @param camera Defines the camera to attach the behavior to
  109138. */
  109139. attach(camera: ArcRotateCamera): void;
  109140. /**
  109141. * Detaches the behavior from its current arc rotate camera.
  109142. */
  109143. detach(): void;
  109144. private _radiusIsAnimating;
  109145. private _radiusBounceTransition;
  109146. private _animatables;
  109147. private _cachedWheelPrecision;
  109148. /**
  109149. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  109150. * @param radiusLimit The limit to check against.
  109151. * @return Bool to indicate if at limit.
  109152. */
  109153. private _isRadiusAtLimit;
  109154. /**
  109155. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  109156. * @param radiusDelta The delta by which to animate to. Can be negative.
  109157. */
  109158. private _applyBoundRadiusAnimation;
  109159. /**
  109160. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  109161. */
  109162. protected _clearAnimationLocks(): void;
  109163. /**
  109164. * Stops and removes all animations that have been applied to the camera
  109165. */
  109166. stopAllAnimations(): void;
  109167. }
  109168. }
  109169. declare module BABYLON {
  109170. /**
  109171. * 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.
  109172. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109173. */
  109174. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  109175. /**
  109176. * Gets the name of the behavior.
  109177. */
  109178. get name(): string;
  109179. private _mode;
  109180. private _radiusScale;
  109181. private _positionScale;
  109182. private _defaultElevation;
  109183. private _elevationReturnTime;
  109184. private _elevationReturnWaitTime;
  109185. private _zoomStopsAnimation;
  109186. private _framingTime;
  109187. /**
  109188. * The easing function used by animations
  109189. */
  109190. static EasingFunction: ExponentialEase;
  109191. /**
  109192. * The easing mode used by animations
  109193. */
  109194. static EasingMode: number;
  109195. /**
  109196. * Sets the current mode used by the behavior
  109197. */
  109198. set mode(mode: number);
  109199. /**
  109200. * Gets current mode used by the behavior.
  109201. */
  109202. get mode(): number;
  109203. /**
  109204. * Sets the scale applied to the radius (1 by default)
  109205. */
  109206. set radiusScale(radius: number);
  109207. /**
  109208. * Gets the scale applied to the radius
  109209. */
  109210. get radiusScale(): number;
  109211. /**
  109212. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  109213. */
  109214. set positionScale(scale: number);
  109215. /**
  109216. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  109217. */
  109218. get positionScale(): number;
  109219. /**
  109220. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  109221. * behaviour is triggered, in radians.
  109222. */
  109223. set defaultElevation(elevation: number);
  109224. /**
  109225. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  109226. * behaviour is triggered, in radians.
  109227. */
  109228. get defaultElevation(): number;
  109229. /**
  109230. * Sets the time (in milliseconds) taken to return to the default beta position.
  109231. * Negative value indicates camera should not return to default.
  109232. */
  109233. set elevationReturnTime(speed: number);
  109234. /**
  109235. * Gets the time (in milliseconds) taken to return to the default beta position.
  109236. * Negative value indicates camera should not return to default.
  109237. */
  109238. get elevationReturnTime(): number;
  109239. /**
  109240. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  109241. */
  109242. set elevationReturnWaitTime(time: number);
  109243. /**
  109244. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  109245. */
  109246. get elevationReturnWaitTime(): number;
  109247. /**
  109248. * Sets the flag that indicates if user zooming should stop animation.
  109249. */
  109250. set zoomStopsAnimation(flag: boolean);
  109251. /**
  109252. * Gets the flag that indicates if user zooming should stop animation.
  109253. */
  109254. get zoomStopsAnimation(): boolean;
  109255. /**
  109256. * Sets the transition time when framing the mesh, in milliseconds
  109257. */
  109258. set framingTime(time: number);
  109259. /**
  109260. * Gets the transition time when framing the mesh, in milliseconds
  109261. */
  109262. get framingTime(): number;
  109263. /**
  109264. * Define if the behavior should automatically change the configured
  109265. * camera limits and sensibilities.
  109266. */
  109267. autoCorrectCameraLimitsAndSensibility: boolean;
  109268. private _onPrePointerObservableObserver;
  109269. private _onAfterCheckInputsObserver;
  109270. private _onMeshTargetChangedObserver;
  109271. private _attachedCamera;
  109272. private _isPointerDown;
  109273. private _lastInteractionTime;
  109274. /**
  109275. * Initializes the behavior.
  109276. */
  109277. init(): void;
  109278. /**
  109279. * Attaches the behavior to its arc rotate camera.
  109280. * @param camera Defines the camera to attach the behavior to
  109281. */
  109282. attach(camera: ArcRotateCamera): void;
  109283. /**
  109284. * Detaches the behavior from its current arc rotate camera.
  109285. */
  109286. detach(): void;
  109287. private _animatables;
  109288. private _betaIsAnimating;
  109289. private _betaTransition;
  109290. private _radiusTransition;
  109291. private _vectorTransition;
  109292. /**
  109293. * Targets the given mesh and updates zoom level accordingly.
  109294. * @param mesh The mesh to target.
  109295. * @param radius Optional. If a cached radius position already exists, overrides default.
  109296. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  109297. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  109298. * @param onAnimationEnd Callback triggered at the end of the framing animation
  109299. */
  109300. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  109301. /**
  109302. * Targets the given mesh with its children and updates zoom level accordingly.
  109303. * @param mesh The mesh to target.
  109304. * @param radius Optional. If a cached radius position already exists, overrides default.
  109305. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  109306. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  109307. * @param onAnimationEnd Callback triggered at the end of the framing animation
  109308. */
  109309. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  109310. /**
  109311. * Targets the given meshes with their children and updates zoom level accordingly.
  109312. * @param meshes The mesh to target.
  109313. * @param radius Optional. If a cached radius position already exists, overrides default.
  109314. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  109315. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  109316. * @param onAnimationEnd Callback triggered at the end of the framing animation
  109317. */
  109318. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  109319. /**
  109320. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  109321. * @param minimumWorld Determines the smaller position of the bounding box extend
  109322. * @param maximumWorld Determines the bigger position of the bounding box extend
  109323. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  109324. * @param onAnimationEnd Callback triggered at the end of the framing animation
  109325. */
  109326. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  109327. /**
  109328. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  109329. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  109330. * frustum width.
  109331. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  109332. * to fully enclose the mesh in the viewing frustum.
  109333. */
  109334. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  109335. /**
  109336. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  109337. * is automatically returned to its default position (expected to be above ground plane).
  109338. */
  109339. private _maintainCameraAboveGround;
  109340. /**
  109341. * Returns the frustum slope based on the canvas ratio and camera FOV
  109342. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  109343. */
  109344. private _getFrustumSlope;
  109345. /**
  109346. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  109347. */
  109348. private _clearAnimationLocks;
  109349. /**
  109350. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  109351. */
  109352. private _applyUserInteraction;
  109353. /**
  109354. * Stops and removes all animations that have been applied to the camera
  109355. */
  109356. stopAllAnimations(): void;
  109357. /**
  109358. * Gets a value indicating if the user is moving the camera
  109359. */
  109360. get isUserIsMoving(): boolean;
  109361. /**
  109362. * The camera can move all the way towards the mesh.
  109363. */
  109364. static IgnoreBoundsSizeMode: number;
  109365. /**
  109366. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  109367. */
  109368. static FitFrustumSidesMode: number;
  109369. }
  109370. }
  109371. declare module BABYLON {
  109372. /**
  109373. * Base class for Camera Pointer Inputs.
  109374. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  109375. * for example usage.
  109376. */
  109377. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  109378. /**
  109379. * Defines the camera the input is attached to.
  109380. */
  109381. abstract camera: Camera;
  109382. /**
  109383. * Whether keyboard modifier keys are pressed at time of last mouse event.
  109384. */
  109385. protected _altKey: boolean;
  109386. protected _ctrlKey: boolean;
  109387. protected _metaKey: boolean;
  109388. protected _shiftKey: boolean;
  109389. /**
  109390. * Which mouse buttons were pressed at time of last mouse event.
  109391. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  109392. */
  109393. protected _buttonsPressed: number;
  109394. /**
  109395. * Defines the buttons associated with the input to handle camera move.
  109396. */
  109397. buttons: number[];
  109398. /**
  109399. * Attach the input controls to a specific dom element to get the input from.
  109400. * @param element Defines the element the controls should be listened from
  109401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109402. */
  109403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109404. /**
  109405. * Detach the current controls from the specified dom element.
  109406. * @param element Defines the element to stop listening the inputs from
  109407. */
  109408. detachControl(element: Nullable<HTMLElement>): void;
  109409. /**
  109410. * Gets the class name of the current input.
  109411. * @returns the class name
  109412. */
  109413. getClassName(): string;
  109414. /**
  109415. * Get the friendly name associated with the input class.
  109416. * @returns the input friendly name
  109417. */
  109418. getSimpleName(): string;
  109419. /**
  109420. * Called on pointer POINTERDOUBLETAP event.
  109421. * Override this method to provide functionality on POINTERDOUBLETAP event.
  109422. */
  109423. protected onDoubleTap(type: string): void;
  109424. /**
  109425. * Called on pointer POINTERMOVE event if only a single touch is active.
  109426. * Override this method to provide functionality.
  109427. */
  109428. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  109429. /**
  109430. * Called on pointer POINTERMOVE event if multiple touches are active.
  109431. * Override this method to provide functionality.
  109432. */
  109433. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  109434. /**
  109435. * Called on JS contextmenu event.
  109436. * Override this method to provide functionality.
  109437. */
  109438. protected onContextMenu(evt: PointerEvent): void;
  109439. /**
  109440. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  109441. * press.
  109442. * Override this method to provide functionality.
  109443. */
  109444. protected onButtonDown(evt: PointerEvent): void;
  109445. /**
  109446. * Called each time a new POINTERUP event occurs. Ie, for each button
  109447. * release.
  109448. * Override this method to provide functionality.
  109449. */
  109450. protected onButtonUp(evt: PointerEvent): void;
  109451. /**
  109452. * Called when window becomes inactive.
  109453. * Override this method to provide functionality.
  109454. */
  109455. protected onLostFocus(): void;
  109456. private _pointerInput;
  109457. private _observer;
  109458. private _onLostFocus;
  109459. private pointA;
  109460. private pointB;
  109461. }
  109462. }
  109463. declare module BABYLON {
  109464. /**
  109465. * Manage the pointers inputs to control an arc rotate camera.
  109466. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109467. */
  109468. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  109469. /**
  109470. * Defines the camera the input is attached to.
  109471. */
  109472. camera: ArcRotateCamera;
  109473. /**
  109474. * Gets the class name of the current input.
  109475. * @returns the class name
  109476. */
  109477. getClassName(): string;
  109478. /**
  109479. * Defines the buttons associated with the input to handle camera move.
  109480. */
  109481. buttons: number[];
  109482. /**
  109483. * Defines the pointer angular sensibility along the X axis or how fast is
  109484. * the camera rotating.
  109485. */
  109486. angularSensibilityX: number;
  109487. /**
  109488. * Defines the pointer angular sensibility along the Y axis or how fast is
  109489. * the camera rotating.
  109490. */
  109491. angularSensibilityY: number;
  109492. /**
  109493. * Defines the pointer pinch precision or how fast is the camera zooming.
  109494. */
  109495. pinchPrecision: number;
  109496. /**
  109497. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  109498. * from 0.
  109499. * It defines the percentage of current camera.radius to use as delta when
  109500. * pinch zoom is used.
  109501. */
  109502. pinchDeltaPercentage: number;
  109503. /**
  109504. * Defines the pointer panning sensibility or how fast is the camera moving.
  109505. */
  109506. panningSensibility: number;
  109507. /**
  109508. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  109509. */
  109510. multiTouchPanning: boolean;
  109511. /**
  109512. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  109513. * zoom (pinch) through multitouch.
  109514. */
  109515. multiTouchPanAndZoom: boolean;
  109516. /**
  109517. * Revers pinch action direction.
  109518. */
  109519. pinchInwards: boolean;
  109520. private _isPanClick;
  109521. private _twoFingerActivityCount;
  109522. private _isPinching;
  109523. /**
  109524. * Called on pointer POINTERMOVE event if only a single touch is active.
  109525. */
  109526. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  109527. /**
  109528. * Called on pointer POINTERDOUBLETAP event.
  109529. */
  109530. protected onDoubleTap(type: string): void;
  109531. /**
  109532. * Called on pointer POINTERMOVE event if multiple touches are active.
  109533. */
  109534. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  109535. /**
  109536. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  109537. * press.
  109538. */
  109539. protected onButtonDown(evt: PointerEvent): void;
  109540. /**
  109541. * Called each time a new POINTERUP event occurs. Ie, for each button
  109542. * release.
  109543. */
  109544. protected onButtonUp(evt: PointerEvent): void;
  109545. /**
  109546. * Called when window becomes inactive.
  109547. */
  109548. protected onLostFocus(): void;
  109549. }
  109550. }
  109551. declare module BABYLON {
  109552. /**
  109553. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  109554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109555. */
  109556. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  109557. /**
  109558. * Defines the camera the input is attached to.
  109559. */
  109560. camera: ArcRotateCamera;
  109561. /**
  109562. * Defines the list of key codes associated with the up action (increase alpha)
  109563. */
  109564. keysUp: number[];
  109565. /**
  109566. * Defines the list of key codes associated with the down action (decrease alpha)
  109567. */
  109568. keysDown: number[];
  109569. /**
  109570. * Defines the list of key codes associated with the left action (increase beta)
  109571. */
  109572. keysLeft: number[];
  109573. /**
  109574. * Defines the list of key codes associated with the right action (decrease beta)
  109575. */
  109576. keysRight: number[];
  109577. /**
  109578. * Defines the list of key codes associated with the reset action.
  109579. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  109580. */
  109581. keysReset: number[];
  109582. /**
  109583. * Defines the panning sensibility of the inputs.
  109584. * (How fast is the camera paning)
  109585. */
  109586. panningSensibility: number;
  109587. /**
  109588. * Defines the zooming sensibility of the inputs.
  109589. * (How fast is the camera zooming)
  109590. */
  109591. zoomingSensibility: number;
  109592. /**
  109593. * Defines wether maintaining the alt key down switch the movement mode from
  109594. * orientation to zoom.
  109595. */
  109596. useAltToZoom: boolean;
  109597. /**
  109598. * Rotation speed of the camera
  109599. */
  109600. angularSpeed: number;
  109601. private _keys;
  109602. private _ctrlPressed;
  109603. private _altPressed;
  109604. private _onCanvasBlurObserver;
  109605. private _onKeyboardObserver;
  109606. private _engine;
  109607. private _scene;
  109608. /**
  109609. * Attach the input controls to a specific dom element to get the input from.
  109610. * @param element Defines the element the controls should be listened from
  109611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109612. */
  109613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109614. /**
  109615. * Detach the current controls from the specified dom element.
  109616. * @param element Defines the element to stop listening the inputs from
  109617. */
  109618. detachControl(element: Nullable<HTMLElement>): void;
  109619. /**
  109620. * Update the current camera state depending on the inputs that have been used this frame.
  109621. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109622. */
  109623. checkInputs(): void;
  109624. /**
  109625. * Gets the class name of the current intput.
  109626. * @returns the class name
  109627. */
  109628. getClassName(): string;
  109629. /**
  109630. * Get the friendly name associated with the input class.
  109631. * @returns the input friendly name
  109632. */
  109633. getSimpleName(): string;
  109634. }
  109635. }
  109636. declare module BABYLON {
  109637. /**
  109638. * Manage the mouse wheel inputs to control an arc rotate camera.
  109639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109640. */
  109641. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  109642. /**
  109643. * Defines the camera the input is attached to.
  109644. */
  109645. camera: ArcRotateCamera;
  109646. /**
  109647. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  109648. */
  109649. wheelPrecision: number;
  109650. /**
  109651. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  109652. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  109653. */
  109654. wheelDeltaPercentage: number;
  109655. private _wheel;
  109656. private _observer;
  109657. private computeDeltaFromMouseWheelLegacyEvent;
  109658. /**
  109659. * Attach the input controls to a specific dom element to get the input from.
  109660. * @param element Defines the element the controls should be listened from
  109661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109662. */
  109663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109664. /**
  109665. * Detach the current controls from the specified dom element.
  109666. * @param element Defines the element to stop listening the inputs from
  109667. */
  109668. detachControl(element: Nullable<HTMLElement>): void;
  109669. /**
  109670. * Gets the class name of the current intput.
  109671. * @returns the class name
  109672. */
  109673. getClassName(): string;
  109674. /**
  109675. * Get the friendly name associated with the input class.
  109676. * @returns the input friendly name
  109677. */
  109678. getSimpleName(): string;
  109679. }
  109680. }
  109681. declare module BABYLON {
  109682. /**
  109683. * Default Inputs manager for the ArcRotateCamera.
  109684. * It groups all the default supported inputs for ease of use.
  109685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109686. */
  109687. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  109688. /**
  109689. * Instantiates a new ArcRotateCameraInputsManager.
  109690. * @param camera Defines the camera the inputs belong to
  109691. */
  109692. constructor(camera: ArcRotateCamera);
  109693. /**
  109694. * Add mouse wheel input support to the input manager.
  109695. * @returns the current input manager
  109696. */
  109697. addMouseWheel(): ArcRotateCameraInputsManager;
  109698. /**
  109699. * Add pointers input support to the input manager.
  109700. * @returns the current input manager
  109701. */
  109702. addPointers(): ArcRotateCameraInputsManager;
  109703. /**
  109704. * Add keyboard input support to the input manager.
  109705. * @returns the current input manager
  109706. */
  109707. addKeyboard(): ArcRotateCameraInputsManager;
  109708. }
  109709. }
  109710. declare module BABYLON {
  109711. /**
  109712. * This represents an orbital type of camera.
  109713. *
  109714. * 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.
  109715. * 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.
  109716. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  109717. */
  109718. export class ArcRotateCamera extends TargetCamera {
  109719. /**
  109720. * Defines the rotation angle of the camera along the longitudinal axis.
  109721. */
  109722. alpha: number;
  109723. /**
  109724. * Defines the rotation angle of the camera along the latitudinal axis.
  109725. */
  109726. beta: number;
  109727. /**
  109728. * Defines the radius of the camera from it s target point.
  109729. */
  109730. radius: number;
  109731. protected _target: Vector3;
  109732. protected _targetHost: Nullable<AbstractMesh>;
  109733. /**
  109734. * Defines the target point of the camera.
  109735. * The camera looks towards it form the radius distance.
  109736. */
  109737. get target(): Vector3;
  109738. set target(value: Vector3);
  109739. /**
  109740. * Define the current local position of the camera in the scene
  109741. */
  109742. get position(): Vector3;
  109743. set position(newPosition: Vector3);
  109744. protected _upVector: Vector3;
  109745. protected _upToYMatrix: Matrix;
  109746. protected _YToUpMatrix: Matrix;
  109747. /**
  109748. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  109749. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  109750. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  109751. */
  109752. set upVector(vec: Vector3);
  109753. get upVector(): Vector3;
  109754. /**
  109755. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  109756. */
  109757. setMatUp(): void;
  109758. /**
  109759. * Current inertia value on the longitudinal axis.
  109760. * The bigger this number the longer it will take for the camera to stop.
  109761. */
  109762. inertialAlphaOffset: number;
  109763. /**
  109764. * Current inertia value on the latitudinal axis.
  109765. * The bigger this number the longer it will take for the camera to stop.
  109766. */
  109767. inertialBetaOffset: number;
  109768. /**
  109769. * Current inertia value on the radius axis.
  109770. * The bigger this number the longer it will take for the camera to stop.
  109771. */
  109772. inertialRadiusOffset: number;
  109773. /**
  109774. * Minimum allowed angle on the longitudinal axis.
  109775. * This can help limiting how the Camera is able to move in the scene.
  109776. */
  109777. lowerAlphaLimit: Nullable<number>;
  109778. /**
  109779. * Maximum allowed angle on the longitudinal axis.
  109780. * This can help limiting how the Camera is able to move in the scene.
  109781. */
  109782. upperAlphaLimit: Nullable<number>;
  109783. /**
  109784. * Minimum allowed angle on the latitudinal axis.
  109785. * This can help limiting how the Camera is able to move in the scene.
  109786. */
  109787. lowerBetaLimit: number;
  109788. /**
  109789. * Maximum allowed angle on the latitudinal axis.
  109790. * This can help limiting how the Camera is able to move in the scene.
  109791. */
  109792. upperBetaLimit: number;
  109793. /**
  109794. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  109795. * This can help limiting how the Camera is able to move in the scene.
  109796. */
  109797. lowerRadiusLimit: Nullable<number>;
  109798. /**
  109799. * Maximum allowed distance of the camera to the target (The camera can not get further).
  109800. * This can help limiting how the Camera is able to move in the scene.
  109801. */
  109802. upperRadiusLimit: Nullable<number>;
  109803. /**
  109804. * Defines the current inertia value used during panning of the camera along the X axis.
  109805. */
  109806. inertialPanningX: number;
  109807. /**
  109808. * Defines the current inertia value used during panning of the camera along the Y axis.
  109809. */
  109810. inertialPanningY: number;
  109811. /**
  109812. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  109813. * Basically if your fingers moves away from more than this distance you will be considered
  109814. * in pinch mode.
  109815. */
  109816. pinchToPanMaxDistance: number;
  109817. /**
  109818. * Defines the maximum distance the camera can pan.
  109819. * This could help keeping the cammera always in your scene.
  109820. */
  109821. panningDistanceLimit: Nullable<number>;
  109822. /**
  109823. * Defines the target of the camera before paning.
  109824. */
  109825. panningOriginTarget: Vector3;
  109826. /**
  109827. * Defines the value of the inertia used during panning.
  109828. * 0 would mean stop inertia and one would mean no decelleration at all.
  109829. */
  109830. panningInertia: number;
  109831. /**
  109832. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  109833. */
  109834. get angularSensibilityX(): number;
  109835. set angularSensibilityX(value: number);
  109836. /**
  109837. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  109838. */
  109839. get angularSensibilityY(): number;
  109840. set angularSensibilityY(value: number);
  109841. /**
  109842. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  109843. */
  109844. get pinchPrecision(): number;
  109845. set pinchPrecision(value: number);
  109846. /**
  109847. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  109848. * It will be used instead of pinchDeltaPrecision if different from 0.
  109849. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109850. */
  109851. get pinchDeltaPercentage(): number;
  109852. set pinchDeltaPercentage(value: number);
  109853. /**
  109854. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  109855. */
  109856. get panningSensibility(): number;
  109857. set panningSensibility(value: number);
  109858. /**
  109859. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  109860. */
  109861. get keysUp(): number[];
  109862. set keysUp(value: number[]);
  109863. /**
  109864. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  109865. */
  109866. get keysDown(): number[];
  109867. set keysDown(value: number[]);
  109868. /**
  109869. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  109870. */
  109871. get keysLeft(): number[];
  109872. set keysLeft(value: number[]);
  109873. /**
  109874. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  109875. */
  109876. get keysRight(): number[];
  109877. set keysRight(value: number[]);
  109878. /**
  109879. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  109880. */
  109881. get wheelPrecision(): number;
  109882. set wheelPrecision(value: number);
  109883. /**
  109884. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  109885. * It will be used instead of pinchDeltaPrecision if different from 0.
  109886. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109887. */
  109888. get wheelDeltaPercentage(): number;
  109889. set wheelDeltaPercentage(value: number);
  109890. /**
  109891. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  109892. */
  109893. zoomOnFactor: number;
  109894. /**
  109895. * Defines a screen offset for the camera position.
  109896. */
  109897. targetScreenOffset: Vector2;
  109898. /**
  109899. * Allows the camera to be completely reversed.
  109900. * If false the camera can not arrive upside down.
  109901. */
  109902. allowUpsideDown: boolean;
  109903. /**
  109904. * Define if double tap/click is used to restore the previously saved state of the camera.
  109905. */
  109906. useInputToRestoreState: boolean;
  109907. /** @hidden */
  109908. _viewMatrix: Matrix;
  109909. /** @hidden */
  109910. _useCtrlForPanning: boolean;
  109911. /** @hidden */
  109912. _panningMouseButton: number;
  109913. /**
  109914. * Defines the input associated to the camera.
  109915. */
  109916. inputs: ArcRotateCameraInputsManager;
  109917. /** @hidden */
  109918. _reset: () => void;
  109919. /**
  109920. * Defines the allowed panning axis.
  109921. */
  109922. panningAxis: Vector3;
  109923. protected _localDirection: Vector3;
  109924. protected _transformedDirection: Vector3;
  109925. private _bouncingBehavior;
  109926. /**
  109927. * Gets the bouncing behavior of the camera if it has been enabled.
  109928. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109929. */
  109930. get bouncingBehavior(): Nullable<BouncingBehavior>;
  109931. /**
  109932. * Defines if the bouncing behavior of the camera is enabled on the camera.
  109933. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109934. */
  109935. get useBouncingBehavior(): boolean;
  109936. set useBouncingBehavior(value: boolean);
  109937. private _framingBehavior;
  109938. /**
  109939. * Gets the framing behavior of the camera if it has been enabled.
  109940. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109941. */
  109942. get framingBehavior(): Nullable<FramingBehavior>;
  109943. /**
  109944. * Defines if the framing behavior of the camera is enabled on the camera.
  109945. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109946. */
  109947. get useFramingBehavior(): boolean;
  109948. set useFramingBehavior(value: boolean);
  109949. private _autoRotationBehavior;
  109950. /**
  109951. * Gets the auto rotation behavior of the camera if it has been enabled.
  109952. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109953. */
  109954. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  109955. /**
  109956. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  109957. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109958. */
  109959. get useAutoRotationBehavior(): boolean;
  109960. set useAutoRotationBehavior(value: boolean);
  109961. /**
  109962. * Observable triggered when the mesh target has been changed on the camera.
  109963. */
  109964. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  109965. /**
  109966. * Event raised when the camera is colliding with a mesh.
  109967. */
  109968. onCollide: (collidedMesh: AbstractMesh) => void;
  109969. /**
  109970. * Defines whether the camera should check collision with the objects oh the scene.
  109971. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  109972. */
  109973. checkCollisions: boolean;
  109974. /**
  109975. * Defines the collision radius of the camera.
  109976. * This simulates a sphere around the camera.
  109977. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109978. */
  109979. collisionRadius: Vector3;
  109980. protected _collider: Collider;
  109981. protected _previousPosition: Vector3;
  109982. protected _collisionVelocity: Vector3;
  109983. protected _newPosition: Vector3;
  109984. protected _previousAlpha: number;
  109985. protected _previousBeta: number;
  109986. protected _previousRadius: number;
  109987. protected _collisionTriggered: boolean;
  109988. protected _targetBoundingCenter: Nullable<Vector3>;
  109989. private _computationVector;
  109990. /**
  109991. * Instantiates a new ArcRotateCamera in a given scene
  109992. * @param name Defines the name of the camera
  109993. * @param alpha Defines the camera rotation along the logitudinal axis
  109994. * @param beta Defines the camera rotation along the latitudinal axis
  109995. * @param radius Defines the camera distance from its target
  109996. * @param target Defines the camera target
  109997. * @param scene Defines the scene the camera belongs to
  109998. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109999. */
  110000. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110001. /** @hidden */
  110002. _initCache(): void;
  110003. /** @hidden */
  110004. _updateCache(ignoreParentClass?: boolean): void;
  110005. protected _getTargetPosition(): Vector3;
  110006. private _storedAlpha;
  110007. private _storedBeta;
  110008. private _storedRadius;
  110009. private _storedTarget;
  110010. private _storedTargetScreenOffset;
  110011. /**
  110012. * Stores the current state of the camera (alpha, beta, radius and target)
  110013. * @returns the camera itself
  110014. */
  110015. storeState(): Camera;
  110016. /**
  110017. * @hidden
  110018. * Restored camera state. You must call storeState() first
  110019. */
  110020. _restoreStateValues(): boolean;
  110021. /** @hidden */
  110022. _isSynchronizedViewMatrix(): boolean;
  110023. /**
  110024. * Attached controls to the current camera.
  110025. * @param element Defines the element the controls should be listened from
  110026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110027. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  110028. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  110029. */
  110030. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  110031. /**
  110032. * Detach the current controls from the camera.
  110033. * The camera will stop reacting to inputs.
  110034. * @param element Defines the element to stop listening the inputs from
  110035. */
  110036. detachControl(element: HTMLElement): void;
  110037. /** @hidden */
  110038. _checkInputs(): void;
  110039. protected _checkLimits(): void;
  110040. /**
  110041. * Rebuilds angles (alpha, beta) and radius from the give position and target
  110042. */
  110043. rebuildAnglesAndRadius(): void;
  110044. /**
  110045. * Use a position to define the current camera related information like alpha, beta and radius
  110046. * @param position Defines the position to set the camera at
  110047. */
  110048. setPosition(position: Vector3): void;
  110049. /**
  110050. * Defines the target the camera should look at.
  110051. * This will automatically adapt alpha beta and radius to fit within the new target.
  110052. * @param target Defines the new target as a Vector or a mesh
  110053. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  110054. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  110055. */
  110056. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  110057. /** @hidden */
  110058. _getViewMatrix(): Matrix;
  110059. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  110060. /**
  110061. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  110062. * @param meshes Defines the mesh to zoom on
  110063. * @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)
  110064. */
  110065. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  110066. /**
  110067. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  110068. * The target will be changed but the radius
  110069. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  110070. * @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)
  110071. */
  110072. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  110073. min: Vector3;
  110074. max: Vector3;
  110075. distance: number;
  110076. }, doNotUpdateMaxZ?: boolean): void;
  110077. /**
  110078. * @override
  110079. * Override Camera.createRigCamera
  110080. */
  110081. createRigCamera(name: string, cameraIndex: number): Camera;
  110082. /**
  110083. * @hidden
  110084. * @override
  110085. * Override Camera._updateRigCameras
  110086. */
  110087. _updateRigCameras(): void;
  110088. /**
  110089. * Destroy the camera and release the current resources hold by it.
  110090. */
  110091. dispose(): void;
  110092. /**
  110093. * Gets the current object class name.
  110094. * @return the class name
  110095. */
  110096. getClassName(): string;
  110097. }
  110098. }
  110099. declare module BABYLON {
  110100. /**
  110101. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  110102. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  110103. */
  110104. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  110105. /**
  110106. * Gets the name of the behavior.
  110107. */
  110108. get name(): string;
  110109. private _zoomStopsAnimation;
  110110. private _idleRotationSpeed;
  110111. private _idleRotationWaitTime;
  110112. private _idleRotationSpinupTime;
  110113. /**
  110114. * Sets the flag that indicates if user zooming should stop animation.
  110115. */
  110116. set zoomStopsAnimation(flag: boolean);
  110117. /**
  110118. * Gets the flag that indicates if user zooming should stop animation.
  110119. */
  110120. get zoomStopsAnimation(): boolean;
  110121. /**
  110122. * Sets the default speed at which the camera rotates around the model.
  110123. */
  110124. set idleRotationSpeed(speed: number);
  110125. /**
  110126. * Gets the default speed at which the camera rotates around the model.
  110127. */
  110128. get idleRotationSpeed(): number;
  110129. /**
  110130. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  110131. */
  110132. set idleRotationWaitTime(time: number);
  110133. /**
  110134. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  110135. */
  110136. get idleRotationWaitTime(): number;
  110137. /**
  110138. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  110139. */
  110140. set idleRotationSpinupTime(time: number);
  110141. /**
  110142. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  110143. */
  110144. get idleRotationSpinupTime(): number;
  110145. /**
  110146. * Gets a value indicating if the camera is currently rotating because of this behavior
  110147. */
  110148. get rotationInProgress(): boolean;
  110149. private _onPrePointerObservableObserver;
  110150. private _onAfterCheckInputsObserver;
  110151. private _attachedCamera;
  110152. private _isPointerDown;
  110153. private _lastFrameTime;
  110154. private _lastInteractionTime;
  110155. private _cameraRotationSpeed;
  110156. /**
  110157. * Initializes the behavior.
  110158. */
  110159. init(): void;
  110160. /**
  110161. * Attaches the behavior to its arc rotate camera.
  110162. * @param camera Defines the camera to attach the behavior to
  110163. */
  110164. attach(camera: ArcRotateCamera): void;
  110165. /**
  110166. * Detaches the behavior from its current arc rotate camera.
  110167. */
  110168. detach(): void;
  110169. /**
  110170. * Returns true if user is scrolling.
  110171. * @return true if user is scrolling.
  110172. */
  110173. private _userIsZooming;
  110174. private _lastFrameRadius;
  110175. private _shouldAnimationStopForInteraction;
  110176. /**
  110177. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  110178. */
  110179. private _applyUserInteraction;
  110180. private _userIsMoving;
  110181. }
  110182. }
  110183. declare module BABYLON {
  110184. /**
  110185. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  110186. */
  110187. export class AttachToBoxBehavior implements Behavior<Mesh> {
  110188. private ui;
  110189. /**
  110190. * The name of the behavior
  110191. */
  110192. name: string;
  110193. /**
  110194. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  110195. */
  110196. distanceAwayFromFace: number;
  110197. /**
  110198. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  110199. */
  110200. distanceAwayFromBottomOfFace: number;
  110201. private _faceVectors;
  110202. private _target;
  110203. private _scene;
  110204. private _onRenderObserver;
  110205. private _tmpMatrix;
  110206. private _tmpVector;
  110207. /**
  110208. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  110209. * @param ui The transform node that should be attched to the mesh
  110210. */
  110211. constructor(ui: TransformNode);
  110212. /**
  110213. * Initializes the behavior
  110214. */
  110215. init(): void;
  110216. private _closestFace;
  110217. private _zeroVector;
  110218. private _lookAtTmpMatrix;
  110219. private _lookAtToRef;
  110220. /**
  110221. * Attaches the AttachToBoxBehavior to the passed in mesh
  110222. * @param target The mesh that the specified node will be attached to
  110223. */
  110224. attach(target: Mesh): void;
  110225. /**
  110226. * Detaches the behavior from the mesh
  110227. */
  110228. detach(): void;
  110229. }
  110230. }
  110231. declare module BABYLON {
  110232. /**
  110233. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  110234. */
  110235. export class FadeInOutBehavior implements Behavior<Mesh> {
  110236. /**
  110237. * Time in milliseconds to delay before fading in (Default: 0)
  110238. */
  110239. delay: number;
  110240. /**
  110241. * Time in milliseconds for the mesh to fade in (Default: 300)
  110242. */
  110243. fadeInTime: number;
  110244. private _millisecondsPerFrame;
  110245. private _hovered;
  110246. private _hoverValue;
  110247. private _ownerNode;
  110248. /**
  110249. * Instatiates the FadeInOutBehavior
  110250. */
  110251. constructor();
  110252. /**
  110253. * The name of the behavior
  110254. */
  110255. get name(): string;
  110256. /**
  110257. * Initializes the behavior
  110258. */
  110259. init(): void;
  110260. /**
  110261. * Attaches the fade behavior on the passed in mesh
  110262. * @param ownerNode The mesh that will be faded in/out once attached
  110263. */
  110264. attach(ownerNode: Mesh): void;
  110265. /**
  110266. * Detaches the behavior from the mesh
  110267. */
  110268. detach(): void;
  110269. /**
  110270. * Triggers the mesh to begin fading in or out
  110271. * @param value if the object should fade in or out (true to fade in)
  110272. */
  110273. fadeIn(value: boolean): void;
  110274. private _update;
  110275. private _setAllVisibility;
  110276. }
  110277. }
  110278. declare module BABYLON {
  110279. /**
  110280. * Class containing a set of static utilities functions for managing Pivots
  110281. * @hidden
  110282. */
  110283. export class PivotTools {
  110284. private static _PivotCached;
  110285. private static _OldPivotPoint;
  110286. private static _PivotTranslation;
  110287. private static _PivotTmpVector;
  110288. /** @hidden */
  110289. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  110290. /** @hidden */
  110291. static _RestorePivotPoint(mesh: AbstractMesh): void;
  110292. }
  110293. }
  110294. declare module BABYLON {
  110295. /**
  110296. * Class containing static functions to help procedurally build meshes
  110297. */
  110298. export class PlaneBuilder {
  110299. /**
  110300. * Creates a plane mesh
  110301. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110302. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110303. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110307. * @param name defines the name of the mesh
  110308. * @param options defines the options used to create the mesh
  110309. * @param scene defines the hosting scene
  110310. * @returns the plane mesh
  110311. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110312. */
  110313. static CreatePlane(name: string, options: {
  110314. size?: number;
  110315. width?: number;
  110316. height?: number;
  110317. sideOrientation?: number;
  110318. frontUVs?: Vector4;
  110319. backUVs?: Vector4;
  110320. updatable?: boolean;
  110321. sourcePlane?: Plane;
  110322. }, scene?: Nullable<Scene>): Mesh;
  110323. }
  110324. }
  110325. declare module BABYLON {
  110326. /**
  110327. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  110328. */
  110329. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  110330. private static _AnyMouseID;
  110331. /**
  110332. * Abstract mesh the behavior is set on
  110333. */
  110334. attachedNode: AbstractMesh;
  110335. private _dragPlane;
  110336. private _scene;
  110337. private _pointerObserver;
  110338. private _beforeRenderObserver;
  110339. private static _planeScene;
  110340. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  110341. /**
  110342. * 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)
  110343. */
  110344. maxDragAngle: number;
  110345. /**
  110346. * @hidden
  110347. */
  110348. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  110349. /**
  110350. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  110351. */
  110352. currentDraggingPointerID: number;
  110353. /**
  110354. * The last position where the pointer hit the drag plane in world space
  110355. */
  110356. lastDragPosition: Vector3;
  110357. /**
  110358. * If the behavior is currently in a dragging state
  110359. */
  110360. dragging: boolean;
  110361. /**
  110362. * 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)
  110363. */
  110364. dragDeltaRatio: number;
  110365. /**
  110366. * If the drag plane orientation should be updated during the dragging (Default: true)
  110367. */
  110368. updateDragPlane: boolean;
  110369. private _debugMode;
  110370. private _moving;
  110371. /**
  110372. * Fires each time the attached mesh is dragged with the pointer
  110373. * * delta between last drag position and current drag position in world space
  110374. * * dragDistance along the drag axis
  110375. * * dragPlaneNormal normal of the current drag plane used during the drag
  110376. * * dragPlanePoint in world space where the drag intersects the drag plane
  110377. */
  110378. onDragObservable: Observable<{
  110379. delta: Vector3;
  110380. dragPlanePoint: Vector3;
  110381. dragPlaneNormal: Vector3;
  110382. dragDistance: number;
  110383. pointerId: number;
  110384. }>;
  110385. /**
  110386. * Fires each time a drag begins (eg. mouse down on mesh)
  110387. */
  110388. onDragStartObservable: Observable<{
  110389. dragPlanePoint: Vector3;
  110390. pointerId: number;
  110391. }>;
  110392. /**
  110393. * Fires each time a drag ends (eg. mouse release after drag)
  110394. */
  110395. onDragEndObservable: Observable<{
  110396. dragPlanePoint: Vector3;
  110397. pointerId: number;
  110398. }>;
  110399. /**
  110400. * If the attached mesh should be moved when dragged
  110401. */
  110402. moveAttached: boolean;
  110403. /**
  110404. * If the drag behavior will react to drag events (Default: true)
  110405. */
  110406. enabled: boolean;
  110407. /**
  110408. * If pointer events should start and release the drag (Default: true)
  110409. */
  110410. startAndReleaseDragOnPointerEvents: boolean;
  110411. /**
  110412. * If camera controls should be detached during the drag
  110413. */
  110414. detachCameraControls: boolean;
  110415. /**
  110416. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  110417. */
  110418. useObjectOrientationForDragging: boolean;
  110419. private _options;
  110420. /**
  110421. * Gets the options used by the behavior
  110422. */
  110423. get options(): {
  110424. dragAxis?: Vector3;
  110425. dragPlaneNormal?: Vector3;
  110426. };
  110427. /**
  110428. * Sets the options used by the behavior
  110429. */
  110430. set options(options: {
  110431. dragAxis?: Vector3;
  110432. dragPlaneNormal?: Vector3;
  110433. });
  110434. /**
  110435. * Creates a pointer drag behavior that can be attached to a mesh
  110436. * @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)
  110437. */
  110438. constructor(options?: {
  110439. dragAxis?: Vector3;
  110440. dragPlaneNormal?: Vector3;
  110441. });
  110442. /**
  110443. * Predicate to determine if it is valid to move the object to a new position when it is moved
  110444. */
  110445. validateDrag: (targetPosition: Vector3) => boolean;
  110446. /**
  110447. * The name of the behavior
  110448. */
  110449. get name(): string;
  110450. /**
  110451. * Initializes the behavior
  110452. */
  110453. init(): void;
  110454. private _tmpVector;
  110455. private _alternatePickedPoint;
  110456. private _worldDragAxis;
  110457. private _targetPosition;
  110458. private _attachedElement;
  110459. /**
  110460. * Attaches the drag behavior the passed in mesh
  110461. * @param ownerNode The mesh that will be dragged around once attached
  110462. * @param predicate Predicate to use for pick filtering
  110463. */
  110464. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  110465. /**
  110466. * Force relase the drag action by code.
  110467. */
  110468. releaseDrag(): void;
  110469. private _startDragRay;
  110470. private _lastPointerRay;
  110471. /**
  110472. * Simulates the start of a pointer drag event on the behavior
  110473. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  110474. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  110475. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  110476. */
  110477. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  110478. private _startDrag;
  110479. private _dragDelta;
  110480. private _moveDrag;
  110481. private _pickWithRayOnDragPlane;
  110482. private _pointA;
  110483. private _pointB;
  110484. private _pointC;
  110485. private _lineA;
  110486. private _lineB;
  110487. private _localAxis;
  110488. private _lookAt;
  110489. private _updateDragPlanePosition;
  110490. /**
  110491. * Detaches the behavior from the mesh
  110492. */
  110493. detach(): void;
  110494. }
  110495. }
  110496. declare module BABYLON {
  110497. /**
  110498. * A behavior that when attached to a mesh will allow the mesh to be scaled
  110499. */
  110500. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  110501. private _dragBehaviorA;
  110502. private _dragBehaviorB;
  110503. private _startDistance;
  110504. private _initialScale;
  110505. private _targetScale;
  110506. private _ownerNode;
  110507. private _sceneRenderObserver;
  110508. /**
  110509. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  110510. */
  110511. constructor();
  110512. /**
  110513. * The name of the behavior
  110514. */
  110515. get name(): string;
  110516. /**
  110517. * Initializes the behavior
  110518. */
  110519. init(): void;
  110520. private _getCurrentDistance;
  110521. /**
  110522. * Attaches the scale behavior the passed in mesh
  110523. * @param ownerNode The mesh that will be scaled around once attached
  110524. */
  110525. attach(ownerNode: Mesh): void;
  110526. /**
  110527. * Detaches the behavior from the mesh
  110528. */
  110529. detach(): void;
  110530. }
  110531. }
  110532. declare module BABYLON {
  110533. /**
  110534. * 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
  110535. */
  110536. export class SixDofDragBehavior implements Behavior<Mesh> {
  110537. private static _virtualScene;
  110538. private _ownerNode;
  110539. private _sceneRenderObserver;
  110540. private _scene;
  110541. private _targetPosition;
  110542. private _virtualOriginMesh;
  110543. private _virtualDragMesh;
  110544. private _pointerObserver;
  110545. private _moving;
  110546. private _startingOrientation;
  110547. /**
  110548. * 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)
  110549. */
  110550. private zDragFactor;
  110551. /**
  110552. * If the object should rotate to face the drag origin
  110553. */
  110554. rotateDraggedObject: boolean;
  110555. /**
  110556. * If the behavior is currently in a dragging state
  110557. */
  110558. dragging: boolean;
  110559. /**
  110560. * 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)
  110561. */
  110562. dragDeltaRatio: number;
  110563. /**
  110564. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  110565. */
  110566. currentDraggingPointerID: number;
  110567. /**
  110568. * If camera controls should be detached during the drag
  110569. */
  110570. detachCameraControls: boolean;
  110571. /**
  110572. * Fires each time a drag starts
  110573. */
  110574. onDragStartObservable: Observable<{}>;
  110575. /**
  110576. * Fires each time a drag ends (eg. mouse release after drag)
  110577. */
  110578. onDragEndObservable: Observable<{}>;
  110579. /**
  110580. * 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
  110581. */
  110582. constructor();
  110583. /**
  110584. * The name of the behavior
  110585. */
  110586. get name(): string;
  110587. /**
  110588. * Initializes the behavior
  110589. */
  110590. init(): void;
  110591. /**
  110592. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  110593. */
  110594. private get _pointerCamera();
  110595. /**
  110596. * Attaches the scale behavior the passed in mesh
  110597. * @param ownerNode The mesh that will be scaled around once attached
  110598. */
  110599. attach(ownerNode: Mesh): void;
  110600. /**
  110601. * Detaches the behavior from the mesh
  110602. */
  110603. detach(): void;
  110604. }
  110605. }
  110606. declare module BABYLON {
  110607. /**
  110608. * Class used to apply inverse kinematics to bones
  110609. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  110610. */
  110611. export class BoneIKController {
  110612. private static _tmpVecs;
  110613. private static _tmpQuat;
  110614. private static _tmpMats;
  110615. /**
  110616. * Gets or sets the target mesh
  110617. */
  110618. targetMesh: AbstractMesh;
  110619. /** Gets or sets the mesh used as pole */
  110620. poleTargetMesh: AbstractMesh;
  110621. /**
  110622. * Gets or sets the bone used as pole
  110623. */
  110624. poleTargetBone: Nullable<Bone>;
  110625. /**
  110626. * Gets or sets the target position
  110627. */
  110628. targetPosition: Vector3;
  110629. /**
  110630. * Gets or sets the pole target position
  110631. */
  110632. poleTargetPosition: Vector3;
  110633. /**
  110634. * Gets or sets the pole target local offset
  110635. */
  110636. poleTargetLocalOffset: Vector3;
  110637. /**
  110638. * Gets or sets the pole angle
  110639. */
  110640. poleAngle: number;
  110641. /**
  110642. * Gets or sets the mesh associated with the controller
  110643. */
  110644. mesh: AbstractMesh;
  110645. /**
  110646. * 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)
  110647. */
  110648. slerpAmount: number;
  110649. private _bone1Quat;
  110650. private _bone1Mat;
  110651. private _bone2Ang;
  110652. private _bone1;
  110653. private _bone2;
  110654. private _bone1Length;
  110655. private _bone2Length;
  110656. private _maxAngle;
  110657. private _maxReach;
  110658. private _rightHandedSystem;
  110659. private _bendAxis;
  110660. private _slerping;
  110661. private _adjustRoll;
  110662. /**
  110663. * Gets or sets maximum allowed angle
  110664. */
  110665. get maxAngle(): number;
  110666. set maxAngle(value: number);
  110667. /**
  110668. * Creates a new BoneIKController
  110669. * @param mesh defines the mesh to control
  110670. * @param bone defines the bone to control
  110671. * @param options defines options to set up the controller
  110672. */
  110673. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  110674. targetMesh?: AbstractMesh;
  110675. poleTargetMesh?: AbstractMesh;
  110676. poleTargetBone?: Bone;
  110677. poleTargetLocalOffset?: Vector3;
  110678. poleAngle?: number;
  110679. bendAxis?: Vector3;
  110680. maxAngle?: number;
  110681. slerpAmount?: number;
  110682. });
  110683. private _setMaxAngle;
  110684. /**
  110685. * Force the controller to update the bones
  110686. */
  110687. update(): void;
  110688. }
  110689. }
  110690. declare module BABYLON {
  110691. /**
  110692. * Class used to make a bone look toward a point in space
  110693. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  110694. */
  110695. export class BoneLookController {
  110696. private static _tmpVecs;
  110697. private static _tmpQuat;
  110698. private static _tmpMats;
  110699. /**
  110700. * The target Vector3 that the bone will look at
  110701. */
  110702. target: Vector3;
  110703. /**
  110704. * The mesh that the bone is attached to
  110705. */
  110706. mesh: AbstractMesh;
  110707. /**
  110708. * The bone that will be looking to the target
  110709. */
  110710. bone: Bone;
  110711. /**
  110712. * The up axis of the coordinate system that is used when the bone is rotated
  110713. */
  110714. upAxis: Vector3;
  110715. /**
  110716. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  110717. */
  110718. upAxisSpace: Space;
  110719. /**
  110720. * Used to make an adjustment to the yaw of the bone
  110721. */
  110722. adjustYaw: number;
  110723. /**
  110724. * Used to make an adjustment to the pitch of the bone
  110725. */
  110726. adjustPitch: number;
  110727. /**
  110728. * Used to make an adjustment to the roll of the bone
  110729. */
  110730. adjustRoll: number;
  110731. /**
  110732. * 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)
  110733. */
  110734. slerpAmount: number;
  110735. private _minYaw;
  110736. private _maxYaw;
  110737. private _minPitch;
  110738. private _maxPitch;
  110739. private _minYawSin;
  110740. private _minYawCos;
  110741. private _maxYawSin;
  110742. private _maxYawCos;
  110743. private _midYawConstraint;
  110744. private _minPitchTan;
  110745. private _maxPitchTan;
  110746. private _boneQuat;
  110747. private _slerping;
  110748. private _transformYawPitch;
  110749. private _transformYawPitchInv;
  110750. private _firstFrameSkipped;
  110751. private _yawRange;
  110752. private _fowardAxis;
  110753. /**
  110754. * Gets or sets the minimum yaw angle that the bone can look to
  110755. */
  110756. get minYaw(): number;
  110757. set minYaw(value: number);
  110758. /**
  110759. * Gets or sets the maximum yaw angle that the bone can look to
  110760. */
  110761. get maxYaw(): number;
  110762. set maxYaw(value: number);
  110763. /**
  110764. * Gets or sets the minimum pitch angle that the bone can look to
  110765. */
  110766. get minPitch(): number;
  110767. set minPitch(value: number);
  110768. /**
  110769. * Gets or sets the maximum pitch angle that the bone can look to
  110770. */
  110771. get maxPitch(): number;
  110772. set maxPitch(value: number);
  110773. /**
  110774. * Create a BoneLookController
  110775. * @param mesh the mesh that the bone belongs to
  110776. * @param bone the bone that will be looking to the target
  110777. * @param target the target Vector3 to look at
  110778. * @param options optional settings:
  110779. * * maxYaw: the maximum angle the bone will yaw to
  110780. * * minYaw: the minimum angle the bone will yaw to
  110781. * * maxPitch: the maximum angle the bone will pitch to
  110782. * * minPitch: the minimum angle the bone will yaw to
  110783. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  110784. * * upAxis: the up axis of the coordinate system
  110785. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  110786. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  110787. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  110788. * * adjustYaw: used to make an adjustment to the yaw of the bone
  110789. * * adjustPitch: used to make an adjustment to the pitch of the bone
  110790. * * adjustRoll: used to make an adjustment to the roll of the bone
  110791. **/
  110792. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  110793. maxYaw?: number;
  110794. minYaw?: number;
  110795. maxPitch?: number;
  110796. minPitch?: number;
  110797. slerpAmount?: number;
  110798. upAxis?: Vector3;
  110799. upAxisSpace?: Space;
  110800. yawAxis?: Vector3;
  110801. pitchAxis?: Vector3;
  110802. adjustYaw?: number;
  110803. adjustPitch?: number;
  110804. adjustRoll?: number;
  110805. });
  110806. /**
  110807. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  110808. */
  110809. update(): void;
  110810. private _getAngleDiff;
  110811. private _getAngleBetween;
  110812. private _isAngleBetween;
  110813. }
  110814. }
  110815. declare module BABYLON {
  110816. /**
  110817. * Manage the gamepad inputs to control an arc rotate camera.
  110818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110819. */
  110820. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  110821. /**
  110822. * Defines the camera the input is attached to.
  110823. */
  110824. camera: ArcRotateCamera;
  110825. /**
  110826. * Defines the gamepad the input is gathering event from.
  110827. */
  110828. gamepad: Nullable<Gamepad>;
  110829. /**
  110830. * Defines the gamepad rotation sensiblity.
  110831. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110832. */
  110833. gamepadRotationSensibility: number;
  110834. /**
  110835. * Defines the gamepad move sensiblity.
  110836. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110837. */
  110838. gamepadMoveSensibility: number;
  110839. private _yAxisScale;
  110840. /**
  110841. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  110842. */
  110843. get invertYAxis(): boolean;
  110844. set invertYAxis(value: boolean);
  110845. private _onGamepadConnectedObserver;
  110846. private _onGamepadDisconnectedObserver;
  110847. /**
  110848. * Attach the input controls to a specific dom element to get the input from.
  110849. * @param element Defines the element the controls should be listened from
  110850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110851. */
  110852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110853. /**
  110854. * Detach the current controls from the specified dom element.
  110855. * @param element Defines the element to stop listening the inputs from
  110856. */
  110857. detachControl(element: Nullable<HTMLElement>): void;
  110858. /**
  110859. * Update the current camera state depending on the inputs that have been used this frame.
  110860. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110861. */
  110862. checkInputs(): void;
  110863. /**
  110864. * Gets the class name of the current intput.
  110865. * @returns the class name
  110866. */
  110867. getClassName(): string;
  110868. /**
  110869. * Get the friendly name associated with the input class.
  110870. * @returns the input friendly name
  110871. */
  110872. getSimpleName(): string;
  110873. }
  110874. }
  110875. declare module BABYLON {
  110876. interface ArcRotateCameraInputsManager {
  110877. /**
  110878. * Add orientation input support to the input manager.
  110879. * @returns the current input manager
  110880. */
  110881. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  110882. }
  110883. /**
  110884. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  110885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110886. */
  110887. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  110888. /**
  110889. * Defines the camera the input is attached to.
  110890. */
  110891. camera: ArcRotateCamera;
  110892. /**
  110893. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  110894. */
  110895. alphaCorrection: number;
  110896. /**
  110897. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  110898. */
  110899. gammaCorrection: number;
  110900. private _alpha;
  110901. private _gamma;
  110902. private _dirty;
  110903. private _deviceOrientationHandler;
  110904. /**
  110905. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  110906. */
  110907. constructor();
  110908. /**
  110909. * Attach the input controls to a specific dom element to get the input from.
  110910. * @param element Defines the element the controls should be listened from
  110911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110912. */
  110913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110914. /** @hidden */
  110915. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  110916. /**
  110917. * Update the current camera state depending on the inputs that have been used this frame.
  110918. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110919. */
  110920. checkInputs(): void;
  110921. /**
  110922. * Detach the current controls from the specified dom element.
  110923. * @param element Defines the element to stop listening the inputs from
  110924. */
  110925. detachControl(element: Nullable<HTMLElement>): void;
  110926. /**
  110927. * Gets the class name of the current intput.
  110928. * @returns the class name
  110929. */
  110930. getClassName(): string;
  110931. /**
  110932. * Get the friendly name associated with the input class.
  110933. * @returns the input friendly name
  110934. */
  110935. getSimpleName(): string;
  110936. }
  110937. }
  110938. declare module BABYLON {
  110939. /**
  110940. * Listen to mouse events to control the camera.
  110941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110942. */
  110943. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  110944. /**
  110945. * Defines the camera the input is attached to.
  110946. */
  110947. camera: FlyCamera;
  110948. /**
  110949. * Defines if touch is enabled. (Default is true.)
  110950. */
  110951. touchEnabled: boolean;
  110952. /**
  110953. * Defines the buttons associated with the input to handle camera rotation.
  110954. */
  110955. buttons: number[];
  110956. /**
  110957. * Assign buttons for Yaw control.
  110958. */
  110959. buttonsYaw: number[];
  110960. /**
  110961. * Assign buttons for Pitch control.
  110962. */
  110963. buttonsPitch: number[];
  110964. /**
  110965. * Assign buttons for Roll control.
  110966. */
  110967. buttonsRoll: number[];
  110968. /**
  110969. * Detect if any button is being pressed while mouse is moved.
  110970. * -1 = Mouse locked.
  110971. * 0 = Left button.
  110972. * 1 = Middle Button.
  110973. * 2 = Right Button.
  110974. */
  110975. activeButton: number;
  110976. /**
  110977. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  110978. * Higher values reduce its sensitivity.
  110979. */
  110980. angularSensibility: number;
  110981. private _mousemoveCallback;
  110982. private _observer;
  110983. private _rollObserver;
  110984. private previousPosition;
  110985. private noPreventDefault;
  110986. private element;
  110987. /**
  110988. * Listen to mouse events to control the camera.
  110989. * @param touchEnabled Define if touch is enabled. (Default is true.)
  110990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110991. */
  110992. constructor(touchEnabled?: boolean);
  110993. /**
  110994. * Attach the mouse control to the HTML DOM element.
  110995. * @param element Defines the element that listens to the input events.
  110996. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  110997. */
  110998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110999. /**
  111000. * Detach the current controls from the specified dom element.
  111001. * @param element Defines the element to stop listening the inputs from
  111002. */
  111003. detachControl(element: Nullable<HTMLElement>): void;
  111004. /**
  111005. * Gets the class name of the current input.
  111006. * @returns the class name.
  111007. */
  111008. getClassName(): string;
  111009. /**
  111010. * Get the friendly name associated with the input class.
  111011. * @returns the input's friendly name.
  111012. */
  111013. getSimpleName(): string;
  111014. private _pointerInput;
  111015. private _onMouseMove;
  111016. /**
  111017. * Rotate camera by mouse offset.
  111018. */
  111019. private rotateCamera;
  111020. }
  111021. }
  111022. declare module BABYLON {
  111023. /**
  111024. * Default Inputs manager for the FlyCamera.
  111025. * It groups all the default supported inputs for ease of use.
  111026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111027. */
  111028. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  111029. /**
  111030. * Instantiates a new FlyCameraInputsManager.
  111031. * @param camera Defines the camera the inputs belong to.
  111032. */
  111033. constructor(camera: FlyCamera);
  111034. /**
  111035. * Add keyboard input support to the input manager.
  111036. * @returns the new FlyCameraKeyboardMoveInput().
  111037. */
  111038. addKeyboard(): FlyCameraInputsManager;
  111039. /**
  111040. * Add mouse input support to the input manager.
  111041. * @param touchEnabled Enable touch screen support.
  111042. * @returns the new FlyCameraMouseInput().
  111043. */
  111044. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  111045. }
  111046. }
  111047. declare module BABYLON {
  111048. /**
  111049. * This is a flying camera, designed for 3D movement and rotation in all directions,
  111050. * such as in a 3D Space Shooter or a Flight Simulator.
  111051. */
  111052. export class FlyCamera extends TargetCamera {
  111053. /**
  111054. * Define the collision ellipsoid of the camera.
  111055. * This is helpful for simulating a camera body, like a player's body.
  111056. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  111057. */
  111058. ellipsoid: Vector3;
  111059. /**
  111060. * Define an offset for the position of the ellipsoid around the camera.
  111061. * This can be helpful if the camera is attached away from the player's body center,
  111062. * such as at its head.
  111063. */
  111064. ellipsoidOffset: Vector3;
  111065. /**
  111066. * Enable or disable collisions of the camera with the rest of the scene objects.
  111067. */
  111068. checkCollisions: boolean;
  111069. /**
  111070. * Enable or disable gravity on the camera.
  111071. */
  111072. applyGravity: boolean;
  111073. /**
  111074. * Define the current direction the camera is moving to.
  111075. */
  111076. cameraDirection: Vector3;
  111077. /**
  111078. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  111079. * This overrides and empties cameraRotation.
  111080. */
  111081. rotationQuaternion: Quaternion;
  111082. /**
  111083. * Track Roll to maintain the wanted Rolling when looking around.
  111084. */
  111085. _trackRoll: number;
  111086. /**
  111087. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  111088. */
  111089. rollCorrect: number;
  111090. /**
  111091. * Mimic a banked turn, Rolling the camera when Yawing.
  111092. * It's recommended to use rollCorrect = 10 for faster banking correction.
  111093. */
  111094. bankedTurn: boolean;
  111095. /**
  111096. * Limit in radians for how much Roll banking will add. (Default: 90°)
  111097. */
  111098. bankedTurnLimit: number;
  111099. /**
  111100. * Value of 0 disables the banked Roll.
  111101. * Value of 1 is equal to the Yaw angle in radians.
  111102. */
  111103. bankedTurnMultiplier: number;
  111104. /**
  111105. * The inputs manager loads all the input sources, such as keyboard and mouse.
  111106. */
  111107. inputs: FlyCameraInputsManager;
  111108. /**
  111109. * Gets the input sensibility for mouse input.
  111110. * Higher values reduce sensitivity.
  111111. */
  111112. get angularSensibility(): number;
  111113. /**
  111114. * Sets the input sensibility for a mouse input.
  111115. * Higher values reduce sensitivity.
  111116. */
  111117. set angularSensibility(value: number);
  111118. /**
  111119. * Get the keys for camera movement forward.
  111120. */
  111121. get keysForward(): number[];
  111122. /**
  111123. * Set the keys for camera movement forward.
  111124. */
  111125. set keysForward(value: number[]);
  111126. /**
  111127. * Get the keys for camera movement backward.
  111128. */
  111129. get keysBackward(): number[];
  111130. set keysBackward(value: number[]);
  111131. /**
  111132. * Get the keys for camera movement up.
  111133. */
  111134. get keysUp(): number[];
  111135. /**
  111136. * Set the keys for camera movement up.
  111137. */
  111138. set keysUp(value: number[]);
  111139. /**
  111140. * Get the keys for camera movement down.
  111141. */
  111142. get keysDown(): number[];
  111143. /**
  111144. * Set the keys for camera movement down.
  111145. */
  111146. set keysDown(value: number[]);
  111147. /**
  111148. * Get the keys for camera movement left.
  111149. */
  111150. get keysLeft(): number[];
  111151. /**
  111152. * Set the keys for camera movement left.
  111153. */
  111154. set keysLeft(value: number[]);
  111155. /**
  111156. * Set the keys for camera movement right.
  111157. */
  111158. get keysRight(): number[];
  111159. /**
  111160. * Set the keys for camera movement right.
  111161. */
  111162. set keysRight(value: number[]);
  111163. /**
  111164. * Event raised when the camera collides with a mesh in the scene.
  111165. */
  111166. onCollide: (collidedMesh: AbstractMesh) => void;
  111167. private _collider;
  111168. private _needMoveForGravity;
  111169. private _oldPosition;
  111170. private _diffPosition;
  111171. private _newPosition;
  111172. /** @hidden */
  111173. _localDirection: Vector3;
  111174. /** @hidden */
  111175. _transformedDirection: Vector3;
  111176. /**
  111177. * Instantiates a FlyCamera.
  111178. * This is a flying camera, designed for 3D movement and rotation in all directions,
  111179. * such as in a 3D Space Shooter or a Flight Simulator.
  111180. * @param name Define the name of the camera in the scene.
  111181. * @param position Define the starting position of the camera in the scene.
  111182. * @param scene Define the scene the camera belongs to.
  111183. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  111184. */
  111185. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  111186. /**
  111187. * Attach a control to the HTML DOM element.
  111188. * @param element Defines the element that listens to the input events.
  111189. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  111190. */
  111191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111192. /**
  111193. * Detach a control from the HTML DOM element.
  111194. * The camera will stop reacting to that input.
  111195. * @param element Defines the element that listens to the input events.
  111196. */
  111197. detachControl(element: HTMLElement): void;
  111198. private _collisionMask;
  111199. /**
  111200. * Get the mask that the camera ignores in collision events.
  111201. */
  111202. get collisionMask(): number;
  111203. /**
  111204. * Set the mask that the camera ignores in collision events.
  111205. */
  111206. set collisionMask(mask: number);
  111207. /** @hidden */
  111208. _collideWithWorld(displacement: Vector3): void;
  111209. /** @hidden */
  111210. private _onCollisionPositionChange;
  111211. /** @hidden */
  111212. _checkInputs(): void;
  111213. /** @hidden */
  111214. _decideIfNeedsToMove(): boolean;
  111215. /** @hidden */
  111216. _updatePosition(): void;
  111217. /**
  111218. * Restore the Roll to its target value at the rate specified.
  111219. * @param rate - Higher means slower restoring.
  111220. * @hidden
  111221. */
  111222. restoreRoll(rate: number): void;
  111223. /**
  111224. * Destroy the camera and release the current resources held by it.
  111225. */
  111226. dispose(): void;
  111227. /**
  111228. * Get the current object class name.
  111229. * @returns the class name.
  111230. */
  111231. getClassName(): string;
  111232. }
  111233. }
  111234. declare module BABYLON {
  111235. /**
  111236. * Listen to keyboard events to control the camera.
  111237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111238. */
  111239. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  111240. /**
  111241. * Defines the camera the input is attached to.
  111242. */
  111243. camera: FlyCamera;
  111244. /**
  111245. * The list of keyboard keys used to control the forward move of the camera.
  111246. */
  111247. keysForward: number[];
  111248. /**
  111249. * The list of keyboard keys used to control the backward move of the camera.
  111250. */
  111251. keysBackward: number[];
  111252. /**
  111253. * The list of keyboard keys used to control the forward move of the camera.
  111254. */
  111255. keysUp: number[];
  111256. /**
  111257. * The list of keyboard keys used to control the backward move of the camera.
  111258. */
  111259. keysDown: number[];
  111260. /**
  111261. * The list of keyboard keys used to control the right strafe move of the camera.
  111262. */
  111263. keysRight: number[];
  111264. /**
  111265. * The list of keyboard keys used to control the left strafe move of the camera.
  111266. */
  111267. keysLeft: number[];
  111268. private _keys;
  111269. private _onCanvasBlurObserver;
  111270. private _onKeyboardObserver;
  111271. private _engine;
  111272. private _scene;
  111273. /**
  111274. * Attach the input controls to a specific dom element to get the input from.
  111275. * @param element Defines the element the controls should be listened from
  111276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111277. */
  111278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111279. /**
  111280. * Detach the current controls from the specified dom element.
  111281. * @param element Defines the element to stop listening the inputs from
  111282. */
  111283. detachControl(element: Nullable<HTMLElement>): void;
  111284. /**
  111285. * Gets the class name of the current intput.
  111286. * @returns the class name
  111287. */
  111288. getClassName(): string;
  111289. /** @hidden */
  111290. _onLostFocus(e: FocusEvent): void;
  111291. /**
  111292. * Get the friendly name associated with the input class.
  111293. * @returns the input friendly name
  111294. */
  111295. getSimpleName(): string;
  111296. /**
  111297. * Update the current camera state depending on the inputs that have been used this frame.
  111298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111299. */
  111300. checkInputs(): void;
  111301. }
  111302. }
  111303. declare module BABYLON {
  111304. /**
  111305. * Manage the mouse wheel inputs to control a follow camera.
  111306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111307. */
  111308. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  111309. /**
  111310. * Defines the camera the input is attached to.
  111311. */
  111312. camera: FollowCamera;
  111313. /**
  111314. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  111315. */
  111316. axisControlRadius: boolean;
  111317. /**
  111318. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  111319. */
  111320. axisControlHeight: boolean;
  111321. /**
  111322. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  111323. */
  111324. axisControlRotation: boolean;
  111325. /**
  111326. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  111327. * relation to mouseWheel events.
  111328. */
  111329. wheelPrecision: number;
  111330. /**
  111331. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111332. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111333. */
  111334. wheelDeltaPercentage: number;
  111335. private _wheel;
  111336. private _observer;
  111337. /**
  111338. * Attach the input controls to a specific dom element to get the input from.
  111339. * @param element Defines the element the controls should be listened from
  111340. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111341. */
  111342. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111343. /**
  111344. * Detach the current controls from the specified dom element.
  111345. * @param element Defines the element to stop listening the inputs from
  111346. */
  111347. detachControl(element: Nullable<HTMLElement>): void;
  111348. /**
  111349. * Gets the class name of the current intput.
  111350. * @returns the class name
  111351. */
  111352. getClassName(): string;
  111353. /**
  111354. * Get the friendly name associated with the input class.
  111355. * @returns the input friendly name
  111356. */
  111357. getSimpleName(): string;
  111358. }
  111359. }
  111360. declare module BABYLON {
  111361. /**
  111362. * Manage the pointers inputs to control an follow camera.
  111363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111364. */
  111365. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  111366. /**
  111367. * Defines the camera the input is attached to.
  111368. */
  111369. camera: FollowCamera;
  111370. /**
  111371. * Gets the class name of the current input.
  111372. * @returns the class name
  111373. */
  111374. getClassName(): string;
  111375. /**
  111376. * Defines the pointer angular sensibility along the X axis or how fast is
  111377. * the camera rotating.
  111378. * A negative number will reverse the axis direction.
  111379. */
  111380. angularSensibilityX: number;
  111381. /**
  111382. * Defines the pointer angular sensibility along the Y axis or how fast is
  111383. * the camera rotating.
  111384. * A negative number will reverse the axis direction.
  111385. */
  111386. angularSensibilityY: number;
  111387. /**
  111388. * Defines the pointer pinch precision or how fast is the camera zooming.
  111389. * A negative number will reverse the axis direction.
  111390. */
  111391. pinchPrecision: number;
  111392. /**
  111393. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111394. * from 0.
  111395. * It defines the percentage of current camera.radius to use as delta when
  111396. * pinch zoom is used.
  111397. */
  111398. pinchDeltaPercentage: number;
  111399. /**
  111400. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  111401. */
  111402. axisXControlRadius: boolean;
  111403. /**
  111404. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  111405. */
  111406. axisXControlHeight: boolean;
  111407. /**
  111408. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  111409. */
  111410. axisXControlRotation: boolean;
  111411. /**
  111412. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  111413. */
  111414. axisYControlRadius: boolean;
  111415. /**
  111416. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  111417. */
  111418. axisYControlHeight: boolean;
  111419. /**
  111420. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  111421. */
  111422. axisYControlRotation: boolean;
  111423. /**
  111424. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  111425. */
  111426. axisPinchControlRadius: boolean;
  111427. /**
  111428. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  111429. */
  111430. axisPinchControlHeight: boolean;
  111431. /**
  111432. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  111433. */
  111434. axisPinchControlRotation: boolean;
  111435. /**
  111436. * Log error messages if basic misconfiguration has occurred.
  111437. */
  111438. warningEnable: boolean;
  111439. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111440. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111441. private _warningCounter;
  111442. private _warning;
  111443. }
  111444. }
  111445. declare module BABYLON {
  111446. /**
  111447. * Default Inputs manager for the FollowCamera.
  111448. * It groups all the default supported inputs for ease of use.
  111449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111450. */
  111451. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  111452. /**
  111453. * Instantiates a new FollowCameraInputsManager.
  111454. * @param camera Defines the camera the inputs belong to
  111455. */
  111456. constructor(camera: FollowCamera);
  111457. /**
  111458. * Add keyboard input support to the input manager.
  111459. * @returns the current input manager
  111460. */
  111461. addKeyboard(): FollowCameraInputsManager;
  111462. /**
  111463. * Add mouse wheel input support to the input manager.
  111464. * @returns the current input manager
  111465. */
  111466. addMouseWheel(): FollowCameraInputsManager;
  111467. /**
  111468. * Add pointers input support to the input manager.
  111469. * @returns the current input manager
  111470. */
  111471. addPointers(): FollowCameraInputsManager;
  111472. /**
  111473. * Add orientation input support to the input manager.
  111474. * @returns the current input manager
  111475. */
  111476. addVRDeviceOrientation(): FollowCameraInputsManager;
  111477. }
  111478. }
  111479. declare module BABYLON {
  111480. /**
  111481. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  111482. * an arc rotate version arcFollowCamera are available.
  111483. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  111484. */
  111485. export class FollowCamera extends TargetCamera {
  111486. /**
  111487. * Distance the follow camera should follow an object at
  111488. */
  111489. radius: number;
  111490. /**
  111491. * Minimum allowed distance of the camera to the axis of rotation
  111492. * (The camera can not get closer).
  111493. * This can help limiting how the Camera is able to move in the scene.
  111494. */
  111495. lowerRadiusLimit: Nullable<number>;
  111496. /**
  111497. * Maximum allowed distance of the camera to the axis of rotation
  111498. * (The camera can not get further).
  111499. * This can help limiting how the Camera is able to move in the scene.
  111500. */
  111501. upperRadiusLimit: Nullable<number>;
  111502. /**
  111503. * Define a rotation offset between the camera and the object it follows
  111504. */
  111505. rotationOffset: number;
  111506. /**
  111507. * Minimum allowed angle to camera position relative to target object.
  111508. * This can help limiting how the Camera is able to move in the scene.
  111509. */
  111510. lowerRotationOffsetLimit: Nullable<number>;
  111511. /**
  111512. * Maximum allowed angle to camera position relative to target object.
  111513. * This can help limiting how the Camera is able to move in the scene.
  111514. */
  111515. upperRotationOffsetLimit: Nullable<number>;
  111516. /**
  111517. * Define a height offset between the camera and the object it follows.
  111518. * It can help following an object from the top (like a car chaing a plane)
  111519. */
  111520. heightOffset: number;
  111521. /**
  111522. * Minimum allowed height of camera position relative to target object.
  111523. * This can help limiting how the Camera is able to move in the scene.
  111524. */
  111525. lowerHeightOffsetLimit: Nullable<number>;
  111526. /**
  111527. * Maximum allowed height of camera position relative to target object.
  111528. * This can help limiting how the Camera is able to move in the scene.
  111529. */
  111530. upperHeightOffsetLimit: Nullable<number>;
  111531. /**
  111532. * Define how fast the camera can accelerate to follow it s target.
  111533. */
  111534. cameraAcceleration: number;
  111535. /**
  111536. * Define the speed limit of the camera following an object.
  111537. */
  111538. maxCameraSpeed: number;
  111539. /**
  111540. * Define the target of the camera.
  111541. */
  111542. lockedTarget: Nullable<AbstractMesh>;
  111543. /**
  111544. * Defines the input associated with the camera.
  111545. */
  111546. inputs: FollowCameraInputsManager;
  111547. /**
  111548. * Instantiates the follow camera.
  111549. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  111550. * @param name Define the name of the camera in the scene
  111551. * @param position Define the position of the camera
  111552. * @param scene Define the scene the camera belong to
  111553. * @param lockedTarget Define the target of the camera
  111554. */
  111555. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  111556. private _follow;
  111557. /**
  111558. * Attached controls to the current camera.
  111559. * @param element Defines the element the controls should be listened from
  111560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111561. */
  111562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111563. /**
  111564. * Detach the current controls from the camera.
  111565. * The camera will stop reacting to inputs.
  111566. * @param element Defines the element to stop listening the inputs from
  111567. */
  111568. detachControl(element: HTMLElement): void;
  111569. /** @hidden */
  111570. _checkInputs(): void;
  111571. private _checkLimits;
  111572. /**
  111573. * Gets the camera class name.
  111574. * @returns the class name
  111575. */
  111576. getClassName(): string;
  111577. }
  111578. /**
  111579. * Arc Rotate version of the follow camera.
  111580. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  111581. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  111582. */
  111583. export class ArcFollowCamera extends TargetCamera {
  111584. /** The longitudinal angle of the camera */
  111585. alpha: number;
  111586. /** The latitudinal angle of the camera */
  111587. beta: number;
  111588. /** The radius of the camera from its target */
  111589. radius: number;
  111590. /** Define the camera target (the messh it should follow) */
  111591. target: Nullable<AbstractMesh>;
  111592. private _cartesianCoordinates;
  111593. /**
  111594. * Instantiates a new ArcFollowCamera
  111595. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  111596. * @param name Define the name of the camera
  111597. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  111598. * @param beta Define the rotation angle of the camera around the elevation axis
  111599. * @param radius Define the radius of the camera from its target point
  111600. * @param target Define the target of the camera
  111601. * @param scene Define the scene the camera belongs to
  111602. */
  111603. constructor(name: string,
  111604. /** The longitudinal angle of the camera */
  111605. alpha: number,
  111606. /** The latitudinal angle of the camera */
  111607. beta: number,
  111608. /** The radius of the camera from its target */
  111609. radius: number,
  111610. /** Define the camera target (the messh it should follow) */
  111611. target: Nullable<AbstractMesh>, scene: Scene);
  111612. private _follow;
  111613. /** @hidden */
  111614. _checkInputs(): void;
  111615. /**
  111616. * Returns the class name of the object.
  111617. * It is mostly used internally for serialization purposes.
  111618. */
  111619. getClassName(): string;
  111620. }
  111621. }
  111622. declare module BABYLON {
  111623. /**
  111624. * Manage the keyboard inputs to control the movement of a follow camera.
  111625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111626. */
  111627. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  111628. /**
  111629. * Defines the camera the input is attached to.
  111630. */
  111631. camera: FollowCamera;
  111632. /**
  111633. * Defines the list of key codes associated with the up action (increase heightOffset)
  111634. */
  111635. keysHeightOffsetIncr: number[];
  111636. /**
  111637. * Defines the list of key codes associated with the down action (decrease heightOffset)
  111638. */
  111639. keysHeightOffsetDecr: number[];
  111640. /**
  111641. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  111642. */
  111643. keysHeightOffsetModifierAlt: boolean;
  111644. /**
  111645. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  111646. */
  111647. keysHeightOffsetModifierCtrl: boolean;
  111648. /**
  111649. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  111650. */
  111651. keysHeightOffsetModifierShift: boolean;
  111652. /**
  111653. * Defines the list of key codes associated with the left action (increase rotationOffset)
  111654. */
  111655. keysRotationOffsetIncr: number[];
  111656. /**
  111657. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  111658. */
  111659. keysRotationOffsetDecr: number[];
  111660. /**
  111661. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  111662. */
  111663. keysRotationOffsetModifierAlt: boolean;
  111664. /**
  111665. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  111666. */
  111667. keysRotationOffsetModifierCtrl: boolean;
  111668. /**
  111669. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  111670. */
  111671. keysRotationOffsetModifierShift: boolean;
  111672. /**
  111673. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  111674. */
  111675. keysRadiusIncr: number[];
  111676. /**
  111677. * Defines the list of key codes associated with the zoom-out action (increase radius)
  111678. */
  111679. keysRadiusDecr: number[];
  111680. /**
  111681. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  111682. */
  111683. keysRadiusModifierAlt: boolean;
  111684. /**
  111685. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  111686. */
  111687. keysRadiusModifierCtrl: boolean;
  111688. /**
  111689. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  111690. */
  111691. keysRadiusModifierShift: boolean;
  111692. /**
  111693. * Defines the rate of change of heightOffset.
  111694. */
  111695. heightSensibility: number;
  111696. /**
  111697. * Defines the rate of change of rotationOffset.
  111698. */
  111699. rotationSensibility: number;
  111700. /**
  111701. * Defines the rate of change of radius.
  111702. */
  111703. radiusSensibility: number;
  111704. private _keys;
  111705. private _ctrlPressed;
  111706. private _altPressed;
  111707. private _shiftPressed;
  111708. private _onCanvasBlurObserver;
  111709. private _onKeyboardObserver;
  111710. private _engine;
  111711. private _scene;
  111712. /**
  111713. * Attach the input controls to a specific dom element to get the input from.
  111714. * @param element Defines the element the controls should be listened from
  111715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111716. */
  111717. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111718. /**
  111719. * Detach the current controls from the specified dom element.
  111720. * @param element Defines the element to stop listening the inputs from
  111721. */
  111722. detachControl(element: Nullable<HTMLElement>): void;
  111723. /**
  111724. * Update the current camera state depending on the inputs that have been used this frame.
  111725. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111726. */
  111727. checkInputs(): void;
  111728. /**
  111729. * Gets the class name of the current input.
  111730. * @returns the class name
  111731. */
  111732. getClassName(): string;
  111733. /**
  111734. * Get the friendly name associated with the input class.
  111735. * @returns the input friendly name
  111736. */
  111737. getSimpleName(): string;
  111738. /**
  111739. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  111740. * allow modification of the heightOffset value.
  111741. */
  111742. private _modifierHeightOffset;
  111743. /**
  111744. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  111745. * allow modification of the rotationOffset value.
  111746. */
  111747. private _modifierRotationOffset;
  111748. /**
  111749. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  111750. * allow modification of the radius value.
  111751. */
  111752. private _modifierRadius;
  111753. }
  111754. }
  111755. declare module BABYLON {
  111756. interface FreeCameraInputsManager {
  111757. /**
  111758. * @hidden
  111759. */
  111760. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  111761. /**
  111762. * Add orientation input support to the input manager.
  111763. * @returns the current input manager
  111764. */
  111765. addDeviceOrientation(): FreeCameraInputsManager;
  111766. }
  111767. /**
  111768. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  111769. * Screen rotation is taken into account.
  111770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111771. */
  111772. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  111773. private _camera;
  111774. private _screenOrientationAngle;
  111775. private _constantTranform;
  111776. private _screenQuaternion;
  111777. private _alpha;
  111778. private _beta;
  111779. private _gamma;
  111780. /**
  111781. * Can be used to detect if a device orientation sensor is available on a device
  111782. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  111783. * @returns a promise that will resolve on orientation change
  111784. */
  111785. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  111786. /**
  111787. * @hidden
  111788. */
  111789. _onDeviceOrientationChangedObservable: Observable<void>;
  111790. /**
  111791. * Instantiates a new input
  111792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111793. */
  111794. constructor();
  111795. /**
  111796. * Define the camera controlled by the input.
  111797. */
  111798. get camera(): FreeCamera;
  111799. set camera(camera: FreeCamera);
  111800. /**
  111801. * Attach the input controls to a specific dom element to get the input from.
  111802. * @param element Defines the element the controls should be listened from
  111803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111804. */
  111805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111806. private _orientationChanged;
  111807. private _deviceOrientation;
  111808. /**
  111809. * Detach the current controls from the specified dom element.
  111810. * @param element Defines the element to stop listening the inputs from
  111811. */
  111812. detachControl(element: Nullable<HTMLElement>): void;
  111813. /**
  111814. * Update the current camera state depending on the inputs that have been used this frame.
  111815. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111816. */
  111817. checkInputs(): void;
  111818. /**
  111819. * Gets the class name of the current intput.
  111820. * @returns the class name
  111821. */
  111822. getClassName(): string;
  111823. /**
  111824. * Get the friendly name associated with the input class.
  111825. * @returns the input friendly name
  111826. */
  111827. getSimpleName(): string;
  111828. }
  111829. }
  111830. declare module BABYLON {
  111831. /**
  111832. * Manage the gamepad inputs to control a free camera.
  111833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111834. */
  111835. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  111836. /**
  111837. * Define the camera the input is attached to.
  111838. */
  111839. camera: FreeCamera;
  111840. /**
  111841. * Define the Gamepad controlling the input
  111842. */
  111843. gamepad: Nullable<Gamepad>;
  111844. /**
  111845. * Defines the gamepad rotation sensiblity.
  111846. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111847. */
  111848. gamepadAngularSensibility: number;
  111849. /**
  111850. * Defines the gamepad move sensiblity.
  111851. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111852. */
  111853. gamepadMoveSensibility: number;
  111854. private _yAxisScale;
  111855. /**
  111856. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  111857. */
  111858. get invertYAxis(): boolean;
  111859. set invertYAxis(value: boolean);
  111860. private _onGamepadConnectedObserver;
  111861. private _onGamepadDisconnectedObserver;
  111862. private _cameraTransform;
  111863. private _deltaTransform;
  111864. private _vector3;
  111865. private _vector2;
  111866. /**
  111867. * Attach the input controls to a specific dom element to get the input from.
  111868. * @param element Defines the element the controls should be listened from
  111869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111870. */
  111871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111872. /**
  111873. * Detach the current controls from the specified dom element.
  111874. * @param element Defines the element to stop listening the inputs from
  111875. */
  111876. detachControl(element: Nullable<HTMLElement>): void;
  111877. /**
  111878. * Update the current camera state depending on the inputs that have been used this frame.
  111879. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111880. */
  111881. checkInputs(): void;
  111882. /**
  111883. * Gets the class name of the current intput.
  111884. * @returns the class name
  111885. */
  111886. getClassName(): string;
  111887. /**
  111888. * Get the friendly name associated with the input class.
  111889. * @returns the input friendly name
  111890. */
  111891. getSimpleName(): string;
  111892. }
  111893. }
  111894. declare module BABYLON {
  111895. /**
  111896. * Defines the potential axis of a Joystick
  111897. */
  111898. export enum JoystickAxis {
  111899. /** X axis */
  111900. X = 0,
  111901. /** Y axis */
  111902. Y = 1,
  111903. /** Z axis */
  111904. Z = 2
  111905. }
  111906. /**
  111907. * Class used to define virtual joystick (used in touch mode)
  111908. */
  111909. export class VirtualJoystick {
  111910. /**
  111911. * Gets or sets a boolean indicating that left and right values must be inverted
  111912. */
  111913. reverseLeftRight: boolean;
  111914. /**
  111915. * Gets or sets a boolean indicating that up and down values must be inverted
  111916. */
  111917. reverseUpDown: boolean;
  111918. /**
  111919. * Gets the offset value for the position (ie. the change of the position value)
  111920. */
  111921. deltaPosition: Vector3;
  111922. /**
  111923. * Gets a boolean indicating if the virtual joystick was pressed
  111924. */
  111925. pressed: boolean;
  111926. /**
  111927. * Canvas the virtual joystick will render onto, default z-index of this is 5
  111928. */
  111929. static Canvas: Nullable<HTMLCanvasElement>;
  111930. private static _globalJoystickIndex;
  111931. private static vjCanvasContext;
  111932. private static vjCanvasWidth;
  111933. private static vjCanvasHeight;
  111934. private static halfWidth;
  111935. private _action;
  111936. private _axisTargetedByLeftAndRight;
  111937. private _axisTargetedByUpAndDown;
  111938. private _joystickSensibility;
  111939. private _inversedSensibility;
  111940. private _joystickPointerID;
  111941. private _joystickColor;
  111942. private _joystickPointerPos;
  111943. private _joystickPreviousPointerPos;
  111944. private _joystickPointerStartPos;
  111945. private _deltaJoystickVector;
  111946. private _leftJoystick;
  111947. private _touches;
  111948. private _onPointerDownHandlerRef;
  111949. private _onPointerMoveHandlerRef;
  111950. private _onPointerUpHandlerRef;
  111951. private _onResize;
  111952. /**
  111953. * Creates a new virtual joystick
  111954. * @param leftJoystick defines that the joystick is for left hand (false by default)
  111955. */
  111956. constructor(leftJoystick?: boolean);
  111957. /**
  111958. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  111959. * @param newJoystickSensibility defines the new sensibility
  111960. */
  111961. setJoystickSensibility(newJoystickSensibility: number): void;
  111962. private _onPointerDown;
  111963. private _onPointerMove;
  111964. private _onPointerUp;
  111965. /**
  111966. * Change the color of the virtual joystick
  111967. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  111968. */
  111969. setJoystickColor(newColor: string): void;
  111970. /**
  111971. * Defines a callback to call when the joystick is touched
  111972. * @param action defines the callback
  111973. */
  111974. setActionOnTouch(action: () => any): void;
  111975. /**
  111976. * Defines which axis you'd like to control for left & right
  111977. * @param axis defines the axis to use
  111978. */
  111979. setAxisForLeftRight(axis: JoystickAxis): void;
  111980. /**
  111981. * Defines which axis you'd like to control for up & down
  111982. * @param axis defines the axis to use
  111983. */
  111984. setAxisForUpDown(axis: JoystickAxis): void;
  111985. private _drawVirtualJoystick;
  111986. /**
  111987. * Release internal HTML canvas
  111988. */
  111989. releaseCanvas(): void;
  111990. }
  111991. }
  111992. declare module BABYLON {
  111993. interface FreeCameraInputsManager {
  111994. /**
  111995. * Add virtual joystick input support to the input manager.
  111996. * @returns the current input manager
  111997. */
  111998. addVirtualJoystick(): FreeCameraInputsManager;
  111999. }
  112000. /**
  112001. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  112002. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112003. */
  112004. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  112005. /**
  112006. * Defines the camera the input is attached to.
  112007. */
  112008. camera: FreeCamera;
  112009. private _leftjoystick;
  112010. private _rightjoystick;
  112011. /**
  112012. * Gets the left stick of the virtual joystick.
  112013. * @returns The virtual Joystick
  112014. */
  112015. getLeftJoystick(): VirtualJoystick;
  112016. /**
  112017. * Gets the right stick of the virtual joystick.
  112018. * @returns The virtual Joystick
  112019. */
  112020. getRightJoystick(): VirtualJoystick;
  112021. /**
  112022. * Update the current camera state depending on the inputs that have been used this frame.
  112023. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112024. */
  112025. checkInputs(): void;
  112026. /**
  112027. * Attach the input controls to a specific dom element to get the input from.
  112028. * @param element Defines the element the controls should be listened from
  112029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112030. */
  112031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112032. /**
  112033. * Detach the current controls from the specified dom element.
  112034. * @param element Defines the element to stop listening the inputs from
  112035. */
  112036. detachControl(element: Nullable<HTMLElement>): void;
  112037. /**
  112038. * Gets the class name of the current intput.
  112039. * @returns the class name
  112040. */
  112041. getClassName(): string;
  112042. /**
  112043. * Get the friendly name associated with the input class.
  112044. * @returns the input friendly name
  112045. */
  112046. getSimpleName(): string;
  112047. }
  112048. }
  112049. declare module BABYLON {
  112050. /**
  112051. * This represents a FPS type of camera controlled by touch.
  112052. * This is like a universal camera minus the Gamepad controls.
  112053. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112054. */
  112055. export class TouchCamera extends FreeCamera {
  112056. /**
  112057. * Defines the touch sensibility for rotation.
  112058. * The higher the faster.
  112059. */
  112060. get touchAngularSensibility(): number;
  112061. set touchAngularSensibility(value: number);
  112062. /**
  112063. * Defines the touch sensibility for move.
  112064. * The higher the faster.
  112065. */
  112066. get touchMoveSensibility(): number;
  112067. set touchMoveSensibility(value: number);
  112068. /**
  112069. * Instantiates a new touch camera.
  112070. * This represents a FPS type of camera controlled by touch.
  112071. * This is like a universal camera minus the Gamepad controls.
  112072. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112073. * @param name Define the name of the camera in the scene
  112074. * @param position Define the start position of the camera in the scene
  112075. * @param scene Define the scene the camera belongs to
  112076. */
  112077. constructor(name: string, position: Vector3, scene: Scene);
  112078. /**
  112079. * Gets the current object class name.
  112080. * @return the class name
  112081. */
  112082. getClassName(): string;
  112083. /** @hidden */
  112084. _setupInputs(): void;
  112085. }
  112086. }
  112087. declare module BABYLON {
  112088. /**
  112089. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  112090. * being tilted forward or back and left or right.
  112091. */
  112092. export class DeviceOrientationCamera extends FreeCamera {
  112093. private _initialQuaternion;
  112094. private _quaternionCache;
  112095. private _tmpDragQuaternion;
  112096. private _disablePointerInputWhenUsingDeviceOrientation;
  112097. /**
  112098. * Creates a new device orientation camera
  112099. * @param name The name of the camera
  112100. * @param position The start position camera
  112101. * @param scene The scene the camera belongs to
  112102. */
  112103. constructor(name: string, position: Vector3, scene: Scene);
  112104. /**
  112105. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  112106. */
  112107. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  112108. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  112109. private _dragFactor;
  112110. /**
  112111. * Enabled turning on the y axis when the orientation sensor is active
  112112. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  112113. */
  112114. enableHorizontalDragging(dragFactor?: number): void;
  112115. /**
  112116. * Gets the current instance class name ("DeviceOrientationCamera").
  112117. * This helps avoiding instanceof at run time.
  112118. * @returns the class name
  112119. */
  112120. getClassName(): string;
  112121. /**
  112122. * @hidden
  112123. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  112124. */
  112125. _checkInputs(): void;
  112126. /**
  112127. * Reset the camera to its default orientation on the specified axis only.
  112128. * @param axis The axis to reset
  112129. */
  112130. resetToCurrentRotation(axis?: Axis): void;
  112131. }
  112132. }
  112133. declare module BABYLON {
  112134. /**
  112135. * Defines supported buttons for XBox360 compatible gamepads
  112136. */
  112137. export enum Xbox360Button {
  112138. /** A */
  112139. A = 0,
  112140. /** B */
  112141. B = 1,
  112142. /** X */
  112143. X = 2,
  112144. /** Y */
  112145. Y = 3,
  112146. /** Start */
  112147. Start = 4,
  112148. /** Back */
  112149. Back = 5,
  112150. /** Left button */
  112151. LB = 6,
  112152. /** Right button */
  112153. RB = 7,
  112154. /** Left stick */
  112155. LeftStick = 8,
  112156. /** Right stick */
  112157. RightStick = 9
  112158. }
  112159. /** Defines values for XBox360 DPad */
  112160. export enum Xbox360Dpad {
  112161. /** Up */
  112162. Up = 0,
  112163. /** Down */
  112164. Down = 1,
  112165. /** Left */
  112166. Left = 2,
  112167. /** Right */
  112168. Right = 3
  112169. }
  112170. /**
  112171. * Defines a XBox360 gamepad
  112172. */
  112173. export class Xbox360Pad extends Gamepad {
  112174. private _leftTrigger;
  112175. private _rightTrigger;
  112176. private _onlefttriggerchanged;
  112177. private _onrighttriggerchanged;
  112178. private _onbuttondown;
  112179. private _onbuttonup;
  112180. private _ondpaddown;
  112181. private _ondpadup;
  112182. /** Observable raised when a button is pressed */
  112183. onButtonDownObservable: Observable<Xbox360Button>;
  112184. /** Observable raised when a button is released */
  112185. onButtonUpObservable: Observable<Xbox360Button>;
  112186. /** Observable raised when a pad is pressed */
  112187. onPadDownObservable: Observable<Xbox360Dpad>;
  112188. /** Observable raised when a pad is released */
  112189. onPadUpObservable: Observable<Xbox360Dpad>;
  112190. private _buttonA;
  112191. private _buttonB;
  112192. private _buttonX;
  112193. private _buttonY;
  112194. private _buttonBack;
  112195. private _buttonStart;
  112196. private _buttonLB;
  112197. private _buttonRB;
  112198. private _buttonLeftStick;
  112199. private _buttonRightStick;
  112200. private _dPadUp;
  112201. private _dPadDown;
  112202. private _dPadLeft;
  112203. private _dPadRight;
  112204. private _isXboxOnePad;
  112205. /**
  112206. * Creates a new XBox360 gamepad object
  112207. * @param id defines the id of this gamepad
  112208. * @param index defines its index
  112209. * @param gamepad defines the internal HTML gamepad object
  112210. * @param xboxOne defines if it is a XBox One gamepad
  112211. */
  112212. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  112213. /**
  112214. * Defines the callback to call when left trigger is pressed
  112215. * @param callback defines the callback to use
  112216. */
  112217. onlefttriggerchanged(callback: (value: number) => void): void;
  112218. /**
  112219. * Defines the callback to call when right trigger is pressed
  112220. * @param callback defines the callback to use
  112221. */
  112222. onrighttriggerchanged(callback: (value: number) => void): void;
  112223. /**
  112224. * Gets the left trigger value
  112225. */
  112226. get leftTrigger(): number;
  112227. /**
  112228. * Sets the left trigger value
  112229. */
  112230. set leftTrigger(newValue: number);
  112231. /**
  112232. * Gets the right trigger value
  112233. */
  112234. get rightTrigger(): number;
  112235. /**
  112236. * Sets the right trigger value
  112237. */
  112238. set rightTrigger(newValue: number);
  112239. /**
  112240. * Defines the callback to call when a button is pressed
  112241. * @param callback defines the callback to use
  112242. */
  112243. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  112244. /**
  112245. * Defines the callback to call when a button is released
  112246. * @param callback defines the callback to use
  112247. */
  112248. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  112249. /**
  112250. * Defines the callback to call when a pad is pressed
  112251. * @param callback defines the callback to use
  112252. */
  112253. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  112254. /**
  112255. * Defines the callback to call when a pad is released
  112256. * @param callback defines the callback to use
  112257. */
  112258. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  112259. private _setButtonValue;
  112260. private _setDPadValue;
  112261. /**
  112262. * Gets the value of the `A` button
  112263. */
  112264. get buttonA(): number;
  112265. /**
  112266. * Sets the value of the `A` button
  112267. */
  112268. set buttonA(value: number);
  112269. /**
  112270. * Gets the value of the `B` button
  112271. */
  112272. get buttonB(): number;
  112273. /**
  112274. * Sets the value of the `B` button
  112275. */
  112276. set buttonB(value: number);
  112277. /**
  112278. * Gets the value of the `X` button
  112279. */
  112280. get buttonX(): number;
  112281. /**
  112282. * Sets the value of the `X` button
  112283. */
  112284. set buttonX(value: number);
  112285. /**
  112286. * Gets the value of the `Y` button
  112287. */
  112288. get buttonY(): number;
  112289. /**
  112290. * Sets the value of the `Y` button
  112291. */
  112292. set buttonY(value: number);
  112293. /**
  112294. * Gets the value of the `Start` button
  112295. */
  112296. get buttonStart(): number;
  112297. /**
  112298. * Sets the value of the `Start` button
  112299. */
  112300. set buttonStart(value: number);
  112301. /**
  112302. * Gets the value of the `Back` button
  112303. */
  112304. get buttonBack(): number;
  112305. /**
  112306. * Sets the value of the `Back` button
  112307. */
  112308. set buttonBack(value: number);
  112309. /**
  112310. * Gets the value of the `Left` button
  112311. */
  112312. get buttonLB(): number;
  112313. /**
  112314. * Sets the value of the `Left` button
  112315. */
  112316. set buttonLB(value: number);
  112317. /**
  112318. * Gets the value of the `Right` button
  112319. */
  112320. get buttonRB(): number;
  112321. /**
  112322. * Sets the value of the `Right` button
  112323. */
  112324. set buttonRB(value: number);
  112325. /**
  112326. * Gets the value of the Left joystick
  112327. */
  112328. get buttonLeftStick(): number;
  112329. /**
  112330. * Sets the value of the Left joystick
  112331. */
  112332. set buttonLeftStick(value: number);
  112333. /**
  112334. * Gets the value of the Right joystick
  112335. */
  112336. get buttonRightStick(): number;
  112337. /**
  112338. * Sets the value of the Right joystick
  112339. */
  112340. set buttonRightStick(value: number);
  112341. /**
  112342. * Gets the value of D-pad up
  112343. */
  112344. get dPadUp(): number;
  112345. /**
  112346. * Sets the value of D-pad up
  112347. */
  112348. set dPadUp(value: number);
  112349. /**
  112350. * Gets the value of D-pad down
  112351. */
  112352. get dPadDown(): number;
  112353. /**
  112354. * Sets the value of D-pad down
  112355. */
  112356. set dPadDown(value: number);
  112357. /**
  112358. * Gets the value of D-pad left
  112359. */
  112360. get dPadLeft(): number;
  112361. /**
  112362. * Sets the value of D-pad left
  112363. */
  112364. set dPadLeft(value: number);
  112365. /**
  112366. * Gets the value of D-pad right
  112367. */
  112368. get dPadRight(): number;
  112369. /**
  112370. * Sets the value of D-pad right
  112371. */
  112372. set dPadRight(value: number);
  112373. /**
  112374. * Force the gamepad to synchronize with device values
  112375. */
  112376. update(): void;
  112377. /**
  112378. * Disposes the gamepad
  112379. */
  112380. dispose(): void;
  112381. }
  112382. }
  112383. declare module BABYLON {
  112384. /**
  112385. * Defines supported buttons for DualShock compatible gamepads
  112386. */
  112387. export enum DualShockButton {
  112388. /** Cross */
  112389. Cross = 0,
  112390. /** Circle */
  112391. Circle = 1,
  112392. /** Square */
  112393. Square = 2,
  112394. /** Triangle */
  112395. Triangle = 3,
  112396. /** Options */
  112397. Options = 4,
  112398. /** Share */
  112399. Share = 5,
  112400. /** L1 */
  112401. L1 = 6,
  112402. /** R1 */
  112403. R1 = 7,
  112404. /** Left stick */
  112405. LeftStick = 8,
  112406. /** Right stick */
  112407. RightStick = 9
  112408. }
  112409. /** Defines values for DualShock DPad */
  112410. export enum DualShockDpad {
  112411. /** Up */
  112412. Up = 0,
  112413. /** Down */
  112414. Down = 1,
  112415. /** Left */
  112416. Left = 2,
  112417. /** Right */
  112418. Right = 3
  112419. }
  112420. /**
  112421. * Defines a DualShock gamepad
  112422. */
  112423. export class DualShockPad extends Gamepad {
  112424. private _leftTrigger;
  112425. private _rightTrigger;
  112426. private _onlefttriggerchanged;
  112427. private _onrighttriggerchanged;
  112428. private _onbuttondown;
  112429. private _onbuttonup;
  112430. private _ondpaddown;
  112431. private _ondpadup;
  112432. /** Observable raised when a button is pressed */
  112433. onButtonDownObservable: Observable<DualShockButton>;
  112434. /** Observable raised when a button is released */
  112435. onButtonUpObservable: Observable<DualShockButton>;
  112436. /** Observable raised when a pad is pressed */
  112437. onPadDownObservable: Observable<DualShockDpad>;
  112438. /** Observable raised when a pad is released */
  112439. onPadUpObservable: Observable<DualShockDpad>;
  112440. private _buttonCross;
  112441. private _buttonCircle;
  112442. private _buttonSquare;
  112443. private _buttonTriangle;
  112444. private _buttonShare;
  112445. private _buttonOptions;
  112446. private _buttonL1;
  112447. private _buttonR1;
  112448. private _buttonLeftStick;
  112449. private _buttonRightStick;
  112450. private _dPadUp;
  112451. private _dPadDown;
  112452. private _dPadLeft;
  112453. private _dPadRight;
  112454. /**
  112455. * Creates a new DualShock gamepad object
  112456. * @param id defines the id of this gamepad
  112457. * @param index defines its index
  112458. * @param gamepad defines the internal HTML gamepad object
  112459. */
  112460. constructor(id: string, index: number, gamepad: any);
  112461. /**
  112462. * Defines the callback to call when left trigger is pressed
  112463. * @param callback defines the callback to use
  112464. */
  112465. onlefttriggerchanged(callback: (value: number) => void): void;
  112466. /**
  112467. * Defines the callback to call when right trigger is pressed
  112468. * @param callback defines the callback to use
  112469. */
  112470. onrighttriggerchanged(callback: (value: number) => void): void;
  112471. /**
  112472. * Gets the left trigger value
  112473. */
  112474. get leftTrigger(): number;
  112475. /**
  112476. * Sets the left trigger value
  112477. */
  112478. set leftTrigger(newValue: number);
  112479. /**
  112480. * Gets the right trigger value
  112481. */
  112482. get rightTrigger(): number;
  112483. /**
  112484. * Sets the right trigger value
  112485. */
  112486. set rightTrigger(newValue: number);
  112487. /**
  112488. * Defines the callback to call when a button is pressed
  112489. * @param callback defines the callback to use
  112490. */
  112491. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  112492. /**
  112493. * Defines the callback to call when a button is released
  112494. * @param callback defines the callback to use
  112495. */
  112496. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  112497. /**
  112498. * Defines the callback to call when a pad is pressed
  112499. * @param callback defines the callback to use
  112500. */
  112501. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  112502. /**
  112503. * Defines the callback to call when a pad is released
  112504. * @param callback defines the callback to use
  112505. */
  112506. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  112507. private _setButtonValue;
  112508. private _setDPadValue;
  112509. /**
  112510. * Gets the value of the `Cross` button
  112511. */
  112512. get buttonCross(): number;
  112513. /**
  112514. * Sets the value of the `Cross` button
  112515. */
  112516. set buttonCross(value: number);
  112517. /**
  112518. * Gets the value of the `Circle` button
  112519. */
  112520. get buttonCircle(): number;
  112521. /**
  112522. * Sets the value of the `Circle` button
  112523. */
  112524. set buttonCircle(value: number);
  112525. /**
  112526. * Gets the value of the `Square` button
  112527. */
  112528. get buttonSquare(): number;
  112529. /**
  112530. * Sets the value of the `Square` button
  112531. */
  112532. set buttonSquare(value: number);
  112533. /**
  112534. * Gets the value of the `Triangle` button
  112535. */
  112536. get buttonTriangle(): number;
  112537. /**
  112538. * Sets the value of the `Triangle` button
  112539. */
  112540. set buttonTriangle(value: number);
  112541. /**
  112542. * Gets the value of the `Options` button
  112543. */
  112544. get buttonOptions(): number;
  112545. /**
  112546. * Sets the value of the `Options` button
  112547. */
  112548. set buttonOptions(value: number);
  112549. /**
  112550. * Gets the value of the `Share` button
  112551. */
  112552. get buttonShare(): number;
  112553. /**
  112554. * Sets the value of the `Share` button
  112555. */
  112556. set buttonShare(value: number);
  112557. /**
  112558. * Gets the value of the `L1` button
  112559. */
  112560. get buttonL1(): number;
  112561. /**
  112562. * Sets the value of the `L1` button
  112563. */
  112564. set buttonL1(value: number);
  112565. /**
  112566. * Gets the value of the `R1` button
  112567. */
  112568. get buttonR1(): number;
  112569. /**
  112570. * Sets the value of the `R1` button
  112571. */
  112572. set buttonR1(value: number);
  112573. /**
  112574. * Gets the value of the Left joystick
  112575. */
  112576. get buttonLeftStick(): number;
  112577. /**
  112578. * Sets the value of the Left joystick
  112579. */
  112580. set buttonLeftStick(value: number);
  112581. /**
  112582. * Gets the value of the Right joystick
  112583. */
  112584. get buttonRightStick(): number;
  112585. /**
  112586. * Sets the value of the Right joystick
  112587. */
  112588. set buttonRightStick(value: number);
  112589. /**
  112590. * Gets the value of D-pad up
  112591. */
  112592. get dPadUp(): number;
  112593. /**
  112594. * Sets the value of D-pad up
  112595. */
  112596. set dPadUp(value: number);
  112597. /**
  112598. * Gets the value of D-pad down
  112599. */
  112600. get dPadDown(): number;
  112601. /**
  112602. * Sets the value of D-pad down
  112603. */
  112604. set dPadDown(value: number);
  112605. /**
  112606. * Gets the value of D-pad left
  112607. */
  112608. get dPadLeft(): number;
  112609. /**
  112610. * Sets the value of D-pad left
  112611. */
  112612. set dPadLeft(value: number);
  112613. /**
  112614. * Gets the value of D-pad right
  112615. */
  112616. get dPadRight(): number;
  112617. /**
  112618. * Sets the value of D-pad right
  112619. */
  112620. set dPadRight(value: number);
  112621. /**
  112622. * Force the gamepad to synchronize with device values
  112623. */
  112624. update(): void;
  112625. /**
  112626. * Disposes the gamepad
  112627. */
  112628. dispose(): void;
  112629. }
  112630. }
  112631. declare module BABYLON {
  112632. /**
  112633. * Manager for handling gamepads
  112634. */
  112635. export class GamepadManager {
  112636. private _scene?;
  112637. private _babylonGamepads;
  112638. private _oneGamepadConnected;
  112639. /** @hidden */
  112640. _isMonitoring: boolean;
  112641. private _gamepadEventSupported;
  112642. private _gamepadSupport?;
  112643. /**
  112644. * observable to be triggered when the gamepad controller has been connected
  112645. */
  112646. onGamepadConnectedObservable: Observable<Gamepad>;
  112647. /**
  112648. * observable to be triggered when the gamepad controller has been disconnected
  112649. */
  112650. onGamepadDisconnectedObservable: Observable<Gamepad>;
  112651. private _onGamepadConnectedEvent;
  112652. private _onGamepadDisconnectedEvent;
  112653. /**
  112654. * Initializes the gamepad manager
  112655. * @param _scene BabylonJS scene
  112656. */
  112657. constructor(_scene?: Scene | undefined);
  112658. /**
  112659. * The gamepads in the game pad manager
  112660. */
  112661. get gamepads(): Gamepad[];
  112662. /**
  112663. * Get the gamepad controllers based on type
  112664. * @param type The type of gamepad controller
  112665. * @returns Nullable gamepad
  112666. */
  112667. getGamepadByType(type?: number): Nullable<Gamepad>;
  112668. /**
  112669. * Disposes the gamepad manager
  112670. */
  112671. dispose(): void;
  112672. private _addNewGamepad;
  112673. private _startMonitoringGamepads;
  112674. private _stopMonitoringGamepads;
  112675. /** @hidden */
  112676. _checkGamepadsStatus(): void;
  112677. private _updateGamepadObjects;
  112678. }
  112679. }
  112680. declare module BABYLON {
  112681. interface Scene {
  112682. /** @hidden */
  112683. _gamepadManager: Nullable<GamepadManager>;
  112684. /**
  112685. * Gets the gamepad manager associated with the scene
  112686. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  112687. */
  112688. gamepadManager: GamepadManager;
  112689. }
  112690. /**
  112691. * Interface representing a free camera inputs manager
  112692. */
  112693. interface FreeCameraInputsManager {
  112694. /**
  112695. * Adds gamepad input support to the FreeCameraInputsManager.
  112696. * @returns the FreeCameraInputsManager
  112697. */
  112698. addGamepad(): FreeCameraInputsManager;
  112699. }
  112700. /**
  112701. * Interface representing an arc rotate camera inputs manager
  112702. */
  112703. interface ArcRotateCameraInputsManager {
  112704. /**
  112705. * Adds gamepad input support to the ArcRotateCamera InputManager.
  112706. * @returns the camera inputs manager
  112707. */
  112708. addGamepad(): ArcRotateCameraInputsManager;
  112709. }
  112710. /**
  112711. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  112712. */
  112713. export class GamepadSystemSceneComponent implements ISceneComponent {
  112714. /**
  112715. * The component name helpfull to identify the component in the list of scene components.
  112716. */
  112717. readonly name: string;
  112718. /**
  112719. * The scene the component belongs to.
  112720. */
  112721. scene: Scene;
  112722. /**
  112723. * Creates a new instance of the component for the given scene
  112724. * @param scene Defines the scene to register the component in
  112725. */
  112726. constructor(scene: Scene);
  112727. /**
  112728. * Registers the component in a given scene
  112729. */
  112730. register(): void;
  112731. /**
  112732. * Rebuilds the elements related to this component in case of
  112733. * context lost for instance.
  112734. */
  112735. rebuild(): void;
  112736. /**
  112737. * Disposes the component and the associated ressources
  112738. */
  112739. dispose(): void;
  112740. private _beforeCameraUpdate;
  112741. }
  112742. }
  112743. declare module BABYLON {
  112744. /**
  112745. * 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,
  112746. * which still works and will still be found in many Playgrounds.
  112747. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112748. */
  112749. export class UniversalCamera extends TouchCamera {
  112750. /**
  112751. * Defines the gamepad rotation sensiblity.
  112752. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112753. */
  112754. get gamepadAngularSensibility(): number;
  112755. set gamepadAngularSensibility(value: number);
  112756. /**
  112757. * Defines the gamepad move sensiblity.
  112758. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112759. */
  112760. get gamepadMoveSensibility(): number;
  112761. set gamepadMoveSensibility(value: number);
  112762. /**
  112763. * 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,
  112764. * which still works and will still be found in many Playgrounds.
  112765. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112766. * @param name Define the name of the camera in the scene
  112767. * @param position Define the start position of the camera in the scene
  112768. * @param scene Define the scene the camera belongs to
  112769. */
  112770. constructor(name: string, position: Vector3, scene: Scene);
  112771. /**
  112772. * Gets the current object class name.
  112773. * @return the class name
  112774. */
  112775. getClassName(): string;
  112776. }
  112777. }
  112778. declare module BABYLON {
  112779. /**
  112780. * This represents a FPS type of camera. This is only here for back compat purpose.
  112781. * Please use the UniversalCamera instead as both are identical.
  112782. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112783. */
  112784. export class GamepadCamera extends UniversalCamera {
  112785. /**
  112786. * Instantiates a new Gamepad Camera
  112787. * This represents a FPS type of camera. This is only here for back compat purpose.
  112788. * Please use the UniversalCamera instead as both are identical.
  112789. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112790. * @param name Define the name of the camera in the scene
  112791. * @param position Define the start position of the camera in the scene
  112792. * @param scene Define the scene the camera belongs to
  112793. */
  112794. constructor(name: string, position: Vector3, scene: Scene);
  112795. /**
  112796. * Gets the current object class name.
  112797. * @return the class name
  112798. */
  112799. getClassName(): string;
  112800. }
  112801. }
  112802. declare module BABYLON {
  112803. /** @hidden */
  112804. export var passPixelShader: {
  112805. name: string;
  112806. shader: string;
  112807. };
  112808. }
  112809. declare module BABYLON {
  112810. /** @hidden */
  112811. export var passCubePixelShader: {
  112812. name: string;
  112813. shader: string;
  112814. };
  112815. }
  112816. declare module BABYLON {
  112817. /**
  112818. * PassPostProcess which produces an output the same as it's input
  112819. */
  112820. export class PassPostProcess extends PostProcess {
  112821. /**
  112822. * Creates the PassPostProcess
  112823. * @param name The name of the effect.
  112824. * @param options The required width/height ratio to downsize to before computing the render pass.
  112825. * @param camera The camera to apply the render pass to.
  112826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112827. * @param engine The engine which the post process will be applied. (default: current engine)
  112828. * @param reusable If the post process can be reused on the same frame. (default: false)
  112829. * @param textureType The type of texture to be used when performing the post processing.
  112830. * @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)
  112831. */
  112832. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112833. }
  112834. /**
  112835. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  112836. */
  112837. export class PassCubePostProcess extends PostProcess {
  112838. private _face;
  112839. /**
  112840. * Gets or sets the cube face to display.
  112841. * * 0 is +X
  112842. * * 1 is -X
  112843. * * 2 is +Y
  112844. * * 3 is -Y
  112845. * * 4 is +Z
  112846. * * 5 is -Z
  112847. */
  112848. get face(): number;
  112849. set face(value: number);
  112850. /**
  112851. * Creates the PassCubePostProcess
  112852. * @param name The name of the effect.
  112853. * @param options The required width/height ratio to downsize to before computing the render pass.
  112854. * @param camera The camera to apply the render pass to.
  112855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112856. * @param engine The engine which the post process will be applied. (default: current engine)
  112857. * @param reusable If the post process can be reused on the same frame. (default: false)
  112858. * @param textureType The type of texture to be used when performing the post processing.
  112859. * @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)
  112860. */
  112861. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112862. }
  112863. }
  112864. declare module BABYLON {
  112865. /** @hidden */
  112866. export var anaglyphPixelShader: {
  112867. name: string;
  112868. shader: string;
  112869. };
  112870. }
  112871. declare module BABYLON {
  112872. /**
  112873. * Postprocess used to generate anaglyphic rendering
  112874. */
  112875. export class AnaglyphPostProcess extends PostProcess {
  112876. private _passedProcess;
  112877. /**
  112878. * Creates a new AnaglyphPostProcess
  112879. * @param name defines postprocess name
  112880. * @param options defines creation options or target ratio scale
  112881. * @param rigCameras defines cameras using this postprocess
  112882. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  112883. * @param engine defines hosting engine
  112884. * @param reusable defines if the postprocess will be reused multiple times per frame
  112885. */
  112886. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  112887. }
  112888. }
  112889. declare module BABYLON {
  112890. /**
  112891. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  112892. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112893. */
  112894. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  112895. /**
  112896. * Creates a new AnaglyphArcRotateCamera
  112897. * @param name defines camera name
  112898. * @param alpha defines alpha angle (in radians)
  112899. * @param beta defines beta angle (in radians)
  112900. * @param radius defines radius
  112901. * @param target defines camera target
  112902. * @param interaxialDistance defines distance between each color axis
  112903. * @param scene defines the hosting scene
  112904. */
  112905. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  112906. /**
  112907. * Gets camera class name
  112908. * @returns AnaglyphArcRotateCamera
  112909. */
  112910. getClassName(): string;
  112911. }
  112912. }
  112913. declare module BABYLON {
  112914. /**
  112915. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  112916. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112917. */
  112918. export class AnaglyphFreeCamera extends FreeCamera {
  112919. /**
  112920. * Creates a new AnaglyphFreeCamera
  112921. * @param name defines camera name
  112922. * @param position defines initial position
  112923. * @param interaxialDistance defines distance between each color axis
  112924. * @param scene defines the hosting scene
  112925. */
  112926. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112927. /**
  112928. * Gets camera class name
  112929. * @returns AnaglyphFreeCamera
  112930. */
  112931. getClassName(): string;
  112932. }
  112933. }
  112934. declare module BABYLON {
  112935. /**
  112936. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  112937. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112938. */
  112939. export class AnaglyphGamepadCamera extends GamepadCamera {
  112940. /**
  112941. * Creates a new AnaglyphGamepadCamera
  112942. * @param name defines camera name
  112943. * @param position defines initial position
  112944. * @param interaxialDistance defines distance between each color axis
  112945. * @param scene defines the hosting scene
  112946. */
  112947. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112948. /**
  112949. * Gets camera class name
  112950. * @returns AnaglyphGamepadCamera
  112951. */
  112952. getClassName(): string;
  112953. }
  112954. }
  112955. declare module BABYLON {
  112956. /**
  112957. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  112958. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112959. */
  112960. export class AnaglyphUniversalCamera extends UniversalCamera {
  112961. /**
  112962. * Creates a new AnaglyphUniversalCamera
  112963. * @param name defines camera name
  112964. * @param position defines initial position
  112965. * @param interaxialDistance defines distance between each color axis
  112966. * @param scene defines the hosting scene
  112967. */
  112968. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112969. /**
  112970. * Gets camera class name
  112971. * @returns AnaglyphUniversalCamera
  112972. */
  112973. getClassName(): string;
  112974. }
  112975. }
  112976. declare module BABYLON {
  112977. /** @hidden */
  112978. export var stereoscopicInterlacePixelShader: {
  112979. name: string;
  112980. shader: string;
  112981. };
  112982. }
  112983. declare module BABYLON {
  112984. /**
  112985. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  112986. */
  112987. export class StereoscopicInterlacePostProcess extends PostProcess {
  112988. private _stepSize;
  112989. private _passedProcess;
  112990. /**
  112991. * Initializes a StereoscopicInterlacePostProcess
  112992. * @param name The name of the effect.
  112993. * @param rigCameras The rig cameras to be appled to the post process
  112994. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  112995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112996. * @param engine The engine which the post process will be applied. (default: current engine)
  112997. * @param reusable If the post process can be reused on the same frame. (default: false)
  112998. */
  112999. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113000. }
  113001. }
  113002. declare module BABYLON {
  113003. /**
  113004. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  113005. * @see http://doc.babylonjs.com/features/cameras
  113006. */
  113007. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  113008. /**
  113009. * Creates a new StereoscopicArcRotateCamera
  113010. * @param name defines camera name
  113011. * @param alpha defines alpha angle (in radians)
  113012. * @param beta defines beta angle (in radians)
  113013. * @param radius defines radius
  113014. * @param target defines camera target
  113015. * @param interaxialDistance defines distance between each color axis
  113016. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  113017. * @param scene defines the hosting scene
  113018. */
  113019. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  113020. /**
  113021. * Gets camera class name
  113022. * @returns StereoscopicArcRotateCamera
  113023. */
  113024. getClassName(): string;
  113025. }
  113026. }
  113027. declare module BABYLON {
  113028. /**
  113029. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  113030. * @see http://doc.babylonjs.com/features/cameras
  113031. */
  113032. export class StereoscopicFreeCamera extends FreeCamera {
  113033. /**
  113034. * Creates a new StereoscopicFreeCamera
  113035. * @param name defines camera name
  113036. * @param position defines initial position
  113037. * @param interaxialDistance defines distance between each color axis
  113038. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  113039. * @param scene defines the hosting scene
  113040. */
  113041. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  113042. /**
  113043. * Gets camera class name
  113044. * @returns StereoscopicFreeCamera
  113045. */
  113046. getClassName(): string;
  113047. }
  113048. }
  113049. declare module BABYLON {
  113050. /**
  113051. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  113052. * @see http://doc.babylonjs.com/features/cameras
  113053. */
  113054. export class StereoscopicGamepadCamera extends GamepadCamera {
  113055. /**
  113056. * Creates a new StereoscopicGamepadCamera
  113057. * @param name defines camera name
  113058. * @param position defines initial position
  113059. * @param interaxialDistance defines distance between each color axis
  113060. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  113061. * @param scene defines the hosting scene
  113062. */
  113063. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  113064. /**
  113065. * Gets camera class name
  113066. * @returns StereoscopicGamepadCamera
  113067. */
  113068. getClassName(): string;
  113069. }
  113070. }
  113071. declare module BABYLON {
  113072. /**
  113073. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  113074. * @see http://doc.babylonjs.com/features/cameras
  113075. */
  113076. export class StereoscopicUniversalCamera extends UniversalCamera {
  113077. /**
  113078. * Creates a new StereoscopicUniversalCamera
  113079. * @param name defines camera name
  113080. * @param position defines initial position
  113081. * @param interaxialDistance defines distance between each color axis
  113082. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  113083. * @param scene defines the hosting scene
  113084. */
  113085. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  113086. /**
  113087. * Gets camera class name
  113088. * @returns StereoscopicUniversalCamera
  113089. */
  113090. getClassName(): string;
  113091. }
  113092. }
  113093. declare module BABYLON {
  113094. /**
  113095. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  113096. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  113097. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  113098. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  113099. */
  113100. export class VirtualJoysticksCamera extends FreeCamera {
  113101. /**
  113102. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  113103. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  113104. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  113105. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  113106. * @param name Define the name of the camera in the scene
  113107. * @param position Define the start position of the camera in the scene
  113108. * @param scene Define the scene the camera belongs to
  113109. */
  113110. constructor(name: string, position: Vector3, scene: Scene);
  113111. /**
  113112. * Gets the current object class name.
  113113. * @return the class name
  113114. */
  113115. getClassName(): string;
  113116. }
  113117. }
  113118. declare module BABYLON {
  113119. /**
  113120. * This represents all the required metrics to create a VR camera.
  113121. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  113122. */
  113123. export class VRCameraMetrics {
  113124. /**
  113125. * Define the horizontal resolution off the screen.
  113126. */
  113127. hResolution: number;
  113128. /**
  113129. * Define the vertical resolution off the screen.
  113130. */
  113131. vResolution: number;
  113132. /**
  113133. * Define the horizontal screen size.
  113134. */
  113135. hScreenSize: number;
  113136. /**
  113137. * Define the vertical screen size.
  113138. */
  113139. vScreenSize: number;
  113140. /**
  113141. * Define the vertical screen center position.
  113142. */
  113143. vScreenCenter: number;
  113144. /**
  113145. * Define the distance of the eyes to the screen.
  113146. */
  113147. eyeToScreenDistance: number;
  113148. /**
  113149. * Define the distance between both lenses
  113150. */
  113151. lensSeparationDistance: number;
  113152. /**
  113153. * Define the distance between both viewer's eyes.
  113154. */
  113155. interpupillaryDistance: number;
  113156. /**
  113157. * Define the distortion factor of the VR postprocess.
  113158. * Please, touch with care.
  113159. */
  113160. distortionK: number[];
  113161. /**
  113162. * Define the chromatic aberration correction factors for the VR post process.
  113163. */
  113164. chromaAbCorrection: number[];
  113165. /**
  113166. * Define the scale factor of the post process.
  113167. * The smaller the better but the slower.
  113168. */
  113169. postProcessScaleFactor: number;
  113170. /**
  113171. * Define an offset for the lens center.
  113172. */
  113173. lensCenterOffset: number;
  113174. /**
  113175. * Define if the current vr camera should compensate the distortion of the lense or not.
  113176. */
  113177. compensateDistortion: boolean;
  113178. /**
  113179. * Defines if multiview should be enabled when rendering (Default: false)
  113180. */
  113181. multiviewEnabled: boolean;
  113182. /**
  113183. * Gets the rendering aspect ratio based on the provided resolutions.
  113184. */
  113185. get aspectRatio(): number;
  113186. /**
  113187. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  113188. */
  113189. get aspectRatioFov(): number;
  113190. /**
  113191. * @hidden
  113192. */
  113193. get leftHMatrix(): Matrix;
  113194. /**
  113195. * @hidden
  113196. */
  113197. get rightHMatrix(): Matrix;
  113198. /**
  113199. * @hidden
  113200. */
  113201. get leftPreViewMatrix(): Matrix;
  113202. /**
  113203. * @hidden
  113204. */
  113205. get rightPreViewMatrix(): Matrix;
  113206. /**
  113207. * Get the default VRMetrics based on the most generic setup.
  113208. * @returns the default vr metrics
  113209. */
  113210. static GetDefault(): VRCameraMetrics;
  113211. }
  113212. }
  113213. declare module BABYLON {
  113214. /** @hidden */
  113215. export var vrDistortionCorrectionPixelShader: {
  113216. name: string;
  113217. shader: string;
  113218. };
  113219. }
  113220. declare module BABYLON {
  113221. /**
  113222. * VRDistortionCorrectionPostProcess used for mobile VR
  113223. */
  113224. export class VRDistortionCorrectionPostProcess extends PostProcess {
  113225. private _isRightEye;
  113226. private _distortionFactors;
  113227. private _postProcessScaleFactor;
  113228. private _lensCenterOffset;
  113229. private _scaleIn;
  113230. private _scaleFactor;
  113231. private _lensCenter;
  113232. /**
  113233. * Initializes the VRDistortionCorrectionPostProcess
  113234. * @param name The name of the effect.
  113235. * @param camera The camera to apply the render pass to.
  113236. * @param isRightEye If this is for the right eye distortion
  113237. * @param vrMetrics All the required metrics for the VR camera
  113238. */
  113239. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  113240. }
  113241. }
  113242. declare module BABYLON {
  113243. /**
  113244. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  113245. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  113246. */
  113247. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  113248. /**
  113249. * Creates a new VRDeviceOrientationArcRotateCamera
  113250. * @param name defines camera name
  113251. * @param alpha defines the camera rotation along the logitudinal axis
  113252. * @param beta defines the camera rotation along the latitudinal axis
  113253. * @param radius defines the camera distance from its target
  113254. * @param target defines the camera target
  113255. * @param scene defines the scene the camera belongs to
  113256. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  113257. * @param vrCameraMetrics defines the vr metrics associated to the camera
  113258. */
  113259. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  113260. /**
  113261. * Gets camera class name
  113262. * @returns VRDeviceOrientationArcRotateCamera
  113263. */
  113264. getClassName(): string;
  113265. }
  113266. }
  113267. declare module BABYLON {
  113268. /**
  113269. * Camera used to simulate VR rendering (based on FreeCamera)
  113270. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  113271. */
  113272. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  113273. /**
  113274. * Creates a new VRDeviceOrientationFreeCamera
  113275. * @param name defines camera name
  113276. * @param position defines the start position of the camera
  113277. * @param scene defines the scene the camera belongs to
  113278. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  113279. * @param vrCameraMetrics defines the vr metrics associated to the camera
  113280. */
  113281. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  113282. /**
  113283. * Gets camera class name
  113284. * @returns VRDeviceOrientationFreeCamera
  113285. */
  113286. getClassName(): string;
  113287. }
  113288. }
  113289. declare module BABYLON {
  113290. /**
  113291. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  113292. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  113293. */
  113294. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  113295. /**
  113296. * Creates a new VRDeviceOrientationGamepadCamera
  113297. * @param name defines camera name
  113298. * @param position defines the start position of the camera
  113299. * @param scene defines the scene the camera belongs to
  113300. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  113301. * @param vrCameraMetrics defines the vr metrics associated to the camera
  113302. */
  113303. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  113304. /**
  113305. * Gets camera class name
  113306. * @returns VRDeviceOrientationGamepadCamera
  113307. */
  113308. getClassName(): string;
  113309. }
  113310. }
  113311. declare module BABYLON {
  113312. /** @hidden */
  113313. export var imageProcessingPixelShader: {
  113314. name: string;
  113315. shader: string;
  113316. };
  113317. }
  113318. declare module BABYLON {
  113319. /**
  113320. * ImageProcessingPostProcess
  113321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  113322. */
  113323. export class ImageProcessingPostProcess extends PostProcess {
  113324. /**
  113325. * Default configuration related to image processing available in the PBR Material.
  113326. */
  113327. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113328. /**
  113329. * Gets the image processing configuration used either in this material.
  113330. */
  113331. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  113332. /**
  113333. * Sets the Default image processing configuration used either in the this material.
  113334. *
  113335. * If sets to null, the scene one is in use.
  113336. */
  113337. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  113338. /**
  113339. * Keep track of the image processing observer to allow dispose and replace.
  113340. */
  113341. private _imageProcessingObserver;
  113342. /**
  113343. * Attaches a new image processing configuration to the PBR Material.
  113344. * @param configuration
  113345. */
  113346. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  113347. /**
  113348. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  113349. */
  113350. get colorCurves(): Nullable<ColorCurves>;
  113351. /**
  113352. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  113353. */
  113354. set colorCurves(value: Nullable<ColorCurves>);
  113355. /**
  113356. * Gets wether the color curves effect is enabled.
  113357. */
  113358. get colorCurvesEnabled(): boolean;
  113359. /**
  113360. * Sets wether the color curves effect is enabled.
  113361. */
  113362. set colorCurvesEnabled(value: boolean);
  113363. /**
  113364. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  113365. */
  113366. get colorGradingTexture(): Nullable<BaseTexture>;
  113367. /**
  113368. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  113369. */
  113370. set colorGradingTexture(value: Nullable<BaseTexture>);
  113371. /**
  113372. * Gets wether the color grading effect is enabled.
  113373. */
  113374. get colorGradingEnabled(): boolean;
  113375. /**
  113376. * Gets wether the color grading effect is enabled.
  113377. */
  113378. set colorGradingEnabled(value: boolean);
  113379. /**
  113380. * Gets exposure used in the effect.
  113381. */
  113382. get exposure(): number;
  113383. /**
  113384. * Sets exposure used in the effect.
  113385. */
  113386. set exposure(value: number);
  113387. /**
  113388. * Gets wether tonemapping is enabled or not.
  113389. */
  113390. get toneMappingEnabled(): boolean;
  113391. /**
  113392. * Sets wether tonemapping is enabled or not
  113393. */
  113394. set toneMappingEnabled(value: boolean);
  113395. /**
  113396. * Gets the type of tone mapping effect.
  113397. */
  113398. get toneMappingType(): number;
  113399. /**
  113400. * Sets the type of tone mapping effect.
  113401. */
  113402. set toneMappingType(value: number);
  113403. /**
  113404. * Gets contrast used in the effect.
  113405. */
  113406. get contrast(): number;
  113407. /**
  113408. * Sets contrast used in the effect.
  113409. */
  113410. set contrast(value: number);
  113411. /**
  113412. * Gets Vignette stretch size.
  113413. */
  113414. get vignetteStretch(): number;
  113415. /**
  113416. * Sets Vignette stretch size.
  113417. */
  113418. set vignetteStretch(value: number);
  113419. /**
  113420. * Gets Vignette centre X Offset.
  113421. */
  113422. get vignetteCentreX(): number;
  113423. /**
  113424. * Sets Vignette centre X Offset.
  113425. */
  113426. set vignetteCentreX(value: number);
  113427. /**
  113428. * Gets Vignette centre Y Offset.
  113429. */
  113430. get vignetteCentreY(): number;
  113431. /**
  113432. * Sets Vignette centre Y Offset.
  113433. */
  113434. set vignetteCentreY(value: number);
  113435. /**
  113436. * Gets Vignette weight or intensity of the vignette effect.
  113437. */
  113438. get vignetteWeight(): number;
  113439. /**
  113440. * Sets Vignette weight or intensity of the vignette effect.
  113441. */
  113442. set vignetteWeight(value: number);
  113443. /**
  113444. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  113445. * if vignetteEnabled is set to true.
  113446. */
  113447. get vignetteColor(): Color4;
  113448. /**
  113449. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  113450. * if vignetteEnabled is set to true.
  113451. */
  113452. set vignetteColor(value: Color4);
  113453. /**
  113454. * Gets Camera field of view used by the Vignette effect.
  113455. */
  113456. get vignetteCameraFov(): number;
  113457. /**
  113458. * Sets Camera field of view used by the Vignette effect.
  113459. */
  113460. set vignetteCameraFov(value: number);
  113461. /**
  113462. * Gets the vignette blend mode allowing different kind of effect.
  113463. */
  113464. get vignetteBlendMode(): number;
  113465. /**
  113466. * Sets the vignette blend mode allowing different kind of effect.
  113467. */
  113468. set vignetteBlendMode(value: number);
  113469. /**
  113470. * Gets wether the vignette effect is enabled.
  113471. */
  113472. get vignetteEnabled(): boolean;
  113473. /**
  113474. * Sets wether the vignette effect is enabled.
  113475. */
  113476. set vignetteEnabled(value: boolean);
  113477. private _fromLinearSpace;
  113478. /**
  113479. * Gets wether the input of the processing is in Gamma or Linear Space.
  113480. */
  113481. get fromLinearSpace(): boolean;
  113482. /**
  113483. * Sets wether the input of the processing is in Gamma or Linear Space.
  113484. */
  113485. set fromLinearSpace(value: boolean);
  113486. /**
  113487. * Defines cache preventing GC.
  113488. */
  113489. private _defines;
  113490. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  113491. /**
  113492. * "ImageProcessingPostProcess"
  113493. * @returns "ImageProcessingPostProcess"
  113494. */
  113495. getClassName(): string;
  113496. protected _updateParameters(): void;
  113497. dispose(camera?: Camera): void;
  113498. }
  113499. }
  113500. declare module BABYLON {
  113501. /**
  113502. * Class containing static functions to help procedurally build meshes
  113503. */
  113504. export class GroundBuilder {
  113505. /**
  113506. * Creates a ground mesh
  113507. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  113508. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  113509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113510. * @param name defines the name of the mesh
  113511. * @param options defines the options used to create the mesh
  113512. * @param scene defines the hosting scene
  113513. * @returns the ground mesh
  113514. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  113515. */
  113516. static CreateGround(name: string, options: {
  113517. width?: number;
  113518. height?: number;
  113519. subdivisions?: number;
  113520. subdivisionsX?: number;
  113521. subdivisionsY?: number;
  113522. updatable?: boolean;
  113523. }, scene: any): Mesh;
  113524. /**
  113525. * Creates a tiled ground mesh
  113526. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  113527. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  113528. * * 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
  113529. * * 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
  113530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113531. * @param name defines the name of the mesh
  113532. * @param options defines the options used to create the mesh
  113533. * @param scene defines the hosting scene
  113534. * @returns the tiled ground mesh
  113535. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  113536. */
  113537. static CreateTiledGround(name: string, options: {
  113538. xmin: number;
  113539. zmin: number;
  113540. xmax: number;
  113541. zmax: number;
  113542. subdivisions?: {
  113543. w: number;
  113544. h: number;
  113545. };
  113546. precision?: {
  113547. w: number;
  113548. h: number;
  113549. };
  113550. updatable?: boolean;
  113551. }, scene?: Nullable<Scene>): Mesh;
  113552. /**
  113553. * Creates a ground mesh from a height map
  113554. * * The parameter `url` sets the URL of the height map image resource.
  113555. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  113556. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  113557. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  113558. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  113559. * * 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.
  113560. * * 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).
  113561. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  113562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113563. * @param name defines the name of the mesh
  113564. * @param url defines the url to the height map
  113565. * @param options defines the options used to create the mesh
  113566. * @param scene defines the hosting scene
  113567. * @returns the ground mesh
  113568. * @see https://doc.babylonjs.com/babylon101/height_map
  113569. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  113570. */
  113571. static CreateGroundFromHeightMap(name: string, url: string, options: {
  113572. width?: number;
  113573. height?: number;
  113574. subdivisions?: number;
  113575. minHeight?: number;
  113576. maxHeight?: number;
  113577. colorFilter?: Color3;
  113578. alphaFilter?: number;
  113579. updatable?: boolean;
  113580. onReady?: (mesh: GroundMesh) => void;
  113581. }, scene?: Nullable<Scene>): GroundMesh;
  113582. }
  113583. }
  113584. declare module BABYLON {
  113585. /**
  113586. * Class containing static functions to help procedurally build meshes
  113587. */
  113588. export class TorusBuilder {
  113589. /**
  113590. * Creates a torus mesh
  113591. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  113592. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  113593. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  113594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113597. * @param name defines the name of the mesh
  113598. * @param options defines the options used to create the mesh
  113599. * @param scene defines the hosting scene
  113600. * @returns the torus mesh
  113601. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  113602. */
  113603. static CreateTorus(name: string, options: {
  113604. diameter?: number;
  113605. thickness?: number;
  113606. tessellation?: number;
  113607. updatable?: boolean;
  113608. sideOrientation?: number;
  113609. frontUVs?: Vector4;
  113610. backUVs?: Vector4;
  113611. }, scene: any): Mesh;
  113612. }
  113613. }
  113614. declare module BABYLON {
  113615. /**
  113616. * Class containing static functions to help procedurally build meshes
  113617. */
  113618. export class CylinderBuilder {
  113619. /**
  113620. * Creates a cylinder or a cone mesh
  113621. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  113622. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  113623. * * 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.
  113624. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  113625. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  113626. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  113627. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  113628. * * 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).
  113629. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  113630. * * 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).
  113631. * * 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
  113632. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  113633. * * 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
  113634. * * 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.
  113635. * * If `enclose` is false, a ring surface is one element.
  113636. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  113637. * * 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
  113638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113639. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113641. * @param name defines the name of the mesh
  113642. * @param options defines the options used to create the mesh
  113643. * @param scene defines the hosting scene
  113644. * @returns the cylinder mesh
  113645. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  113646. */
  113647. static CreateCylinder(name: string, options: {
  113648. height?: number;
  113649. diameterTop?: number;
  113650. diameterBottom?: number;
  113651. diameter?: number;
  113652. tessellation?: number;
  113653. subdivisions?: number;
  113654. arc?: number;
  113655. faceColors?: Color4[];
  113656. faceUV?: Vector4[];
  113657. updatable?: boolean;
  113658. hasRings?: boolean;
  113659. enclose?: boolean;
  113660. cap?: number;
  113661. sideOrientation?: number;
  113662. frontUVs?: Vector4;
  113663. backUVs?: Vector4;
  113664. }, scene: any): Mesh;
  113665. }
  113666. }
  113667. declare module BABYLON {
  113668. /**
  113669. * States of the webXR experience
  113670. */
  113671. export enum WebXRState {
  113672. /**
  113673. * Transitioning to being in XR mode
  113674. */
  113675. ENTERING_XR = 0,
  113676. /**
  113677. * Transitioning to non XR mode
  113678. */
  113679. EXITING_XR = 1,
  113680. /**
  113681. * In XR mode and presenting
  113682. */
  113683. IN_XR = 2,
  113684. /**
  113685. * Not entered XR mode
  113686. */
  113687. NOT_IN_XR = 3
  113688. }
  113689. /**
  113690. * Abstraction of the XR render target
  113691. */
  113692. export interface WebXRRenderTarget extends IDisposable {
  113693. /**
  113694. * xrpresent context of the canvas which can be used to display/mirror xr content
  113695. */
  113696. canvasContext: WebGLRenderingContext;
  113697. /**
  113698. * xr layer for the canvas
  113699. */
  113700. xrLayer: Nullable<XRWebGLLayer>;
  113701. /**
  113702. * Initializes the xr layer for the session
  113703. * @param xrSession xr session
  113704. * @returns a promise that will resolve once the XR Layer has been created
  113705. */
  113706. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  113707. }
  113708. }
  113709. declare module BABYLON {
  113710. /**
  113711. * COnfiguration object for WebXR output canvas
  113712. */
  113713. export class WebXRManagedOutputCanvasOptions {
  113714. /**
  113715. * Options for this XR Layer output
  113716. */
  113717. canvasOptions: XRWebGLLayerOptions;
  113718. /**
  113719. * CSS styling for a newly created canvas (if not provided)
  113720. */
  113721. newCanvasCssStyle?: string;
  113722. /**
  113723. * Get the default values of the configuration object
  113724. * @returns default values of this configuration object
  113725. */
  113726. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  113727. }
  113728. /**
  113729. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  113730. */
  113731. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  113732. private configuration;
  113733. private _engine;
  113734. private _canvas;
  113735. /**
  113736. * xrpresent context of the canvas which can be used to display/mirror xr content
  113737. */
  113738. canvasContext: WebGLRenderingContext;
  113739. /**
  113740. * xr layer for the canvas
  113741. */
  113742. xrLayer: Nullable<XRWebGLLayer>;
  113743. /**
  113744. * Initializes the xr layer for the session
  113745. * @param xrSession xr session
  113746. * @returns a promise that will resolve once the XR Layer has been created
  113747. */
  113748. initializeXRLayerAsync(xrSession: any): any;
  113749. /**
  113750. * Initializes the canvas to be added/removed upon entering/exiting xr
  113751. * @param engine the Babylon engine
  113752. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  113753. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  113754. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  113755. */
  113756. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  113757. /**
  113758. * Disposes of the object
  113759. */
  113760. dispose(): void;
  113761. private _setManagedOutputCanvas;
  113762. private _addCanvas;
  113763. private _removeCanvas;
  113764. }
  113765. }
  113766. declare module BABYLON {
  113767. /**
  113768. * Manages an XRSession to work with Babylon's engine
  113769. * @see https://doc.babylonjs.com/how_to/webxr
  113770. */
  113771. export class WebXRSessionManager implements IDisposable {
  113772. /** The scene which the session should be created for */
  113773. scene: Scene;
  113774. /**
  113775. * Fires every time a new xrFrame arrives which can be used to update the camera
  113776. */
  113777. onXRFrameObservable: Observable<XRFrame>;
  113778. /**
  113779. * Fires when the xr session is ended either by the device or manually done
  113780. */
  113781. onXRSessionEnded: Observable<any>;
  113782. /**
  113783. * Fires when the xr session is ended either by the device or manually done
  113784. */
  113785. onXRSessionInit: Observable<XRSession>;
  113786. /**
  113787. * Underlying xr session
  113788. */
  113789. session: XRSession;
  113790. /**
  113791. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  113792. * or get the offset the player is currently at.
  113793. */
  113794. viewerReferenceSpace: XRReferenceSpace;
  113795. /**
  113796. * The current reference space used in this session. This reference space can constantly change!
  113797. * It is mainly used to offset the camera's position.
  113798. */
  113799. referenceSpace: XRReferenceSpace;
  113800. /**
  113801. * The base reference space from which the session started. good if you want to reset your
  113802. * reference space
  113803. */
  113804. baseReferenceSpace: XRReferenceSpace;
  113805. /**
  113806. * Used just in case of a failure to initialize an immersive session.
  113807. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  113808. */
  113809. defaultHeightCompensation: number;
  113810. /**
  113811. * Current XR frame
  113812. */
  113813. currentFrame: Nullable<XRFrame>;
  113814. /** WebXR timestamp updated every frame */
  113815. currentTimestamp: number;
  113816. private _xrNavigator;
  113817. private baseLayer;
  113818. private _rttProvider;
  113819. private _sessionEnded;
  113820. /**
  113821. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  113822. * @param scene The scene which the session should be created for
  113823. */
  113824. constructor(
  113825. /** The scene which the session should be created for */
  113826. scene: Scene);
  113827. /**
  113828. * Initializes the manager
  113829. * After initialization enterXR can be called to start an XR session
  113830. * @returns Promise which resolves after it is initialized
  113831. */
  113832. initializeAsync(): Promise<void>;
  113833. /**
  113834. * Initializes an xr session
  113835. * @param xrSessionMode mode to initialize
  113836. * @param optionalFeatures defines optional values to pass to the session builder
  113837. * @returns a promise which will resolve once the session has been initialized
  113838. */
  113839. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  113840. /**
  113841. * Sets the reference space on the xr session
  113842. * @param referenceSpace space to set
  113843. * @returns a promise that will resolve once the reference space has been set
  113844. */
  113845. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  113846. /**
  113847. * Updates the render state of the session
  113848. * @param state state to set
  113849. * @returns a promise that resolves once the render state has been updated
  113850. */
  113851. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  113852. /**
  113853. * Starts rendering to the xr layer
  113854. * @returns a promise that will resolve once rendering has started
  113855. */
  113856. startRenderingToXRAsync(): Promise<void>;
  113857. /**
  113858. * Gets the correct render target texture to be rendered this frame for this eye
  113859. * @param eye the eye for which to get the render target
  113860. * @returns the render target for the specified eye
  113861. */
  113862. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  113863. /**
  113864. * Stops the xrSession and restores the renderloop
  113865. * @returns Promise which resolves after it exits XR
  113866. */
  113867. exitXRAsync(): Promise<void>;
  113868. /**
  113869. * Checks if a session would be supported for the creation options specified
  113870. * @param sessionMode session mode to check if supported eg. immersive-vr
  113871. * @returns true if supported
  113872. */
  113873. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113874. /**
  113875. * Creates a WebXRRenderTarget object for the XR session
  113876. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  113877. * @param options optional options to provide when creating a new render target
  113878. * @returns a WebXR render target to which the session can render
  113879. */
  113880. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  113881. /**
  113882. * @hidden
  113883. * Converts the render layer of xrSession to a render target
  113884. * @param session session to create render target for
  113885. * @param scene scene the new render target should be created for
  113886. * @param baseLayer the webgl layer to create the render target for
  113887. */
  113888. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  113889. /**
  113890. * Disposes of the session manager
  113891. */
  113892. dispose(): void;
  113893. /**
  113894. * Gets a promise returning true when fullfiled if the given session mode is supported
  113895. * @param sessionMode defines the session to test
  113896. * @returns a promise
  113897. */
  113898. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113899. }
  113900. }
  113901. declare module BABYLON {
  113902. /**
  113903. * WebXR Camera which holds the views for the xrSession
  113904. * @see https://doc.babylonjs.com/how_to/webxr
  113905. */
  113906. export class WebXRCamera extends FreeCamera {
  113907. private _xrSessionManager;
  113908. /**
  113909. * Is the camera in debug mode. Used when using an emulator
  113910. */
  113911. debugMode: boolean;
  113912. private _firstFrame;
  113913. private _referencedPosition;
  113914. private _referenceQuaternion;
  113915. private _xrInvPositionCache;
  113916. private _xrInvQuaternionCache;
  113917. /**
  113918. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  113919. * @param name the name of the camera
  113920. * @param scene the scene to add the camera to
  113921. */
  113922. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  113923. private _updateNumberOfRigCameras;
  113924. /** @hidden */
  113925. _updateForDualEyeDebugging(): void;
  113926. private _updateReferenceSpace;
  113927. private _updateReferenceSpaceOffset;
  113928. private _updateFromXRSession;
  113929. }
  113930. }
  113931. declare module BABYLON {
  113932. /**
  113933. * Defining the interface required for a (webxr) feature
  113934. */
  113935. export interface IWebXRFeature extends IDisposable {
  113936. /**
  113937. * Attach the feature to the session
  113938. * Will usually be called by the features manager
  113939. *
  113940. * @returns true if successful.
  113941. */
  113942. attach(): boolean;
  113943. /**
  113944. * Detach the feature from the session
  113945. * Will usually be called by the features manager
  113946. *
  113947. * @returns true if successful.
  113948. */
  113949. detach(): boolean;
  113950. }
  113951. /**
  113952. * Defining the constructor of a feature. Used to register the modules.
  113953. */
  113954. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  113955. /**
  113956. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  113957. * It is mainly used in AR sessions.
  113958. *
  113959. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  113960. */
  113961. export class WebXRFeaturesManager implements IDisposable {
  113962. private _xrSessionManager;
  113963. private static readonly _AvailableFeatures;
  113964. /**
  113965. * Used to register a module. After calling this function a developer can use this feature in the scene.
  113966. * Mainly used internally.
  113967. *
  113968. * @param featureName the name of the feature to register
  113969. * @param constructorFunction the function used to construct the module
  113970. * @param version the (babylon) version of the module
  113971. * @param stable is that a stable version of this module
  113972. */
  113973. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  113974. /**
  113975. * Returns a constructor of a specific feature.
  113976. *
  113977. * @param featureName the name of the feature to construct
  113978. * @param version the version of the feature to load
  113979. * @param xrSessionManager the xrSessionManager. Used to construct the module
  113980. * @param options optional options provided to the module.
  113981. * @returns a function that, when called, will return a new instance of this feature
  113982. */
  113983. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  113984. /**
  113985. * Return the latest unstable version of this feature
  113986. * @param featureName the name of the feature to search
  113987. * @returns the version number. if not found will return -1
  113988. */
  113989. static GetLatestVersionOfFeature(featureName: string): number;
  113990. /**
  113991. * Return the latest stable version of this feature
  113992. * @param featureName the name of the feature to search
  113993. * @returns the version number. if not found will return -1
  113994. */
  113995. static GetStableVersionOfFeature(featureName: string): number;
  113996. /**
  113997. * Can be used to return the list of features currently registered
  113998. *
  113999. * @returns an Array of available features
  114000. */
  114001. static GetAvailableFeatures(): string[];
  114002. /**
  114003. * Gets the versions available for a specific feature
  114004. * @param featureName the name of the feature
  114005. * @returns an array with the available versions
  114006. */
  114007. static GetAvailableVersions(featureName: string): string[];
  114008. private _features;
  114009. /**
  114010. * constructs a new features manages.
  114011. *
  114012. * @param _xrSessionManager an instance of WebXRSessionManager
  114013. */
  114014. constructor(_xrSessionManager: WebXRSessionManager);
  114015. /**
  114016. * 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.
  114017. *
  114018. * @param featureName the name of the feature to load or the class of the feature
  114019. * @param version optional version to load. if not provided the latest version will be enabled
  114020. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  114021. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  114022. * @returns a new constructed feature or throws an error if feature not found.
  114023. */
  114024. enableFeature(featureName: string | {
  114025. Name: string;
  114026. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  114027. /**
  114028. * Used to disable an already-enabled feature
  114029. * @param featureName the feature to disable
  114030. * @returns true if disable was successful
  114031. */
  114032. disableFeature(featureName: string | {
  114033. Name: string;
  114034. }): boolean;
  114035. /**
  114036. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  114037. * Can be used during a session to start a feature
  114038. * @param featureName the name of feature to attach
  114039. */
  114040. attachFeature(featureName: string): void;
  114041. /**
  114042. * Can be used inside a session or when the session ends to detach a specific feature
  114043. * @param featureName the name of the feature to detach
  114044. */
  114045. detachFeature(featureName: string): void;
  114046. /**
  114047. * Get the list of enabled features
  114048. * @returns an array of enabled features
  114049. */
  114050. getEnabledFeatures(): string[];
  114051. /**
  114052. * get the implementation of an enabled feature.
  114053. * @param featureName the name of the feature to load
  114054. * @returns the feature class, if found
  114055. */
  114056. getEnabledFeature(featureName: string): IWebXRFeature;
  114057. /**
  114058. * dispose this features manager
  114059. */
  114060. dispose(): void;
  114061. }
  114062. }
  114063. declare module BABYLON {
  114064. /**
  114065. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  114066. * @see https://doc.babylonjs.com/how_to/webxr
  114067. */
  114068. export class WebXRExperienceHelper implements IDisposable {
  114069. private scene;
  114070. /**
  114071. * Camera used to render xr content
  114072. */
  114073. camera: WebXRCamera;
  114074. /**
  114075. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  114076. */
  114077. state: WebXRState;
  114078. private _setState;
  114079. /**
  114080. * Fires when the state of the experience helper has changed
  114081. */
  114082. onStateChangedObservable: Observable<WebXRState>;
  114083. /**
  114084. * Observers registered here will be triggered after the camera's initial transformation is set
  114085. * This can be used to set a different ground level or an extra rotation.
  114086. *
  114087. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  114088. * to the position set after this observable is done executing.
  114089. */
  114090. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  114091. /** Session manager used to keep track of xr session */
  114092. sessionManager: WebXRSessionManager;
  114093. /** A features manager for this xr session */
  114094. featuresManager: WebXRFeaturesManager;
  114095. private _nonVRCamera;
  114096. private _originalSceneAutoClear;
  114097. private _supported;
  114098. /**
  114099. * Creates the experience helper
  114100. * @param scene the scene to attach the experience helper to
  114101. * @returns a promise for the experience helper
  114102. */
  114103. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  114104. /**
  114105. * Creates a WebXRExperienceHelper
  114106. * @param scene The scene the helper should be created in
  114107. */
  114108. private constructor();
  114109. /**
  114110. * Exits XR mode and returns the scene to its original state
  114111. * @returns promise that resolves after xr mode has exited
  114112. */
  114113. exitXRAsync(): Promise<void>;
  114114. /**
  114115. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  114116. * @param sessionMode options for the XR session
  114117. * @param referenceSpaceType frame of reference of the XR session
  114118. * @param renderTarget the output canvas that will be used to enter XR mode
  114119. * @returns promise that resolves after xr mode has entered
  114120. */
  114121. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  114122. /**
  114123. * Disposes of the experience helper
  114124. */
  114125. dispose(): void;
  114126. private _nonXRToXRCamera;
  114127. }
  114128. }
  114129. declare module BABYLON {
  114130. /**
  114131. * X-Y values for axes in WebXR
  114132. */
  114133. export interface IWebXRMotionControllerAxesValue {
  114134. /**
  114135. * The value of the x axis
  114136. */
  114137. x: number;
  114138. /**
  114139. * The value of the y-axis
  114140. */
  114141. y: number;
  114142. }
  114143. /**
  114144. * changed / previous values for the values of this component
  114145. */
  114146. export interface IWebXRMotionControllerComponentChangesValues<T> {
  114147. /**
  114148. * current (this frame) value
  114149. */
  114150. current: T;
  114151. /**
  114152. * previous (last change) value
  114153. */
  114154. previous: T;
  114155. }
  114156. /**
  114157. * Represents changes in the component between current frame and last values recorded
  114158. */
  114159. export interface IWebXRMotionControllerComponentChanges {
  114160. /**
  114161. * will be populated with previous and current values if touched changed
  114162. */
  114163. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  114164. /**
  114165. * will be populated with previous and current values if pressed changed
  114166. */
  114167. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  114168. /**
  114169. * will be populated with previous and current values if value changed
  114170. */
  114171. value?: IWebXRMotionControllerComponentChangesValues<number>;
  114172. /**
  114173. * will be populated with previous and current values if axes changed
  114174. */
  114175. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  114176. }
  114177. /**
  114178. * This class represents a single component (for example button or thumbstick) of a motion controller
  114179. */
  114180. export class WebXRControllerComponent implements IDisposable {
  114181. /**
  114182. * the id of this component
  114183. */
  114184. id: string;
  114185. /**
  114186. * the type of the component
  114187. */
  114188. type: MotionControllerComponentType;
  114189. private _buttonIndex;
  114190. private _axesIndices;
  114191. /**
  114192. * Observers registered here will be triggered when the state of a button changes
  114193. * State change is either pressed / touched / value
  114194. */
  114195. onButtonStateChanged: Observable<WebXRControllerComponent>;
  114196. /**
  114197. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  114198. * the axes data changes
  114199. */
  114200. onAxisValueChanged: Observable<{
  114201. x: number;
  114202. y: number;
  114203. }>;
  114204. private _currentValue;
  114205. private _touched;
  114206. private _pressed;
  114207. private _axes;
  114208. private _changes;
  114209. /**
  114210. * Creates a new component for a motion controller.
  114211. * It is created by the motion controller itself
  114212. *
  114213. * @param id the id of this component
  114214. * @param type the type of the component
  114215. * @param _buttonIndex index in the buttons array of the gamepad
  114216. * @param _axesIndices indices of the values in the axes array of the gamepad
  114217. */
  114218. constructor(
  114219. /**
  114220. * the id of this component
  114221. */
  114222. id: string,
  114223. /**
  114224. * the type of the component
  114225. */
  114226. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  114227. /**
  114228. * Get the current value of this component
  114229. */
  114230. get value(): number;
  114231. /**
  114232. * is the button currently pressed
  114233. */
  114234. get pressed(): boolean;
  114235. /**
  114236. * is the button currently touched
  114237. */
  114238. get touched(): boolean;
  114239. /**
  114240. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  114241. */
  114242. get axes(): IWebXRMotionControllerAxesValue;
  114243. /**
  114244. * Get the changes. Elements will be populated only if they changed with their previous and current value
  114245. */
  114246. get changes(): IWebXRMotionControllerComponentChanges;
  114247. /**
  114248. * Is this component a button (hence - pressable)
  114249. * @returns true if can be pressed
  114250. */
  114251. isButton(): boolean;
  114252. /**
  114253. * Are there axes correlating to this component
  114254. * @return true is axes data is available
  114255. */
  114256. isAxes(): boolean;
  114257. /**
  114258. * update this component using the gamepad object it is in. Called on every frame
  114259. * @param nativeController the native gamepad controller object
  114260. */
  114261. update(nativeController: IMinimalMotionControllerObject): void;
  114262. /**
  114263. * Dispose this component
  114264. */
  114265. dispose(): void;
  114266. }
  114267. }
  114268. declare module BABYLON {
  114269. /**
  114270. * Class used to represent data loading progression
  114271. */
  114272. export class SceneLoaderProgressEvent {
  114273. /** defines if data length to load can be evaluated */
  114274. readonly lengthComputable: boolean;
  114275. /** defines the loaded data length */
  114276. readonly loaded: number;
  114277. /** defines the data length to load */
  114278. readonly total: number;
  114279. /**
  114280. * Create a new progress event
  114281. * @param lengthComputable defines if data length to load can be evaluated
  114282. * @param loaded defines the loaded data length
  114283. * @param total defines the data length to load
  114284. */
  114285. constructor(
  114286. /** defines if data length to load can be evaluated */
  114287. lengthComputable: boolean,
  114288. /** defines the loaded data length */
  114289. loaded: number,
  114290. /** defines the data length to load */
  114291. total: number);
  114292. /**
  114293. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  114294. * @param event defines the source event
  114295. * @returns a new SceneLoaderProgressEvent
  114296. */
  114297. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  114298. }
  114299. /**
  114300. * Interface used by SceneLoader plugins to define supported file extensions
  114301. */
  114302. export interface ISceneLoaderPluginExtensions {
  114303. /**
  114304. * Defines the list of supported extensions
  114305. */
  114306. [extension: string]: {
  114307. isBinary: boolean;
  114308. };
  114309. }
  114310. /**
  114311. * Interface used by SceneLoader plugin factory
  114312. */
  114313. export interface ISceneLoaderPluginFactory {
  114314. /**
  114315. * Defines the name of the factory
  114316. */
  114317. name: string;
  114318. /**
  114319. * Function called to create a new plugin
  114320. * @return the new plugin
  114321. */
  114322. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  114323. /**
  114324. * The callback that returns true if the data can be directly loaded.
  114325. * @param data string containing the file data
  114326. * @returns if the data can be loaded directly
  114327. */
  114328. canDirectLoad?(data: string): boolean;
  114329. }
  114330. /**
  114331. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  114332. */
  114333. export interface ISceneLoaderPluginBase {
  114334. /**
  114335. * The friendly name of this plugin.
  114336. */
  114337. name: string;
  114338. /**
  114339. * The file extensions supported by this plugin.
  114340. */
  114341. extensions: string | ISceneLoaderPluginExtensions;
  114342. /**
  114343. * The callback called when loading from a url.
  114344. * @param scene scene loading this url
  114345. * @param url url to load
  114346. * @param onSuccess callback called when the file successfully loads
  114347. * @param onProgress callback called while file is loading (if the server supports this mode)
  114348. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114349. * @param onError callback called when the file fails to load
  114350. * @returns a file request object
  114351. */
  114352. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  114353. /**
  114354. * The callback called when loading from a file object.
  114355. * @param scene scene loading this file
  114356. * @param file defines the file to load
  114357. * @param onSuccess defines the callback to call when data is loaded
  114358. * @param onProgress defines the callback to call during loading process
  114359. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  114360. * @param onError defines the callback to call when an error occurs
  114361. * @returns a file request object
  114362. */
  114363. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  114364. /**
  114365. * The callback that returns true if the data can be directly loaded.
  114366. * @param data string containing the file data
  114367. * @returns if the data can be loaded directly
  114368. */
  114369. canDirectLoad?(data: string): boolean;
  114370. /**
  114371. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  114372. * @param scene scene loading this data
  114373. * @param data string containing the data
  114374. * @returns data to pass to the plugin
  114375. */
  114376. directLoad?(scene: Scene, data: string): any;
  114377. /**
  114378. * The callback that allows custom handling of the root url based on the response url.
  114379. * @param rootUrl the original root url
  114380. * @param responseURL the response url if available
  114381. * @returns the new root url
  114382. */
  114383. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  114384. }
  114385. /**
  114386. * Interface used to define a SceneLoader plugin
  114387. */
  114388. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  114389. /**
  114390. * Import meshes into a scene.
  114391. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  114392. * @param scene The scene to import into
  114393. * @param data The data to import
  114394. * @param rootUrl The root url for scene and resources
  114395. * @param meshes The meshes array to import into
  114396. * @param particleSystems The particle systems array to import into
  114397. * @param skeletons The skeletons array to import into
  114398. * @param onError The callback when import fails
  114399. * @returns True if successful or false otherwise
  114400. */
  114401. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  114402. /**
  114403. * Load into a scene.
  114404. * @param scene The scene to load into
  114405. * @param data The data to import
  114406. * @param rootUrl The root url for scene and resources
  114407. * @param onError The callback when import fails
  114408. * @returns True if successful or false otherwise
  114409. */
  114410. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  114411. /**
  114412. * Load into an asset container.
  114413. * @param scene The scene to load into
  114414. * @param data The data to import
  114415. * @param rootUrl The root url for scene and resources
  114416. * @param onError The callback when import fails
  114417. * @returns The loaded asset container
  114418. */
  114419. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  114420. }
  114421. /**
  114422. * Interface used to define an async SceneLoader plugin
  114423. */
  114424. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  114425. /**
  114426. * Import meshes into a scene.
  114427. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  114428. * @param scene The scene to import into
  114429. * @param data The data to import
  114430. * @param rootUrl The root url for scene and resources
  114431. * @param onProgress The callback when the load progresses
  114432. * @param fileName Defines the name of the file to load
  114433. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  114434. */
  114435. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  114436. meshes: AbstractMesh[];
  114437. particleSystems: IParticleSystem[];
  114438. skeletons: Skeleton[];
  114439. animationGroups: AnimationGroup[];
  114440. }>;
  114441. /**
  114442. * Load into a scene.
  114443. * @param scene The scene to load into
  114444. * @param data The data to import
  114445. * @param rootUrl The root url for scene and resources
  114446. * @param onProgress The callback when the load progresses
  114447. * @param fileName Defines the name of the file to load
  114448. * @returns Nothing
  114449. */
  114450. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  114451. /**
  114452. * Load into an asset container.
  114453. * @param scene The scene to load into
  114454. * @param data The data to import
  114455. * @param rootUrl The root url for scene and resources
  114456. * @param onProgress The callback when the load progresses
  114457. * @param fileName Defines the name of the file to load
  114458. * @returns The loaded asset container
  114459. */
  114460. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  114461. }
  114462. /**
  114463. * Mode that determines how to handle old animation groups before loading new ones.
  114464. */
  114465. export enum SceneLoaderAnimationGroupLoadingMode {
  114466. /**
  114467. * Reset all old animations to initial state then dispose them.
  114468. */
  114469. Clean = 0,
  114470. /**
  114471. * Stop all old animations.
  114472. */
  114473. Stop = 1,
  114474. /**
  114475. * Restart old animations from first frame.
  114476. */
  114477. Sync = 2,
  114478. /**
  114479. * Old animations remains untouched.
  114480. */
  114481. NoSync = 3
  114482. }
  114483. /**
  114484. * Class used to load scene from various file formats using registered plugins
  114485. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  114486. */
  114487. export class SceneLoader {
  114488. /**
  114489. * No logging while loading
  114490. */
  114491. static readonly NO_LOGGING: number;
  114492. /**
  114493. * Minimal logging while loading
  114494. */
  114495. static readonly MINIMAL_LOGGING: number;
  114496. /**
  114497. * Summary logging while loading
  114498. */
  114499. static readonly SUMMARY_LOGGING: number;
  114500. /**
  114501. * Detailled logging while loading
  114502. */
  114503. static readonly DETAILED_LOGGING: number;
  114504. /**
  114505. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  114506. */
  114507. static get ForceFullSceneLoadingForIncremental(): boolean;
  114508. static set ForceFullSceneLoadingForIncremental(value: boolean);
  114509. /**
  114510. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  114511. */
  114512. static get ShowLoadingScreen(): boolean;
  114513. static set ShowLoadingScreen(value: boolean);
  114514. /**
  114515. * Defines the current logging level (while loading the scene)
  114516. * @ignorenaming
  114517. */
  114518. static get loggingLevel(): number;
  114519. static set loggingLevel(value: number);
  114520. /**
  114521. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  114522. */
  114523. static get CleanBoneMatrixWeights(): boolean;
  114524. static set CleanBoneMatrixWeights(value: boolean);
  114525. /**
  114526. * Event raised when a plugin is used to load a scene
  114527. */
  114528. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  114529. private static _registeredPlugins;
  114530. private static _getDefaultPlugin;
  114531. private static _getPluginForExtension;
  114532. private static _getPluginForDirectLoad;
  114533. private static _getPluginForFilename;
  114534. private static _getDirectLoad;
  114535. private static _loadData;
  114536. private static _getFileInfo;
  114537. /**
  114538. * Gets a plugin that can load the given extension
  114539. * @param extension defines the extension to load
  114540. * @returns a plugin or null if none works
  114541. */
  114542. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  114543. /**
  114544. * Gets a boolean indicating that the given extension can be loaded
  114545. * @param extension defines the extension to load
  114546. * @returns true if the extension is supported
  114547. */
  114548. static IsPluginForExtensionAvailable(extension: string): boolean;
  114549. /**
  114550. * Adds a new plugin to the list of registered plugins
  114551. * @param plugin defines the plugin to add
  114552. */
  114553. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  114554. /**
  114555. * Import meshes into a scene
  114556. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  114557. * @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)
  114558. * @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)
  114559. * @param scene the instance of BABYLON.Scene to append to
  114560. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  114561. * @param onProgress a callback with a progress event for each file being loaded
  114562. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114563. * @param pluginExtension the extension used to determine the plugin
  114564. * @returns The loaded plugin
  114565. */
  114566. 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>;
  114567. /**
  114568. * Import meshes into a scene
  114569. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  114570. * @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)
  114571. * @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)
  114572. * @param scene the instance of BABYLON.Scene to append to
  114573. * @param onProgress a callback with a progress event for each file being loaded
  114574. * @param pluginExtension the extension used to determine the plugin
  114575. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  114576. */
  114577. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  114578. meshes: AbstractMesh[];
  114579. particleSystems: IParticleSystem[];
  114580. skeletons: Skeleton[];
  114581. animationGroups: AnimationGroup[];
  114582. }>;
  114583. /**
  114584. * Load a scene
  114585. * @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)
  114586. * @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)
  114587. * @param engine is the instance of BABYLON.Engine to use to create the scene
  114588. * @param onSuccess a callback with the scene when import succeeds
  114589. * @param onProgress a callback with a progress event for each file being loaded
  114590. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114591. * @param pluginExtension the extension used to determine the plugin
  114592. * @returns The loaded plugin
  114593. */
  114594. 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>;
  114595. /**
  114596. * Load a scene
  114597. * @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)
  114598. * @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)
  114599. * @param engine is the instance of BABYLON.Engine to use to create the scene
  114600. * @param onProgress a callback with a progress event for each file being loaded
  114601. * @param pluginExtension the extension used to determine the plugin
  114602. * @returns The loaded scene
  114603. */
  114604. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  114605. /**
  114606. * Append a scene
  114607. * @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)
  114608. * @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)
  114609. * @param scene is the instance of BABYLON.Scene to append to
  114610. * @param onSuccess a callback with the scene when import succeeds
  114611. * @param onProgress a callback with a progress event for each file being loaded
  114612. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114613. * @param pluginExtension the extension used to determine the plugin
  114614. * @returns The loaded plugin
  114615. */
  114616. 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>;
  114617. /**
  114618. * Append a scene
  114619. * @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)
  114620. * @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)
  114621. * @param scene is the instance of BABYLON.Scene to append to
  114622. * @param onProgress a callback with a progress event for each file being loaded
  114623. * @param pluginExtension the extension used to determine the plugin
  114624. * @returns The given scene
  114625. */
  114626. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  114627. /**
  114628. * Load a scene into an asset container
  114629. * @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)
  114630. * @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)
  114631. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  114632. * @param onSuccess a callback with the scene when import succeeds
  114633. * @param onProgress a callback with a progress event for each file being loaded
  114634. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114635. * @param pluginExtension the extension used to determine the plugin
  114636. * @returns The loaded plugin
  114637. */
  114638. 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>;
  114639. /**
  114640. * Load a scene into an asset container
  114641. * @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)
  114642. * @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)
  114643. * @param scene is the instance of Scene to append to
  114644. * @param onProgress a callback with a progress event for each file being loaded
  114645. * @param pluginExtension the extension used to determine the plugin
  114646. * @returns The loaded asset container
  114647. */
  114648. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  114649. /**
  114650. * Import animations from a file into a scene
  114651. * @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)
  114652. * @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)
  114653. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  114654. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  114655. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  114656. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  114657. * @param onSuccess a callback with the scene when import succeeds
  114658. * @param onProgress a callback with a progress event for each file being loaded
  114659. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114660. */
  114661. 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;
  114662. /**
  114663. * Import animations from a file into a scene
  114664. * @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)
  114665. * @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)
  114666. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  114667. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  114668. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  114669. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  114670. * @param onSuccess a callback with the scene when import succeeds
  114671. * @param onProgress a callback with a progress event for each file being loaded
  114672. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114673. * @returns the updated scene with imported animations
  114674. */
  114675. 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>;
  114676. }
  114677. }
  114678. declare module BABYLON {
  114679. /**
  114680. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  114681. */
  114682. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  114683. /**
  114684. * The type of components available in motion controllers.
  114685. * This is not the name of the component.
  114686. */
  114687. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  114688. /**
  114689. * The schema of motion controller layout.
  114690. * No object will be initialized using this interface
  114691. * This is used just to define the profile.
  114692. */
  114693. export interface IMotionControllerLayout {
  114694. /**
  114695. * Defines the main button component id
  114696. */
  114697. selectComponentId: string;
  114698. /**
  114699. * Available components (unsorted)
  114700. */
  114701. components: {
  114702. /**
  114703. * A map of component Ids
  114704. */
  114705. [componentId: string]: {
  114706. /**
  114707. * The type of input the component outputs
  114708. */
  114709. type: MotionControllerComponentType;
  114710. };
  114711. };
  114712. /**
  114713. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  114714. */
  114715. gamepad?: {
  114716. /**
  114717. * Is the mapping based on the xr-standard defined here:
  114718. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  114719. */
  114720. mapping: "" | "xr-standard";
  114721. /**
  114722. * The buttons available in this input in the right order
  114723. * index of this button will be the index in the gamepadObject.buttons array
  114724. * correlates to the componentId in components
  114725. */
  114726. buttons: Array<string | null>;
  114727. /**
  114728. * Definition of the axes of the gamepad input, sorted
  114729. * Correlates to componentIds in the components map
  114730. */
  114731. axes: Array<{
  114732. /**
  114733. * The component id that the axis correlates to
  114734. */
  114735. componentId: string;
  114736. /**
  114737. * X or Y Axis
  114738. */
  114739. axis: "x-axis" | "y-axis";
  114740. } | null>;
  114741. };
  114742. }
  114743. /**
  114744. * A definition for the layout map in the input profile
  114745. */
  114746. export interface IMotionControllerLayoutMap {
  114747. /**
  114748. * Layouts with handness type as a key
  114749. */
  114750. [handness: string]: IMotionControllerLayout;
  114751. }
  114752. /**
  114753. * The XR Input profile schema
  114754. * Profiles can be found here:
  114755. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  114756. */
  114757. export interface IMotionControllerProfile {
  114758. /**
  114759. * The id of this profile
  114760. * correlates to the profile(s) in the xrInput.profiles array
  114761. */
  114762. profileId: string;
  114763. /**
  114764. * fallback profiles for this profileId
  114765. */
  114766. fallbackProfileIds: string[];
  114767. /**
  114768. * The layout map, with handness as key
  114769. */
  114770. layouts: IMotionControllerLayoutMap;
  114771. }
  114772. /**
  114773. * A helper-interface for the 3 meshes needed for controller button animation
  114774. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  114775. */
  114776. export interface IMotionControllerButtonMeshMap {
  114777. /**
  114778. * The mesh that will be changed when value changes
  114779. */
  114780. valueMesh: AbstractMesh;
  114781. /**
  114782. * the mesh that defines the pressed value mesh position.
  114783. * This is used to find the max-position of this button
  114784. */
  114785. pressedMesh: AbstractMesh;
  114786. /**
  114787. * the mesh that defines the unpressed value mesh position.
  114788. * This is used to find the min (or initial) position of this button
  114789. */
  114790. unpressedMesh: AbstractMesh;
  114791. }
  114792. /**
  114793. * A helper-interface for the 3 meshes needed for controller axis animation.
  114794. * This will be expanded when touchpad animations are fully supported
  114795. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  114796. */
  114797. export interface IMotionControllerAxisMeshMap {
  114798. /**
  114799. * The mesh that will be changed when axis value changes
  114800. */
  114801. valueMesh: AbstractMesh;
  114802. /**
  114803. * the mesh that defines the minimum value mesh position.
  114804. */
  114805. minMesh: AbstractMesh;
  114806. /**
  114807. * the mesh that defines the maximum value mesh position.
  114808. */
  114809. maxMesh: AbstractMesh;
  114810. }
  114811. /**
  114812. * The elements needed for change-detection of the gamepad objects in motion controllers
  114813. */
  114814. export interface IMinimalMotionControllerObject {
  114815. /**
  114816. * An array of available buttons
  114817. */
  114818. buttons: Array<{
  114819. /**
  114820. * Value of the button/trigger
  114821. */
  114822. value: number;
  114823. /**
  114824. * If the button/trigger is currently touched
  114825. */
  114826. touched: boolean;
  114827. /**
  114828. * If the button/trigger is currently pressed
  114829. */
  114830. pressed: boolean;
  114831. }>;
  114832. /**
  114833. * Available axes of this controller
  114834. */
  114835. axes: number[];
  114836. }
  114837. /**
  114838. * An Abstract Motion controller
  114839. * This class receives an xrInput and a profile layout and uses those to initialize the components
  114840. * Each component has an observable to check for changes in value and state
  114841. */
  114842. export abstract class WebXRAbstractMotionController implements IDisposable {
  114843. protected scene: Scene;
  114844. protected layout: IMotionControllerLayout;
  114845. /**
  114846. * The gamepad object correlating to this controller
  114847. */
  114848. gamepadObject: IMinimalMotionControllerObject;
  114849. /**
  114850. * handness (left/right/none) of this controller
  114851. */
  114852. handness: MotionControllerHandness;
  114853. /**
  114854. * Component type map
  114855. */
  114856. static ComponentType: {
  114857. TRIGGER: string;
  114858. SQUEEZE: string;
  114859. TOUCHPAD: string;
  114860. THUMBSTICK: string;
  114861. BUTTON: string;
  114862. };
  114863. /**
  114864. * The profile id of this motion controller
  114865. */
  114866. abstract profileId: string;
  114867. /**
  114868. * A map of components (WebXRControllerComponent) in this motion controller
  114869. * Components have a ComponentType and can also have both button and axis definitions
  114870. */
  114871. readonly components: {
  114872. [id: string]: WebXRControllerComponent;
  114873. };
  114874. /**
  114875. * Observers registered here will be triggered when the model of this controller is done loading
  114876. */
  114877. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  114878. /**
  114879. * The root mesh of the model. It is null if the model was not yet initialized
  114880. */
  114881. rootMesh: Nullable<AbstractMesh>;
  114882. private _modelReady;
  114883. /**
  114884. * constructs a new abstract motion controller
  114885. * @param scene the scene to which the model of the controller will be added
  114886. * @param layout The profile layout to load
  114887. * @param gamepadObject The gamepad object correlating to this controller
  114888. * @param handness handness (left/right/none) of this controller
  114889. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  114890. */
  114891. constructor(scene: Scene, layout: IMotionControllerLayout,
  114892. /**
  114893. * The gamepad object correlating to this controller
  114894. */
  114895. gamepadObject: IMinimalMotionControllerObject,
  114896. /**
  114897. * handness (left/right/none) of this controller
  114898. */
  114899. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  114900. private _initComponent;
  114901. /**
  114902. * Update this model using the current XRFrame
  114903. * @param xrFrame the current xr frame to use and update the model
  114904. */
  114905. updateFromXRFrame(xrFrame: XRFrame): void;
  114906. /**
  114907. * Get the list of components available in this motion controller
  114908. * @returns an array of strings correlating to available components
  114909. */
  114910. getComponentTypes(): string[];
  114911. /**
  114912. * Get the main (Select) component of this controller as defined in the layout
  114913. * @returns the main component of this controller
  114914. */
  114915. getMainComponent(): WebXRControllerComponent;
  114916. /**
  114917. * get a component based an its component id as defined in layout.components
  114918. * @param id the id of the component
  114919. * @returns the component correlates to the id or undefined if not found
  114920. */
  114921. getComponent(id: string): WebXRControllerComponent;
  114922. /**
  114923. * Loads the model correlating to this controller
  114924. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  114925. * @returns A promise fulfilled with the result of the model loading
  114926. */
  114927. loadModel(): Promise<boolean>;
  114928. /**
  114929. * Update the model itself with the current frame data
  114930. * @param xrFrame the frame to use for updating the model mesh
  114931. */
  114932. protected updateModel(xrFrame: XRFrame): void;
  114933. /**
  114934. * Moves the axis on the controller mesh based on its current state
  114935. * @param axis the index of the axis
  114936. * @param axisValue the value of the axis which determines the meshes new position
  114937. * @hidden
  114938. */
  114939. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  114940. /**
  114941. * Moves the buttons on the controller mesh based on their current state
  114942. * @param buttonName the name of the button to move
  114943. * @param buttonValue the value of the button which determines the buttons new position
  114944. */
  114945. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  114946. private _getGenericFilenameAndPath;
  114947. private _getGenericParentMesh;
  114948. /**
  114949. * Get the filename and path for this controller's model
  114950. * @returns a map of filename and path
  114951. */
  114952. protected abstract _getFilenameAndPath(): {
  114953. filename: string;
  114954. path: string;
  114955. };
  114956. /**
  114957. * This function will be called after the model was successfully loaded and can be used
  114958. * for mesh transformations before it is available for the user
  114959. * @param meshes the loaded meshes
  114960. */
  114961. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  114962. /**
  114963. * Set the root mesh for this controller. Important for the WebXR controller class
  114964. * @param meshes the loaded meshes
  114965. */
  114966. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  114967. /**
  114968. * A function executed each frame that updates the mesh (if needed)
  114969. * @param xrFrame the current xrFrame
  114970. */
  114971. protected abstract _updateModel(xrFrame: XRFrame): void;
  114972. /**
  114973. * This function is called before the mesh is loaded. It checks for loading constraints.
  114974. * For example, this function can check if the GLB loader is available
  114975. * If this function returns false, the generic controller will be loaded instead
  114976. * @returns Is the client ready to load the mesh
  114977. */
  114978. protected abstract _getModelLoadingConstraints(): boolean;
  114979. /**
  114980. * Dispose this controller, the model mesh and all its components
  114981. */
  114982. dispose(): void;
  114983. }
  114984. }
  114985. declare module BABYLON {
  114986. /**
  114987. * A generic trigger-only motion controller for WebXR
  114988. */
  114989. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  114990. /**
  114991. * Static version of the profile id of this controller
  114992. */
  114993. static ProfileId: string;
  114994. profileId: string;
  114995. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  114996. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  114997. protected _updateModel(): void;
  114998. protected _getFilenameAndPath(): {
  114999. filename: string;
  115000. path: string;
  115001. };
  115002. protected _setRootMesh(meshes: AbstractMesh[]): void;
  115003. protected _getModelLoadingConstraints(): boolean;
  115004. }
  115005. }
  115006. declare module BABYLON {
  115007. /**
  115008. * A construction function type to create a new controller based on an xrInput object
  115009. */
  115010. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  115011. /**
  115012. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  115013. *
  115014. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  115015. * it should be replaced with auto-loaded controllers.
  115016. *
  115017. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  115018. */
  115019. export class WebXRMotionControllerManager {
  115020. private static _AvailableControllers;
  115021. private static _Fallbacks;
  115022. /**
  115023. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  115024. *
  115025. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  115026. *
  115027. * @param type the profile type to register
  115028. * @param constructFunction the function to be called when loading this profile
  115029. */
  115030. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  115031. /**
  115032. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  115033. * The order of search:
  115034. *
  115035. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  115036. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  115037. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  115038. * 4) return the generic trigger controller if none were found
  115039. *
  115040. * @param xrInput the xrInput to which a new controller is initialized
  115041. * @param scene the scene to which the model will be added
  115042. * @param forceProfile force a certain profile for this controller
  115043. * @return the motion controller class for this profile id or the generic standard class if none was found
  115044. */
  115045. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  115046. /**
  115047. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  115048. * @param profileId the profile to which a fallback needs to be found
  115049. * @return an array with corresponding fallback profiles
  115050. */
  115051. static FindFallbackWithProfileId(profileId: string): string[];
  115052. /**
  115053. * Register a fallback to a specific profile.
  115054. * @param profileId the profileId that will receive the fallbacks
  115055. * @param fallbacks A list of fallback profiles
  115056. */
  115057. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  115058. /**
  115059. * Register the default fallbacks.
  115060. * This function is called automatically when this file is imported.
  115061. */
  115062. static DefaultFallbacks(): void;
  115063. }
  115064. }
  115065. declare module BABYLON {
  115066. /**
  115067. * Represents an XR input
  115068. */
  115069. export class WebXRController {
  115070. private scene;
  115071. /** The underlying input source for the controller */
  115072. inputSource: XRInputSource;
  115073. /**
  115074. * 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
  115075. */
  115076. grip?: AbstractMesh;
  115077. /**
  115078. * Pointer which can be used to select objects or attach a visible laser to
  115079. */
  115080. pointer: AbstractMesh;
  115081. private _gamepadMode;
  115082. /**
  115083. * If available, this is the gamepad object related to this controller.
  115084. * Using this object it is possible to get click events and trackpad changes of the
  115085. * webxr controller that is currently being used.
  115086. */
  115087. gamepadController?: WebXRAbstractMotionController;
  115088. /**
  115089. * Event that fires when the controller is removed/disposed
  115090. */
  115091. onDisposeObservable: Observable<{}>;
  115092. private _tmpQuaternion;
  115093. private _tmpVector;
  115094. /**
  115095. * Creates the controller
  115096. * @see https://doc.babylonjs.com/how_to/webxr
  115097. * @param scene the scene which the controller should be associated to
  115098. * @param inputSource the underlying input source for the controller
  115099. * @param controllerProfile An optional controller profile for this input. This will override the xrInput profile.
  115100. */
  115101. constructor(scene: Scene,
  115102. /** The underlying input source for the controller */
  115103. inputSource: XRInputSource, controllerProfile?: string);
  115104. /**
  115105. * Updates the controller pose based on the given XRFrame
  115106. * @param xrFrame xr frame to update the pose with
  115107. * @param referenceSpace reference space to use
  115108. */
  115109. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  115110. /**
  115111. * Gets a world space ray coming from the controller
  115112. * @param result the resulting ray
  115113. */
  115114. getWorldPointerRayToRef(result: Ray): void;
  115115. /**
  115116. * Get the scene associated with this controller
  115117. * @returns the scene object
  115118. */
  115119. getScene(): Scene;
  115120. /**
  115121. * Disposes of the object
  115122. */
  115123. dispose(): void;
  115124. }
  115125. }
  115126. declare module BABYLON {
  115127. /**
  115128. * The schema for initialization options of the XR Input class
  115129. */
  115130. export interface IWebXRInputOptions {
  115131. /**
  115132. * If set to true no model will be automatically loaded
  115133. */
  115134. doNotLoadControllerMeshes?: boolean;
  115135. /**
  115136. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  115137. * If not found, the xr input profile data will be used.
  115138. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  115139. */
  115140. forceInputProfile?: string;
  115141. }
  115142. /**
  115143. * XR input used to track XR inputs such as controllers/rays
  115144. */
  115145. export class WebXRInput implements IDisposable {
  115146. /**
  115147. * the xr session manager for this session
  115148. */
  115149. xrSessionManager: WebXRSessionManager;
  115150. /**
  115151. * the WebXR camera for this session. Mainly used for teleportation
  115152. */
  115153. xrCamera: WebXRCamera;
  115154. private readonly options;
  115155. /**
  115156. * XR controllers being tracked
  115157. */
  115158. controllers: Array<WebXRController>;
  115159. private _frameObserver;
  115160. private _sessionEndedObserver;
  115161. private _sessionInitObserver;
  115162. /**
  115163. * Event when a controller has been connected/added
  115164. */
  115165. onControllerAddedObservable: Observable<WebXRController>;
  115166. /**
  115167. * Event when a controller has been removed/disconnected
  115168. */
  115169. onControllerRemovedObservable: Observable<WebXRController>;
  115170. /**
  115171. * Initializes the WebXRInput
  115172. * @param xrSessionManager the xr session manager for this session
  115173. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  115174. * @param options = initialization options for this xr input
  115175. */
  115176. constructor(
  115177. /**
  115178. * the xr session manager for this session
  115179. */
  115180. xrSessionManager: WebXRSessionManager,
  115181. /**
  115182. * the WebXR camera for this session. Mainly used for teleportation
  115183. */
  115184. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  115185. private _onInputSourcesChange;
  115186. private _addAndRemoveControllers;
  115187. /**
  115188. * Disposes of the object
  115189. */
  115190. dispose(): void;
  115191. }
  115192. }
  115193. declare module BABYLON {
  115194. /**
  115195. * Handles pointer input automatically for the pointer of XR controllers
  115196. */
  115197. export class WebXRControllerPointerSelection {
  115198. private static _idCounter;
  115199. private _tmpRay;
  115200. /**
  115201. * Creates a WebXRControllerPointerSelection
  115202. * @param input input manager to setup pointer selection
  115203. */
  115204. constructor(input: WebXRInput);
  115205. private _convertNormalToDirectionOfRay;
  115206. private _updatePointerDistance;
  115207. }
  115208. }
  115209. declare module BABYLON {
  115210. /**
  115211. * Enables teleportation
  115212. */
  115213. export class WebXRControllerTeleportation {
  115214. private _teleportationFillColor;
  115215. private _teleportationBorderColor;
  115216. private _tmpRay;
  115217. private _tmpVector;
  115218. /**
  115219. * when set to true (default) teleportation will wait for thumbstick changes.
  115220. * When set to false teleportation will be disabled.
  115221. *
  115222. * If set to false while teleporting results can be unexpected.
  115223. */
  115224. enabled: boolean;
  115225. /**
  115226. * Creates a WebXRControllerTeleportation
  115227. * @param input input manager to add teleportation to
  115228. * @param floorMeshes floormeshes which can be teleported to
  115229. */
  115230. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  115231. }
  115232. }
  115233. declare module BABYLON {
  115234. /**
  115235. * Button which can be used to enter a different mode of XR
  115236. */
  115237. export class WebXREnterExitUIButton {
  115238. /** button element */
  115239. element: HTMLElement;
  115240. /** XR initialization options for the button */
  115241. sessionMode: XRSessionMode;
  115242. /** Reference space type */
  115243. referenceSpaceType: XRReferenceSpaceType;
  115244. /**
  115245. * Creates a WebXREnterExitUIButton
  115246. * @param element button element
  115247. * @param sessionMode XR initialization session mode
  115248. * @param referenceSpaceType the type of reference space to be used
  115249. */
  115250. constructor(
  115251. /** button element */
  115252. element: HTMLElement,
  115253. /** XR initialization options for the button */
  115254. sessionMode: XRSessionMode,
  115255. /** Reference space type */
  115256. referenceSpaceType: XRReferenceSpaceType);
  115257. /**
  115258. * Overwritable function which can be used to update the button's visuals when the state changes
  115259. * @param activeButton the current active button in the UI
  115260. */
  115261. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  115262. }
  115263. /**
  115264. * Options to create the webXR UI
  115265. */
  115266. export class WebXREnterExitUIOptions {
  115267. /**
  115268. * Context to enter xr with
  115269. */
  115270. renderTarget?: Nullable<WebXRRenderTarget>;
  115271. /**
  115272. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  115273. */
  115274. customButtons?: Array<WebXREnterExitUIButton>;
  115275. /**
  115276. * A session mode to use when creating the default button.
  115277. * Default is immersive-vr
  115278. */
  115279. sessionMode?: XRSessionMode;
  115280. /**
  115281. * A reference space type to use when creating the default button.
  115282. * Default is local-floor
  115283. */
  115284. referenceSpaceType?: XRReferenceSpaceType;
  115285. }
  115286. /**
  115287. * UI to allow the user to enter/exit XR mode
  115288. */
  115289. export class WebXREnterExitUI implements IDisposable {
  115290. private scene;
  115291. /** version of the options passed to this UI */
  115292. options: WebXREnterExitUIOptions;
  115293. private _overlay;
  115294. private _buttons;
  115295. private _activeButton;
  115296. /**
  115297. * Fired every time the active button is changed.
  115298. *
  115299. * When xr is entered via a button that launches xr that button will be the callback parameter
  115300. *
  115301. * When exiting xr the callback parameter will be null)
  115302. */
  115303. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  115304. /**
  115305. * Creates UI to allow the user to enter/exit XR mode
  115306. * @param scene the scene to add the ui to
  115307. * @param helper the xr experience helper to enter/exit xr with
  115308. * @param options options to configure the UI
  115309. * @returns the created ui
  115310. */
  115311. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  115312. /**
  115313. *
  115314. * @param scene babylon scene object to use
  115315. * @param options (read-only) version of the options passed to this UI
  115316. */
  115317. private constructor();
  115318. private _updateButtons;
  115319. /**
  115320. * Disposes of the object
  115321. */
  115322. dispose(): void;
  115323. }
  115324. }
  115325. declare module BABYLON {
  115326. /**
  115327. * Options for the default xr helper
  115328. */
  115329. export class WebXRDefaultExperienceOptions {
  115330. /**
  115331. * Floor meshes that should be used for teleporting
  115332. */
  115333. floorMeshes?: Array<AbstractMesh>;
  115334. /**
  115335. * Enable or disable default UI to enter XR
  115336. */
  115337. disableDefaultUI?: boolean;
  115338. /**
  115339. * optional configuration for the output canvas
  115340. */
  115341. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  115342. /**
  115343. * optional UI options. This can be used among other to change session mode and reference space type
  115344. */
  115345. uiOptions?: WebXREnterExitUIOptions;
  115346. /**
  115347. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  115348. */
  115349. inputOptions?: IWebXRInputOptions;
  115350. }
  115351. /**
  115352. * Default experience which provides a similar setup to the previous webVRExperience
  115353. */
  115354. export class WebXRDefaultExperience {
  115355. /**
  115356. * Base experience
  115357. */
  115358. baseExperience: WebXRExperienceHelper;
  115359. /**
  115360. * Input experience extension
  115361. */
  115362. input: WebXRInput;
  115363. /**
  115364. * Enables laser pointer and selection
  115365. */
  115366. pointerSelection: WebXRControllerPointerSelection;
  115367. /**
  115368. * Enables teleportation
  115369. */
  115370. teleportation: WebXRControllerTeleportation;
  115371. /**
  115372. * Enables ui for entering/exiting xr
  115373. */
  115374. enterExitUI: WebXREnterExitUI;
  115375. /**
  115376. * Default target xr should render to
  115377. */
  115378. renderTarget: WebXRRenderTarget;
  115379. /**
  115380. * Creates the default xr experience
  115381. * @param scene scene
  115382. * @param options options for basic configuration
  115383. * @returns resulting WebXRDefaultExperience
  115384. */
  115385. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115386. private constructor();
  115387. /**
  115388. * DIsposes of the experience helper
  115389. */
  115390. dispose(): void;
  115391. }
  115392. }
  115393. declare module BABYLON {
  115394. /**
  115395. * Options to modify the vr teleportation behavior.
  115396. */
  115397. export interface VRTeleportationOptions {
  115398. /**
  115399. * The name of the mesh which should be used as the teleportation floor. (default: null)
  115400. */
  115401. floorMeshName?: string;
  115402. /**
  115403. * A list of meshes to be used as the teleportation floor. (default: empty)
  115404. */
  115405. floorMeshes?: Mesh[];
  115406. /**
  115407. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  115408. */
  115409. teleportationMode?: number;
  115410. /**
  115411. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  115412. */
  115413. teleportationTime?: number;
  115414. /**
  115415. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  115416. */
  115417. teleportationSpeed?: number;
  115418. /**
  115419. * The easing function used in the animation or null for Linear. (default CircleEase)
  115420. */
  115421. easingFunction?: EasingFunction;
  115422. }
  115423. /**
  115424. * Options to modify the vr experience helper's behavior.
  115425. */
  115426. export interface VRExperienceHelperOptions extends WebVROptions {
  115427. /**
  115428. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  115429. */
  115430. createDeviceOrientationCamera?: boolean;
  115431. /**
  115432. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  115433. */
  115434. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  115435. /**
  115436. * Uses the main button on the controller to toggle the laser casted. (default: true)
  115437. */
  115438. laserToggle?: boolean;
  115439. /**
  115440. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  115441. */
  115442. floorMeshes?: Mesh[];
  115443. /**
  115444. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  115445. */
  115446. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  115447. /**
  115448. * Defines if WebXR should be used instead of WebVR (if available)
  115449. */
  115450. useXR?: boolean;
  115451. }
  115452. /**
  115453. * Event containing information after VR has been entered
  115454. */
  115455. export class OnAfterEnteringVRObservableEvent {
  115456. /**
  115457. * If entering vr was successful
  115458. */
  115459. success: boolean;
  115460. }
  115461. /**
  115462. * Helps to quickly add VR support to an existing scene.
  115463. * See http://doc.babylonjs.com/how_to/webvr_helper
  115464. */
  115465. export class VRExperienceHelper {
  115466. /** Options to modify the vr experience helper's behavior. */
  115467. webVROptions: VRExperienceHelperOptions;
  115468. private _scene;
  115469. private _position;
  115470. private _btnVR;
  115471. private _btnVRDisplayed;
  115472. private _webVRsupported;
  115473. private _webVRready;
  115474. private _webVRrequesting;
  115475. private _webVRpresenting;
  115476. private _hasEnteredVR;
  115477. private _fullscreenVRpresenting;
  115478. private _inputElement;
  115479. private _webVRCamera;
  115480. private _vrDeviceOrientationCamera;
  115481. private _deviceOrientationCamera;
  115482. private _existingCamera;
  115483. private _onKeyDown;
  115484. private _onVrDisplayPresentChange;
  115485. private _onVRDisplayChanged;
  115486. private _onVRRequestPresentStart;
  115487. private _onVRRequestPresentComplete;
  115488. /**
  115489. * 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)
  115490. */
  115491. enableGazeEvenWhenNoPointerLock: boolean;
  115492. /**
  115493. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  115494. */
  115495. exitVROnDoubleTap: boolean;
  115496. /**
  115497. * Observable raised right before entering VR.
  115498. */
  115499. onEnteringVRObservable: Observable<VRExperienceHelper>;
  115500. /**
  115501. * Observable raised when entering VR has completed.
  115502. */
  115503. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  115504. /**
  115505. * Observable raised when exiting VR.
  115506. */
  115507. onExitingVRObservable: Observable<VRExperienceHelper>;
  115508. /**
  115509. * Observable raised when controller mesh is loaded.
  115510. */
  115511. onControllerMeshLoadedObservable: Observable<WebVRController>;
  115512. /** Return this.onEnteringVRObservable
  115513. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  115514. */
  115515. get onEnteringVR(): Observable<VRExperienceHelper>;
  115516. /** Return this.onExitingVRObservable
  115517. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  115518. */
  115519. get onExitingVR(): Observable<VRExperienceHelper>;
  115520. /** Return this.onControllerMeshLoadedObservable
  115521. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  115522. */
  115523. get onControllerMeshLoaded(): Observable<WebVRController>;
  115524. private _rayLength;
  115525. private _useCustomVRButton;
  115526. private _teleportationRequested;
  115527. private _teleportActive;
  115528. private _floorMeshName;
  115529. private _floorMeshesCollection;
  115530. private _teleportationMode;
  115531. private _teleportationTime;
  115532. private _teleportationSpeed;
  115533. private _teleportationEasing;
  115534. private _rotationAllowed;
  115535. private _teleportBackwardsVector;
  115536. private _teleportationTarget;
  115537. private _isDefaultTeleportationTarget;
  115538. private _postProcessMove;
  115539. private _teleportationFillColor;
  115540. private _teleportationBorderColor;
  115541. private _rotationAngle;
  115542. private _haloCenter;
  115543. private _cameraGazer;
  115544. private _padSensibilityUp;
  115545. private _padSensibilityDown;
  115546. private _leftController;
  115547. private _rightController;
  115548. private _gazeColor;
  115549. private _laserColor;
  115550. private _pickedLaserColor;
  115551. private _pickedGazeColor;
  115552. /**
  115553. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  115554. */
  115555. onNewMeshSelected: Observable<AbstractMesh>;
  115556. /**
  115557. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  115558. * This observable will provide the mesh and the controller used to select the mesh
  115559. */
  115560. onMeshSelectedWithController: Observable<{
  115561. mesh: AbstractMesh;
  115562. controller: WebVRController;
  115563. }>;
  115564. /**
  115565. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  115566. */
  115567. onNewMeshPicked: Observable<PickingInfo>;
  115568. private _circleEase;
  115569. /**
  115570. * Observable raised before camera teleportation
  115571. */
  115572. onBeforeCameraTeleport: Observable<Vector3>;
  115573. /**
  115574. * Observable raised after camera teleportation
  115575. */
  115576. onAfterCameraTeleport: Observable<Vector3>;
  115577. /**
  115578. * Observable raised when current selected mesh gets unselected
  115579. */
  115580. onSelectedMeshUnselected: Observable<AbstractMesh>;
  115581. private _raySelectionPredicate;
  115582. /**
  115583. * To be optionaly changed by user to define custom ray selection
  115584. */
  115585. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  115586. /**
  115587. * To be optionaly changed by user to define custom selection logic (after ray selection)
  115588. */
  115589. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115590. /**
  115591. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  115592. */
  115593. teleportationEnabled: boolean;
  115594. private _defaultHeight;
  115595. private _teleportationInitialized;
  115596. private _interactionsEnabled;
  115597. private _interactionsRequested;
  115598. private _displayGaze;
  115599. private _displayLaserPointer;
  115600. /**
  115601. * The mesh used to display where the user is going to teleport.
  115602. */
  115603. get teleportationTarget(): Mesh;
  115604. /**
  115605. * Sets the mesh to be used to display where the user is going to teleport.
  115606. */
  115607. set teleportationTarget(value: Mesh);
  115608. /**
  115609. * 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
  115610. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  115611. * See http://doc.babylonjs.com/resources/baking_transformations
  115612. */
  115613. get gazeTrackerMesh(): Mesh;
  115614. set gazeTrackerMesh(value: Mesh);
  115615. /**
  115616. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  115617. */
  115618. updateGazeTrackerScale: boolean;
  115619. /**
  115620. * If the gaze trackers color should be updated when selecting meshes
  115621. */
  115622. updateGazeTrackerColor: boolean;
  115623. /**
  115624. * If the controller laser color should be updated when selecting meshes
  115625. */
  115626. updateControllerLaserColor: boolean;
  115627. /**
  115628. * The gaze tracking mesh corresponding to the left controller
  115629. */
  115630. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  115631. /**
  115632. * The gaze tracking mesh corresponding to the right controller
  115633. */
  115634. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  115635. /**
  115636. * If the ray of the gaze should be displayed.
  115637. */
  115638. get displayGaze(): boolean;
  115639. /**
  115640. * Sets if the ray of the gaze should be displayed.
  115641. */
  115642. set displayGaze(value: boolean);
  115643. /**
  115644. * If the ray of the LaserPointer should be displayed.
  115645. */
  115646. get displayLaserPointer(): boolean;
  115647. /**
  115648. * Sets if the ray of the LaserPointer should be displayed.
  115649. */
  115650. set displayLaserPointer(value: boolean);
  115651. /**
  115652. * The deviceOrientationCamera used as the camera when not in VR.
  115653. */
  115654. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  115655. /**
  115656. * Based on the current WebVR support, returns the current VR camera used.
  115657. */
  115658. get currentVRCamera(): Nullable<Camera>;
  115659. /**
  115660. * The webVRCamera which is used when in VR.
  115661. */
  115662. get webVRCamera(): WebVRFreeCamera;
  115663. /**
  115664. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  115665. */
  115666. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  115667. /**
  115668. * The html button that is used to trigger entering into VR.
  115669. */
  115670. get vrButton(): Nullable<HTMLButtonElement>;
  115671. private get _teleportationRequestInitiated();
  115672. /**
  115673. * Defines wether or not Pointer lock should be requested when switching to
  115674. * full screen.
  115675. */
  115676. requestPointerLockOnFullScreen: boolean;
  115677. /**
  115678. * If asking to force XR, this will be populated with the default xr experience
  115679. */
  115680. xr: WebXRDefaultExperience;
  115681. /**
  115682. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  115683. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  115684. */
  115685. xrTestDone: boolean;
  115686. /**
  115687. * Instantiates a VRExperienceHelper.
  115688. * Helps to quickly add VR support to an existing scene.
  115689. * @param scene The scene the VRExperienceHelper belongs to.
  115690. * @param webVROptions Options to modify the vr experience helper's behavior.
  115691. */
  115692. constructor(scene: Scene,
  115693. /** Options to modify the vr experience helper's behavior. */
  115694. webVROptions?: VRExperienceHelperOptions);
  115695. private completeVRInit;
  115696. private _onDefaultMeshLoaded;
  115697. private _onResize;
  115698. private _onFullscreenChange;
  115699. /**
  115700. * Gets a value indicating if we are currently in VR mode.
  115701. */
  115702. get isInVRMode(): boolean;
  115703. private onVrDisplayPresentChange;
  115704. private onVRDisplayChanged;
  115705. private moveButtonToBottomRight;
  115706. private displayVRButton;
  115707. private updateButtonVisibility;
  115708. private _cachedAngularSensibility;
  115709. /**
  115710. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  115711. * Otherwise, will use the fullscreen API.
  115712. */
  115713. enterVR(): void;
  115714. /**
  115715. * Attempt to exit VR, or fullscreen.
  115716. */
  115717. exitVR(): void;
  115718. /**
  115719. * The position of the vr experience helper.
  115720. */
  115721. get position(): Vector3;
  115722. /**
  115723. * Sets the position of the vr experience helper.
  115724. */
  115725. set position(value: Vector3);
  115726. /**
  115727. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  115728. */
  115729. enableInteractions(): void;
  115730. private get _noControllerIsActive();
  115731. private beforeRender;
  115732. private _isTeleportationFloor;
  115733. /**
  115734. * Adds a floor mesh to be used for teleportation.
  115735. * @param floorMesh the mesh to be used for teleportation.
  115736. */
  115737. addFloorMesh(floorMesh: Mesh): void;
  115738. /**
  115739. * Removes a floor mesh from being used for teleportation.
  115740. * @param floorMesh the mesh to be removed.
  115741. */
  115742. removeFloorMesh(floorMesh: Mesh): void;
  115743. /**
  115744. * Enables interactions and teleportation using the VR controllers and gaze.
  115745. * @param vrTeleportationOptions options to modify teleportation behavior.
  115746. */
  115747. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  115748. private _onNewGamepadConnected;
  115749. private _tryEnableInteractionOnController;
  115750. private _onNewGamepadDisconnected;
  115751. private _enableInteractionOnController;
  115752. private _checkTeleportWithRay;
  115753. private _checkRotate;
  115754. private _checkTeleportBackwards;
  115755. private _enableTeleportationOnController;
  115756. private _createTeleportationCircles;
  115757. private _displayTeleportationTarget;
  115758. private _hideTeleportationTarget;
  115759. private _rotateCamera;
  115760. private _moveTeleportationSelectorTo;
  115761. private _workingVector;
  115762. private _workingQuaternion;
  115763. private _workingMatrix;
  115764. /**
  115765. * Time Constant Teleportation Mode
  115766. */
  115767. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  115768. /**
  115769. * Speed Constant Teleportation Mode
  115770. */
  115771. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  115772. /**
  115773. * Teleports the users feet to the desired location
  115774. * @param location The location where the user's feet should be placed
  115775. */
  115776. teleportCamera(location: Vector3): void;
  115777. private _convertNormalToDirectionOfRay;
  115778. private _castRayAndSelectObject;
  115779. private _notifySelectedMeshUnselected;
  115780. /**
  115781. * Permanently set new colors for the laser pointer
  115782. * @param color the new laser color
  115783. * @param pickedColor the new laser color when picked mesh detected
  115784. */
  115785. setLaserColor(color: Color3, pickedColor?: Color3): void;
  115786. /**
  115787. * Permanently set new colors for the gaze pointer
  115788. * @param color the new gaze color
  115789. * @param pickedColor the new gaze color when picked mesh detected
  115790. */
  115791. setGazeColor(color: Color3, pickedColor?: Color3): void;
  115792. /**
  115793. * Sets the color of the laser ray from the vr controllers.
  115794. * @param color new color for the ray.
  115795. */
  115796. changeLaserColor(color: Color3): void;
  115797. /**
  115798. * Sets the color of the ray from the vr headsets gaze.
  115799. * @param color new color for the ray.
  115800. */
  115801. changeGazeColor(color: Color3): void;
  115802. /**
  115803. * Exits VR and disposes of the vr experience helper
  115804. */
  115805. dispose(): void;
  115806. /**
  115807. * Gets the name of the VRExperienceHelper class
  115808. * @returns "VRExperienceHelper"
  115809. */
  115810. getClassName(): string;
  115811. }
  115812. }
  115813. declare module BABYLON {
  115814. /**
  115815. * Options used for hit testing
  115816. */
  115817. export interface IWebXRHitTestOptions {
  115818. /**
  115819. * Only test when user interacted with the scene. Default - hit test every frame
  115820. */
  115821. testOnPointerDownOnly?: boolean;
  115822. /**
  115823. * The node to use to transform the local results to world coordinates
  115824. */
  115825. worldParentNode?: TransformNode;
  115826. }
  115827. /**
  115828. * Interface defining the babylon result of raycasting/hit-test
  115829. */
  115830. export interface IWebXRHitResult {
  115831. /**
  115832. * The native hit test result
  115833. */
  115834. xrHitResult: XRHitResult;
  115835. /**
  115836. * Transformation matrix that can be applied to a node that will put it in the hit point location
  115837. */
  115838. transformationMatrix: Matrix;
  115839. }
  115840. /**
  115841. * The currently-working hit-test module.
  115842. * Hit test (or raycasting) is used to interact with the real world.
  115843. * For further information read here - https://github.com/immersive-web/hit-test
  115844. */
  115845. export class WebXRHitTestLegacy implements IWebXRFeature {
  115846. private _xrSessionManager;
  115847. /**
  115848. * options to use when constructing this feature
  115849. */
  115850. readonly options: IWebXRHitTestOptions;
  115851. /**
  115852. * The module's name
  115853. */
  115854. static readonly Name: string;
  115855. /**
  115856. * The (Babylon) version of this module.
  115857. * This is an integer representing the implementation version.
  115858. * This number does not correspond to the webxr specs version
  115859. */
  115860. static readonly Version: number;
  115861. /**
  115862. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  115863. * @param event the (select) event to use to select with
  115864. * @param referenceSpace the reference space to use for this hit test
  115865. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  115866. */
  115867. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  115868. /**
  115869. * execute a hit test with an XR Ray
  115870. *
  115871. * @param xrSession a native xrSession that will execute this hit test
  115872. * @param xrRay the ray (position and direction) to use for raycasting
  115873. * @param referenceSpace native XR reference space to use for the hit-test
  115874. * @param filter filter function that will filter the results
  115875. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  115876. */
  115877. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  115878. /**
  115879. * Triggered when new babylon (transformed) hit test results are available
  115880. */
  115881. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  115882. /**
  115883. * Creates a new instance of the (legacy version) hit test feature
  115884. * @param _xrSessionManager an instance of WebXRSessionManager
  115885. * @param options options to use when constructing this feature
  115886. */
  115887. constructor(_xrSessionManager: WebXRSessionManager,
  115888. /**
  115889. * options to use when constructing this feature
  115890. */
  115891. options?: IWebXRHitTestOptions);
  115892. private _onSelectEnabled;
  115893. private _xrFrameObserver;
  115894. private _attached;
  115895. /**
  115896. * Populated with the last native XR Hit Results
  115897. */
  115898. lastNativeXRHitResults: XRHitResult[];
  115899. /**
  115900. * attach this feature
  115901. * Will usually be called by the features manager
  115902. *
  115903. * @returns true if successful.
  115904. */
  115905. attach(): boolean;
  115906. /**
  115907. * detach this feature.
  115908. * Will usually be called by the features manager
  115909. *
  115910. * @returns true if successful.
  115911. */
  115912. detach(): boolean;
  115913. private _onHitTestResults;
  115914. private _onSelect;
  115915. /**
  115916. * Dispose this feature and all of the resources attached
  115917. */
  115918. dispose(): void;
  115919. }
  115920. }
  115921. declare module BABYLON {
  115922. /**
  115923. * Options used in the plane detector module
  115924. */
  115925. export interface IWebXRPlaneDetectorOptions {
  115926. /**
  115927. * The node to use to transform the local results to world coordinates
  115928. */
  115929. worldParentNode?: TransformNode;
  115930. }
  115931. /**
  115932. * A babylon interface for a webxr plane.
  115933. * A Plane is actually a polygon, built from N points in space
  115934. */
  115935. export interface IWebXRPlane {
  115936. /**
  115937. * a babylon-assigned ID for this polygon
  115938. */
  115939. id: number;
  115940. /**
  115941. * the native xr-plane object
  115942. */
  115943. xrPlane: XRPlane;
  115944. /**
  115945. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  115946. */
  115947. polygonDefinition: Array<Vector3>;
  115948. /**
  115949. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  115950. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  115951. */
  115952. transformationMatrix: Matrix;
  115953. }
  115954. /**
  115955. * The plane detector is used to detect planes in the real world when in AR
  115956. * For more information see https://github.com/immersive-web/real-world-geometry/
  115957. */
  115958. export class WebXRPlaneDetector implements IWebXRFeature {
  115959. private _xrSessionManager;
  115960. private _options;
  115961. /**
  115962. * The module's name
  115963. */
  115964. static readonly Name: string;
  115965. /**
  115966. * The (Babylon) version of this module.
  115967. * This is an integer representing the implementation version.
  115968. * This number does not correspond to the webxr specs version
  115969. */
  115970. static readonly Version: number;
  115971. /**
  115972. * Observers registered here will be executed when a new plane was added to the session
  115973. */
  115974. onPlaneAddedObservable: Observable<IWebXRPlane>;
  115975. /**
  115976. * Observers registered here will be executed when a plane is no longer detected in the session
  115977. */
  115978. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  115979. /**
  115980. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  115981. * This can execute N times every frame
  115982. */
  115983. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  115984. private _enabled;
  115985. private _attached;
  115986. private _detectedPlanes;
  115987. private _lastFrameDetected;
  115988. private _observerTracked;
  115989. /**
  115990. * construct a new Plane Detector
  115991. * @param _xrSessionManager an instance of xr Session manager
  115992. * @param _options configuration to use when constructing this feature
  115993. */
  115994. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  115995. /**
  115996. * attach this feature
  115997. * Will usually be called by the features manager
  115998. *
  115999. * @returns true if successful.
  116000. */
  116001. attach(): boolean;
  116002. /**
  116003. * detach this feature.
  116004. * Will usually be called by the features manager
  116005. *
  116006. * @returns true if successful.
  116007. */
  116008. detach(): boolean;
  116009. /**
  116010. * Dispose this feature and all of the resources attached
  116011. */
  116012. dispose(): void;
  116013. private _updatePlaneWithXRPlane;
  116014. /**
  116015. * avoiding using Array.find for global support.
  116016. * @param xrPlane the plane to find in the array
  116017. */
  116018. private findIndexInPlaneArray;
  116019. }
  116020. }
  116021. declare module BABYLON {
  116022. /**
  116023. * Configuration options of the anchor system
  116024. */
  116025. export interface IWebXRAnchorSystemOptions {
  116026. /**
  116027. * a node that will be used to convert local to world coordinates
  116028. */
  116029. worldParentNode?: TransformNode;
  116030. /**
  116031. * should the anchor system use plane detection.
  116032. * If set to true, the plane-detection feature should be set using setPlaneDetector
  116033. */
  116034. usePlaneDetection?: boolean;
  116035. /**
  116036. * Should a new anchor be added every time a select event is triggered
  116037. */
  116038. addAnchorOnSelect?: boolean;
  116039. }
  116040. /**
  116041. * A babylon container for an XR Anchor
  116042. */
  116043. export interface IWebXRAnchor {
  116044. /**
  116045. * A babylon-assigned ID for this anchor
  116046. */
  116047. id: number;
  116048. /**
  116049. * The native anchor object
  116050. */
  116051. xrAnchor: XRAnchor;
  116052. /**
  116053. * Transformation matrix to apply to an object attached to this anchor
  116054. */
  116055. transformationMatrix: Matrix;
  116056. }
  116057. /**
  116058. * An implementation of the anchor system of WebXR.
  116059. * Note that the current documented implementation is not available in any browser. Future implementations
  116060. * will use the frame to create an anchor and not the session or a detected plane
  116061. * For further information see https://github.com/immersive-web/anchors/
  116062. */
  116063. export class WebXRAnchorSystem implements IWebXRFeature {
  116064. private _xrSessionManager;
  116065. private _options;
  116066. /**
  116067. * The module's name
  116068. */
  116069. static readonly Name: string;
  116070. /**
  116071. * The (Babylon) version of this module.
  116072. * This is an integer representing the implementation version.
  116073. * This number does not correspond to the webxr specs version
  116074. */
  116075. static readonly Version: number;
  116076. /**
  116077. * Observers registered here will be executed when a new anchor was added to the session
  116078. */
  116079. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  116080. /**
  116081. * Observers registered here will be executed when an existing anchor updates
  116082. * This can execute N times every frame
  116083. */
  116084. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  116085. /**
  116086. * Observers registered here will be executed when an anchor was removed from the session
  116087. */
  116088. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  116089. private _planeDetector;
  116090. private _hitTestModule;
  116091. private _enabled;
  116092. private _attached;
  116093. private _trackedAnchors;
  116094. private _lastFrameDetected;
  116095. private _observerTracked;
  116096. /**
  116097. * constructs a new anchor system
  116098. * @param _xrSessionManager an instance of WebXRSessionManager
  116099. * @param _options configuration object for this feature
  116100. */
  116101. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  116102. /**
  116103. * set the plane detector to use in order to create anchors from frames
  116104. * @param planeDetector the plane-detector module to use
  116105. * @param enable enable plane-anchors. default is true
  116106. */
  116107. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  116108. /**
  116109. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  116110. * @param hitTestModule the hit-test module to use.
  116111. */
  116112. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  116113. /**
  116114. * attach this feature
  116115. * Will usually be called by the features manager
  116116. *
  116117. * @returns true if successful.
  116118. */
  116119. attach(): boolean;
  116120. /**
  116121. * detach this feature.
  116122. * Will usually be called by the features manager
  116123. *
  116124. * @returns true if successful.
  116125. */
  116126. detach(): boolean;
  116127. /**
  116128. * Dispose this feature and all of the resources attached
  116129. */
  116130. dispose(): void;
  116131. private _onSelect;
  116132. /**
  116133. * Add anchor at a specific XR point.
  116134. *
  116135. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  116136. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  116137. * @returns a promise the fulfills when the anchor was created
  116138. */
  116139. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  116140. private _updateAnchorWithXRFrame;
  116141. /**
  116142. * avoiding using Array.find for global support.
  116143. * @param xrAnchor the plane to find in the array
  116144. */
  116145. private _findIndexInAnchorArray;
  116146. }
  116147. }
  116148. declare module BABYLON {
  116149. /**
  116150. * Options interface for the background remover plugin
  116151. */
  116152. export interface IWebXRBackgroundRemoverOptions {
  116153. /**
  116154. * don't disable the environment helper
  116155. */
  116156. ignoreEnvironmentHelper?: boolean;
  116157. /**
  116158. * flags to configure the removal of the environment helper.
  116159. * If not set, the entire background will be removed. If set, flags should be set as well.
  116160. */
  116161. environmentHelperRemovalFlags?: {
  116162. /**
  116163. * Should the skybox be removed (default false)
  116164. */
  116165. skyBox?: boolean;
  116166. /**
  116167. * Should the ground be removed (default false)
  116168. */
  116169. ground?: boolean;
  116170. };
  116171. /**
  116172. * Further background meshes to disable when entering AR
  116173. */
  116174. backgroundMeshes?: AbstractMesh[];
  116175. }
  116176. /**
  116177. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  116178. */
  116179. export class WebXRBackgroundRemover implements IWebXRFeature {
  116180. private _xrSessionManager;
  116181. /**
  116182. * read-only options to be used in this module
  116183. */
  116184. readonly options: IWebXRBackgroundRemoverOptions;
  116185. /**
  116186. * The module's name
  116187. */
  116188. static readonly Name: string;
  116189. /**
  116190. * The (Babylon) version of this module.
  116191. * This is an integer representing the implementation version.
  116192. * This number does not correspond to the webxr specs version
  116193. */
  116194. static readonly Version: number;
  116195. /**
  116196. * registered observers will be triggered when the background state changes
  116197. */
  116198. onBackgroundStateChangedObservable: Observable<boolean>;
  116199. /**
  116200. * constructs a new background remover module
  116201. * @param _xrSessionManager the session manager for this module
  116202. * @param options read-only options to be used in this module
  116203. */
  116204. constructor(_xrSessionManager: WebXRSessionManager,
  116205. /**
  116206. * read-only options to be used in this module
  116207. */
  116208. options?: IWebXRBackgroundRemoverOptions);
  116209. /**
  116210. * attach this feature
  116211. * Will usually be called by the features manager
  116212. *
  116213. * @returns true if successful.
  116214. */
  116215. attach(): boolean;
  116216. /**
  116217. * detach this feature.
  116218. * Will usually be called by the features manager
  116219. *
  116220. * @returns true if successful.
  116221. */
  116222. detach(): boolean;
  116223. private _setBackgroundState;
  116224. /**
  116225. * Dispose this feature and all of the resources attached
  116226. */
  116227. dispose(): void;
  116228. }
  116229. }
  116230. declare module BABYLON {
  116231. /**
  116232. * The motion controller class for all microsoft mixed reality controllers
  116233. */
  116234. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  116235. /**
  116236. * The base url used to load the left and right controller models
  116237. */
  116238. static MODEL_BASE_URL: string;
  116239. /**
  116240. * The name of the left controller model file
  116241. */
  116242. static MODEL_LEFT_FILENAME: string;
  116243. /**
  116244. * The name of the right controller model file
  116245. */
  116246. static MODEL_RIGHT_FILENAME: string;
  116247. profileId: string;
  116248. protected readonly _mapping: {
  116249. defaultButton: {
  116250. "valueNodeName": string;
  116251. "unpressedNodeName": string;
  116252. "pressedNodeName": string;
  116253. };
  116254. defaultAxis: {
  116255. "valueNodeName": string;
  116256. "minNodeName": string;
  116257. "maxNodeName": string;
  116258. };
  116259. buttons: {
  116260. "xr-standard-trigger": {
  116261. "rootNodeName": string;
  116262. "componentProperty": string;
  116263. "states": string[];
  116264. };
  116265. "xr-standard-squeeze": {
  116266. "rootNodeName": string;
  116267. "componentProperty": string;
  116268. "states": string[];
  116269. };
  116270. "xr-standard-touchpad": {
  116271. "rootNodeName": string;
  116272. "labelAnchorNodeName": string;
  116273. "touchPointNodeName": string;
  116274. };
  116275. "xr-standard-thumbstick": {
  116276. "rootNodeName": string;
  116277. "componentProperty": string;
  116278. "states": string[];
  116279. };
  116280. "menu": {
  116281. "rootNodeName": string;
  116282. "componentProperty": string;
  116283. "states": string[];
  116284. };
  116285. };
  116286. axes: {
  116287. "xr-standard-touchpad": {
  116288. "x-axis": {
  116289. "rootNodeName": string;
  116290. };
  116291. "y-axis": {
  116292. "rootNodeName": string;
  116293. };
  116294. };
  116295. "xr-standard-thumbstick": {
  116296. "x-axis": {
  116297. "rootNodeName": string;
  116298. };
  116299. "y-axis": {
  116300. "rootNodeName": string;
  116301. };
  116302. };
  116303. };
  116304. };
  116305. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  116306. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  116307. private _getChildByName;
  116308. private _getImmediateChildByName;
  116309. protected _getFilenameAndPath(): {
  116310. filename: string;
  116311. path: string;
  116312. };
  116313. protected _updateModel(): void;
  116314. protected _getModelLoadingConstraints(): boolean;
  116315. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116316. }
  116317. }
  116318. declare module BABYLON {
  116319. /**
  116320. * The motion controller class for oculus touch (quest, rift).
  116321. * This class supports legacy mapping as well the standard xr mapping
  116322. */
  116323. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  116324. private _forceLegacyControllers;
  116325. /**
  116326. * The base url used to load the left and right controller models
  116327. */
  116328. static MODEL_BASE_URL: string;
  116329. /**
  116330. * The name of the left controller model file
  116331. */
  116332. static MODEL_LEFT_FILENAME: string;
  116333. /**
  116334. * The name of the right controller model file
  116335. */
  116336. static MODEL_RIGHT_FILENAME: string;
  116337. /**
  116338. * Base Url for the Quest controller model.
  116339. */
  116340. static QUEST_MODEL_BASE_URL: string;
  116341. profileId: string;
  116342. private _modelRootNode;
  116343. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  116344. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  116345. protected _getFilenameAndPath(): {
  116346. filename: string;
  116347. path: string;
  116348. };
  116349. /**
  116350. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  116351. * between the touch and touch 2.
  116352. */
  116353. private _isQuest;
  116354. protected _updateModel(): void;
  116355. protected _getModelLoadingConstraints(): boolean;
  116356. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116357. }
  116358. }
  116359. declare module BABYLON {
  116360. /**
  116361. * The motion controller class for the standard HTC-Vive controllers
  116362. */
  116363. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  116364. /**
  116365. * The base url used to load the left and right controller models
  116366. */
  116367. static MODEL_BASE_URL: string;
  116368. /**
  116369. * File name for the controller model.
  116370. */
  116371. static MODEL_FILENAME: string;
  116372. profileId: string;
  116373. private _modelRootNode;
  116374. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  116375. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  116376. protected _getFilenameAndPath(): {
  116377. filename: string;
  116378. path: string;
  116379. };
  116380. protected _updateModel(): void;
  116381. protected _getModelLoadingConstraints(): boolean;
  116382. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116383. }
  116384. }
  116385. declare module BABYLON {
  116386. /**
  116387. * Contains an array of blocks representing the octree
  116388. */
  116389. export interface IOctreeContainer<T> {
  116390. /**
  116391. * Blocks within the octree
  116392. */
  116393. blocks: Array<OctreeBlock<T>>;
  116394. }
  116395. /**
  116396. * Class used to store a cell in an octree
  116397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116398. */
  116399. export class OctreeBlock<T> {
  116400. /**
  116401. * Gets the content of the current block
  116402. */
  116403. entries: T[];
  116404. /**
  116405. * Gets the list of block children
  116406. */
  116407. blocks: Array<OctreeBlock<T>>;
  116408. private _depth;
  116409. private _maxDepth;
  116410. private _capacity;
  116411. private _minPoint;
  116412. private _maxPoint;
  116413. private _boundingVectors;
  116414. private _creationFunc;
  116415. /**
  116416. * Creates a new block
  116417. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  116418. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  116419. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  116420. * @param depth defines the current depth of this block in the octree
  116421. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  116422. * @param creationFunc defines a callback to call when an element is added to the block
  116423. */
  116424. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  116425. /**
  116426. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  116427. */
  116428. get capacity(): number;
  116429. /**
  116430. * Gets the minimum vector (in world space) of the block's bounding box
  116431. */
  116432. get minPoint(): Vector3;
  116433. /**
  116434. * Gets the maximum vector (in world space) of the block's bounding box
  116435. */
  116436. get maxPoint(): Vector3;
  116437. /**
  116438. * Add a new element to this block
  116439. * @param entry defines the element to add
  116440. */
  116441. addEntry(entry: T): void;
  116442. /**
  116443. * Remove an element from this block
  116444. * @param entry defines the element to remove
  116445. */
  116446. removeEntry(entry: T): void;
  116447. /**
  116448. * Add an array of elements to this block
  116449. * @param entries defines the array of elements to add
  116450. */
  116451. addEntries(entries: T[]): void;
  116452. /**
  116453. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  116454. * @param frustumPlanes defines the frustum planes to test
  116455. * @param selection defines the array to store current content if selection is positive
  116456. * @param allowDuplicate defines if the selection array can contains duplicated entries
  116457. */
  116458. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  116459. /**
  116460. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  116461. * @param sphereCenter defines the bounding sphere center
  116462. * @param sphereRadius defines the bounding sphere radius
  116463. * @param selection defines the array to store current content if selection is positive
  116464. * @param allowDuplicate defines if the selection array can contains duplicated entries
  116465. */
  116466. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  116467. /**
  116468. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  116469. * @param ray defines the ray to test with
  116470. * @param selection defines the array to store current content if selection is positive
  116471. */
  116472. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  116473. /**
  116474. * Subdivide the content into child blocks (this block will then be empty)
  116475. */
  116476. createInnerBlocks(): void;
  116477. /**
  116478. * @hidden
  116479. */
  116480. 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;
  116481. }
  116482. }
  116483. declare module BABYLON {
  116484. /**
  116485. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  116486. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116487. */
  116488. export class Octree<T> {
  116489. /** 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.) */
  116490. maxDepth: number;
  116491. /**
  116492. * Blocks within the octree containing objects
  116493. */
  116494. blocks: Array<OctreeBlock<T>>;
  116495. /**
  116496. * Content stored in the octree
  116497. */
  116498. dynamicContent: T[];
  116499. private _maxBlockCapacity;
  116500. private _selectionContent;
  116501. private _creationFunc;
  116502. /**
  116503. * Creates a octree
  116504. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116505. * @param creationFunc function to be used to instatiate the octree
  116506. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  116507. * @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.)
  116508. */
  116509. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  116510. /** 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.) */
  116511. maxDepth?: number);
  116512. /**
  116513. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  116514. * @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);
  116515. * @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);
  116516. * @param entries meshes to be added to the octree blocks
  116517. */
  116518. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  116519. /**
  116520. * Adds a mesh to the octree
  116521. * @param entry Mesh to add to the octree
  116522. */
  116523. addMesh(entry: T): void;
  116524. /**
  116525. * Remove an element from the octree
  116526. * @param entry defines the element to remove
  116527. */
  116528. removeMesh(entry: T): void;
  116529. /**
  116530. * Selects an array of meshes within the frustum
  116531. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  116532. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  116533. * @returns array of meshes within the frustum
  116534. */
  116535. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  116536. /**
  116537. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  116538. * @param sphereCenter defines the bounding sphere center
  116539. * @param sphereRadius defines the bounding sphere radius
  116540. * @param allowDuplicate defines if the selection array can contains duplicated entries
  116541. * @returns an array of objects that intersect the sphere
  116542. */
  116543. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  116544. /**
  116545. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  116546. * @param ray defines the ray to test with
  116547. * @returns array of intersected objects
  116548. */
  116549. intersectsRay(ray: Ray): SmartArray<T>;
  116550. /**
  116551. * Adds a mesh into the octree block if it intersects the block
  116552. */
  116553. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  116554. /**
  116555. * Adds a submesh into the octree block if it intersects the block
  116556. */
  116557. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  116558. }
  116559. }
  116560. declare module BABYLON {
  116561. interface Scene {
  116562. /**
  116563. * @hidden
  116564. * Backing Filed
  116565. */
  116566. _selectionOctree: Octree<AbstractMesh>;
  116567. /**
  116568. * Gets the octree used to boost mesh selection (picking)
  116569. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116570. */
  116571. selectionOctree: Octree<AbstractMesh>;
  116572. /**
  116573. * Creates or updates the octree used to boost selection (picking)
  116574. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116575. * @param maxCapacity defines the maximum capacity per leaf
  116576. * @param maxDepth defines the maximum depth of the octree
  116577. * @returns an octree of AbstractMesh
  116578. */
  116579. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  116580. }
  116581. interface AbstractMesh {
  116582. /**
  116583. * @hidden
  116584. * Backing Field
  116585. */
  116586. _submeshesOctree: Octree<SubMesh>;
  116587. /**
  116588. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  116589. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  116590. * @param maxCapacity defines the maximum size of each block (64 by default)
  116591. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  116592. * @returns the new octree
  116593. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  116594. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116595. */
  116596. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  116597. }
  116598. /**
  116599. * Defines the octree scene component responsible to manage any octrees
  116600. * in a given scene.
  116601. */
  116602. export class OctreeSceneComponent {
  116603. /**
  116604. * The component name help to identify the component in the list of scene components.
  116605. */
  116606. readonly name: string;
  116607. /**
  116608. * The scene the component belongs to.
  116609. */
  116610. scene: Scene;
  116611. /**
  116612. * Indicates if the meshes have been checked to make sure they are isEnabled()
  116613. */
  116614. readonly checksIsEnabled: boolean;
  116615. /**
  116616. * Creates a new instance of the component for the given scene
  116617. * @param scene Defines the scene to register the component in
  116618. */
  116619. constructor(scene: Scene);
  116620. /**
  116621. * Registers the component in a given scene
  116622. */
  116623. register(): void;
  116624. /**
  116625. * Return the list of active meshes
  116626. * @returns the list of active meshes
  116627. */
  116628. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  116629. /**
  116630. * Return the list of active sub meshes
  116631. * @param mesh The mesh to get the candidates sub meshes from
  116632. * @returns the list of active sub meshes
  116633. */
  116634. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  116635. private _tempRay;
  116636. /**
  116637. * Return the list of sub meshes intersecting with a given local ray
  116638. * @param mesh defines the mesh to find the submesh for
  116639. * @param localRay defines the ray in local space
  116640. * @returns the list of intersecting sub meshes
  116641. */
  116642. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  116643. /**
  116644. * Return the list of sub meshes colliding with a collider
  116645. * @param mesh defines the mesh to find the submesh for
  116646. * @param collider defines the collider to evaluate the collision against
  116647. * @returns the list of colliding sub meshes
  116648. */
  116649. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  116650. /**
  116651. * Rebuilds the elements related to this component in case of
  116652. * context lost for instance.
  116653. */
  116654. rebuild(): void;
  116655. /**
  116656. * Disposes the component and the associated ressources.
  116657. */
  116658. dispose(): void;
  116659. }
  116660. }
  116661. declare module BABYLON {
  116662. /**
  116663. * Renders a layer on top of an existing scene
  116664. */
  116665. export class UtilityLayerRenderer implements IDisposable {
  116666. /** the original scene that will be rendered on top of */
  116667. originalScene: Scene;
  116668. private _pointerCaptures;
  116669. private _lastPointerEvents;
  116670. private static _DefaultUtilityLayer;
  116671. private static _DefaultKeepDepthUtilityLayer;
  116672. private _sharedGizmoLight;
  116673. private _renderCamera;
  116674. /**
  116675. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  116676. * @returns the camera that is used when rendering the utility layer
  116677. */
  116678. getRenderCamera(): Nullable<Camera>;
  116679. /**
  116680. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  116681. * @param cam the camera that should be used when rendering the utility layer
  116682. */
  116683. setRenderCamera(cam: Nullable<Camera>): void;
  116684. /**
  116685. * @hidden
  116686. * Light which used by gizmos to get light shading
  116687. */
  116688. _getSharedGizmoLight(): HemisphericLight;
  116689. /**
  116690. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  116691. */
  116692. pickUtilitySceneFirst: boolean;
  116693. /**
  116694. * 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)
  116695. */
  116696. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  116697. /**
  116698. * 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)
  116699. */
  116700. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  116701. /**
  116702. * The scene that is rendered on top of the original scene
  116703. */
  116704. utilityLayerScene: Scene;
  116705. /**
  116706. * If the utility layer should automatically be rendered on top of existing scene
  116707. */
  116708. shouldRender: boolean;
  116709. /**
  116710. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  116711. */
  116712. onlyCheckPointerDownEvents: boolean;
  116713. /**
  116714. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  116715. */
  116716. processAllEvents: boolean;
  116717. /**
  116718. * Observable raised when the pointer move from the utility layer scene to the main scene
  116719. */
  116720. onPointerOutObservable: Observable<number>;
  116721. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  116722. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  116723. private _afterRenderObserver;
  116724. private _sceneDisposeObserver;
  116725. private _originalPointerObserver;
  116726. /**
  116727. * Instantiates a UtilityLayerRenderer
  116728. * @param originalScene the original scene that will be rendered on top of
  116729. * @param handleEvents boolean indicating if the utility layer should handle events
  116730. */
  116731. constructor(
  116732. /** the original scene that will be rendered on top of */
  116733. originalScene: Scene, handleEvents?: boolean);
  116734. private _notifyObservers;
  116735. /**
  116736. * Renders the utility layers scene on top of the original scene
  116737. */
  116738. render(): void;
  116739. /**
  116740. * Disposes of the renderer
  116741. */
  116742. dispose(): void;
  116743. private _updateCamera;
  116744. }
  116745. }
  116746. declare module BABYLON {
  116747. /**
  116748. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  116749. */
  116750. export class Gizmo implements IDisposable {
  116751. /** The utility layer the gizmo will be added to */
  116752. gizmoLayer: UtilityLayerRenderer;
  116753. /**
  116754. * The root mesh of the gizmo
  116755. */
  116756. _rootMesh: Mesh;
  116757. private _attachedMesh;
  116758. /**
  116759. * Ratio for the scale of the gizmo (Default: 1)
  116760. */
  116761. scaleRatio: number;
  116762. /**
  116763. * If a custom mesh has been set (Default: false)
  116764. */
  116765. protected _customMeshSet: boolean;
  116766. /**
  116767. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  116768. * * When set, interactions will be enabled
  116769. */
  116770. get attachedMesh(): Nullable<AbstractMesh>;
  116771. set attachedMesh(value: Nullable<AbstractMesh>);
  116772. /**
  116773. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  116774. * @param mesh The mesh to replace the default mesh of the gizmo
  116775. */
  116776. setCustomMesh(mesh: Mesh): void;
  116777. /**
  116778. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  116779. */
  116780. updateGizmoRotationToMatchAttachedMesh: boolean;
  116781. /**
  116782. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  116783. */
  116784. updateGizmoPositionToMatchAttachedMesh: boolean;
  116785. /**
  116786. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  116787. */
  116788. updateScale: boolean;
  116789. protected _interactionsEnabled: boolean;
  116790. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  116791. private _beforeRenderObserver;
  116792. private _tempVector;
  116793. /**
  116794. * Creates a gizmo
  116795. * @param gizmoLayer The utility layer the gizmo will be added to
  116796. */
  116797. constructor(
  116798. /** The utility layer the gizmo will be added to */
  116799. gizmoLayer?: UtilityLayerRenderer);
  116800. /**
  116801. * Updates the gizmo to match the attached mesh's position/rotation
  116802. */
  116803. protected _update(): void;
  116804. /**
  116805. * Disposes of the gizmo
  116806. */
  116807. dispose(): void;
  116808. }
  116809. }
  116810. declare module BABYLON {
  116811. /**
  116812. * Single plane drag gizmo
  116813. */
  116814. export class PlaneDragGizmo extends Gizmo {
  116815. /**
  116816. * Drag behavior responsible for the gizmos dragging interactions
  116817. */
  116818. dragBehavior: PointerDragBehavior;
  116819. private _pointerObserver;
  116820. /**
  116821. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  116822. */
  116823. snapDistance: number;
  116824. /**
  116825. * Event that fires each time the gizmo snaps to a new location.
  116826. * * snapDistance is the the change in distance
  116827. */
  116828. onSnapObservable: Observable<{
  116829. snapDistance: number;
  116830. }>;
  116831. private _plane;
  116832. private _coloredMaterial;
  116833. private _hoverMaterial;
  116834. private _isEnabled;
  116835. private _parent;
  116836. /** @hidden */
  116837. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  116838. /** @hidden */
  116839. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  116840. /**
  116841. * Creates a PlaneDragGizmo
  116842. * @param gizmoLayer The utility layer the gizmo will be added to
  116843. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  116844. * @param color The color of the gizmo
  116845. */
  116846. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  116847. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  116848. /**
  116849. * If the gizmo is enabled
  116850. */
  116851. set isEnabled(value: boolean);
  116852. get isEnabled(): boolean;
  116853. /**
  116854. * Disposes of the gizmo
  116855. */
  116856. dispose(): void;
  116857. }
  116858. }
  116859. declare module BABYLON {
  116860. /**
  116861. * Gizmo that enables dragging a mesh along 3 axis
  116862. */
  116863. export class PositionGizmo extends Gizmo {
  116864. /**
  116865. * Internal gizmo used for interactions on the x axis
  116866. */
  116867. xGizmo: AxisDragGizmo;
  116868. /**
  116869. * Internal gizmo used for interactions on the y axis
  116870. */
  116871. yGizmo: AxisDragGizmo;
  116872. /**
  116873. * Internal gizmo used for interactions on the z axis
  116874. */
  116875. zGizmo: AxisDragGizmo;
  116876. /**
  116877. * Internal gizmo used for interactions on the yz plane
  116878. */
  116879. xPlaneGizmo: PlaneDragGizmo;
  116880. /**
  116881. * Internal gizmo used for interactions on the xz plane
  116882. */
  116883. yPlaneGizmo: PlaneDragGizmo;
  116884. /**
  116885. * Internal gizmo used for interactions on the xy plane
  116886. */
  116887. zPlaneGizmo: PlaneDragGizmo;
  116888. /**
  116889. * private variables
  116890. */
  116891. private _meshAttached;
  116892. private _updateGizmoRotationToMatchAttachedMesh;
  116893. private _snapDistance;
  116894. private _scaleRatio;
  116895. /** Fires an event when any of it's sub gizmos are dragged */
  116896. onDragStartObservable: Observable<unknown>;
  116897. /** Fires an event when any of it's sub gizmos are released from dragging */
  116898. onDragEndObservable: Observable<unknown>;
  116899. /**
  116900. * If set to true, planar drag is enabled
  116901. */
  116902. private _planarGizmoEnabled;
  116903. get attachedMesh(): Nullable<AbstractMesh>;
  116904. set attachedMesh(mesh: Nullable<AbstractMesh>);
  116905. /**
  116906. * Creates a PositionGizmo
  116907. * @param gizmoLayer The utility layer the gizmo will be added to
  116908. */
  116909. constructor(gizmoLayer?: UtilityLayerRenderer);
  116910. /**
  116911. * If the planar drag gizmo is enabled
  116912. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  116913. */
  116914. set planarGizmoEnabled(value: boolean);
  116915. get planarGizmoEnabled(): boolean;
  116916. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  116917. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  116918. /**
  116919. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  116920. */
  116921. set snapDistance(value: number);
  116922. get snapDistance(): number;
  116923. /**
  116924. * Ratio for the scale of the gizmo (Default: 1)
  116925. */
  116926. set scaleRatio(value: number);
  116927. get scaleRatio(): number;
  116928. /**
  116929. * Disposes of the gizmo
  116930. */
  116931. dispose(): void;
  116932. /**
  116933. * CustomMeshes are not supported by this gizmo
  116934. * @param mesh The mesh to replace the default mesh of the gizmo
  116935. */
  116936. setCustomMesh(mesh: Mesh): void;
  116937. }
  116938. }
  116939. declare module BABYLON {
  116940. /**
  116941. * Single axis drag gizmo
  116942. */
  116943. export class AxisDragGizmo extends Gizmo {
  116944. /**
  116945. * Drag behavior responsible for the gizmos dragging interactions
  116946. */
  116947. dragBehavior: PointerDragBehavior;
  116948. private _pointerObserver;
  116949. /**
  116950. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  116951. */
  116952. snapDistance: number;
  116953. /**
  116954. * Event that fires each time the gizmo snaps to a new location.
  116955. * * snapDistance is the the change in distance
  116956. */
  116957. onSnapObservable: Observable<{
  116958. snapDistance: number;
  116959. }>;
  116960. private _isEnabled;
  116961. private _parent;
  116962. private _arrow;
  116963. private _coloredMaterial;
  116964. private _hoverMaterial;
  116965. /** @hidden */
  116966. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  116967. /** @hidden */
  116968. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  116969. /**
  116970. * Creates an AxisDragGizmo
  116971. * @param gizmoLayer The utility layer the gizmo will be added to
  116972. * @param dragAxis The axis which the gizmo will be able to drag on
  116973. * @param color The color of the gizmo
  116974. */
  116975. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  116976. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  116977. /**
  116978. * If the gizmo is enabled
  116979. */
  116980. set isEnabled(value: boolean);
  116981. get isEnabled(): boolean;
  116982. /**
  116983. * Disposes of the gizmo
  116984. */
  116985. dispose(): void;
  116986. }
  116987. }
  116988. declare module BABYLON.Debug {
  116989. /**
  116990. * The Axes viewer will show 3 axes in a specific point in space
  116991. */
  116992. export class AxesViewer {
  116993. private _xAxis;
  116994. private _yAxis;
  116995. private _zAxis;
  116996. private _scaleLinesFactor;
  116997. private _instanced;
  116998. /**
  116999. * Gets the hosting scene
  117000. */
  117001. scene: Scene;
  117002. /**
  117003. * Gets or sets a number used to scale line length
  117004. */
  117005. scaleLines: number;
  117006. /** Gets the node hierarchy used to render x-axis */
  117007. get xAxis(): TransformNode;
  117008. /** Gets the node hierarchy used to render y-axis */
  117009. get yAxis(): TransformNode;
  117010. /** Gets the node hierarchy used to render z-axis */
  117011. get zAxis(): TransformNode;
  117012. /**
  117013. * Creates a new AxesViewer
  117014. * @param scene defines the hosting scene
  117015. * @param scaleLines defines a number used to scale line length (1 by default)
  117016. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  117017. * @param xAxis defines the node hierarchy used to render the x-axis
  117018. * @param yAxis defines the node hierarchy used to render the y-axis
  117019. * @param zAxis defines the node hierarchy used to render the z-axis
  117020. */
  117021. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  117022. /**
  117023. * Force the viewer to update
  117024. * @param position defines the position of the viewer
  117025. * @param xaxis defines the x axis of the viewer
  117026. * @param yaxis defines the y axis of the viewer
  117027. * @param zaxis defines the z axis of the viewer
  117028. */
  117029. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  117030. /**
  117031. * Creates an instance of this axes viewer.
  117032. * @returns a new axes viewer with instanced meshes
  117033. */
  117034. createInstance(): AxesViewer;
  117035. /** Releases resources */
  117036. dispose(): void;
  117037. private static _SetRenderingGroupId;
  117038. }
  117039. }
  117040. declare module BABYLON.Debug {
  117041. /**
  117042. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  117043. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  117044. */
  117045. export class BoneAxesViewer extends AxesViewer {
  117046. /**
  117047. * Gets or sets the target mesh where to display the axes viewer
  117048. */
  117049. mesh: Nullable<Mesh>;
  117050. /**
  117051. * Gets or sets the target bone where to display the axes viewer
  117052. */
  117053. bone: Nullable<Bone>;
  117054. /** Gets current position */
  117055. pos: Vector3;
  117056. /** Gets direction of X axis */
  117057. xaxis: Vector3;
  117058. /** Gets direction of Y axis */
  117059. yaxis: Vector3;
  117060. /** Gets direction of Z axis */
  117061. zaxis: Vector3;
  117062. /**
  117063. * Creates a new BoneAxesViewer
  117064. * @param scene defines the hosting scene
  117065. * @param bone defines the target bone
  117066. * @param mesh defines the target mesh
  117067. * @param scaleLines defines a scaling factor for line length (1 by default)
  117068. */
  117069. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  117070. /**
  117071. * Force the viewer to update
  117072. */
  117073. update(): void;
  117074. /** Releases resources */
  117075. dispose(): void;
  117076. }
  117077. }
  117078. declare module BABYLON {
  117079. /**
  117080. * Interface used to define scene explorer extensibility option
  117081. */
  117082. export interface IExplorerExtensibilityOption {
  117083. /**
  117084. * Define the option label
  117085. */
  117086. label: string;
  117087. /**
  117088. * Defines the action to execute on click
  117089. */
  117090. action: (entity: any) => void;
  117091. }
  117092. /**
  117093. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  117094. */
  117095. export interface IExplorerExtensibilityGroup {
  117096. /**
  117097. * Defines a predicate to test if a given type mut be extended
  117098. */
  117099. predicate: (entity: any) => boolean;
  117100. /**
  117101. * Gets the list of options added to a type
  117102. */
  117103. entries: IExplorerExtensibilityOption[];
  117104. }
  117105. /**
  117106. * Interface used to define the options to use to create the Inspector
  117107. */
  117108. export interface IInspectorOptions {
  117109. /**
  117110. * Display in overlay mode (default: false)
  117111. */
  117112. overlay?: boolean;
  117113. /**
  117114. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  117115. */
  117116. globalRoot?: HTMLElement;
  117117. /**
  117118. * Display the Scene explorer
  117119. */
  117120. showExplorer?: boolean;
  117121. /**
  117122. * Display the property inspector
  117123. */
  117124. showInspector?: boolean;
  117125. /**
  117126. * Display in embed mode (both panes on the right)
  117127. */
  117128. embedMode?: boolean;
  117129. /**
  117130. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  117131. */
  117132. handleResize?: boolean;
  117133. /**
  117134. * Allow the panes to popup (default: true)
  117135. */
  117136. enablePopup?: boolean;
  117137. /**
  117138. * Allow the panes to be closed by users (default: true)
  117139. */
  117140. enableClose?: boolean;
  117141. /**
  117142. * Optional list of extensibility entries
  117143. */
  117144. explorerExtensibility?: IExplorerExtensibilityGroup[];
  117145. /**
  117146. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  117147. */
  117148. inspectorURL?: string;
  117149. /**
  117150. * Optional initial tab (default to DebugLayerTab.Properties)
  117151. */
  117152. initialTab?: DebugLayerTab;
  117153. }
  117154. interface Scene {
  117155. /**
  117156. * @hidden
  117157. * Backing field
  117158. */
  117159. _debugLayer: DebugLayer;
  117160. /**
  117161. * Gets the debug layer (aka Inspector) associated with the scene
  117162. * @see http://doc.babylonjs.com/features/playground_debuglayer
  117163. */
  117164. debugLayer: DebugLayer;
  117165. }
  117166. /**
  117167. * Enum of inspector action tab
  117168. */
  117169. export enum DebugLayerTab {
  117170. /**
  117171. * Properties tag (default)
  117172. */
  117173. Properties = 0,
  117174. /**
  117175. * Debug tab
  117176. */
  117177. Debug = 1,
  117178. /**
  117179. * Statistics tab
  117180. */
  117181. Statistics = 2,
  117182. /**
  117183. * Tools tab
  117184. */
  117185. Tools = 3,
  117186. /**
  117187. * Settings tab
  117188. */
  117189. Settings = 4
  117190. }
  117191. /**
  117192. * The debug layer (aka Inspector) is the go to tool in order to better understand
  117193. * what is happening in your scene
  117194. * @see http://doc.babylonjs.com/features/playground_debuglayer
  117195. */
  117196. export class DebugLayer {
  117197. /**
  117198. * Define the url to get the inspector script from.
  117199. * By default it uses the babylonjs CDN.
  117200. * @ignoreNaming
  117201. */
  117202. static InspectorURL: string;
  117203. private _scene;
  117204. private BJSINSPECTOR;
  117205. private _onPropertyChangedObservable?;
  117206. /**
  117207. * Observable triggered when a property is changed through the inspector.
  117208. */
  117209. get onPropertyChangedObservable(): any;
  117210. /**
  117211. * Instantiates a new debug layer.
  117212. * The debug layer (aka Inspector) is the go to tool in order to better understand
  117213. * what is happening in your scene
  117214. * @see http://doc.babylonjs.com/features/playground_debuglayer
  117215. * @param scene Defines the scene to inspect
  117216. */
  117217. constructor(scene: Scene);
  117218. /** Creates the inspector window. */
  117219. private _createInspector;
  117220. /**
  117221. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  117222. * @param entity defines the entity to select
  117223. * @param lineContainerTitle defines the specific block to highlight
  117224. */
  117225. select(entity: any, lineContainerTitle?: string): void;
  117226. /** Get the inspector from bundle or global */
  117227. private _getGlobalInspector;
  117228. /**
  117229. * Get if the inspector is visible or not.
  117230. * @returns true if visible otherwise, false
  117231. */
  117232. isVisible(): boolean;
  117233. /**
  117234. * Hide the inspector and close its window.
  117235. */
  117236. hide(): void;
  117237. /**
  117238. * Launch the debugLayer.
  117239. * @param config Define the configuration of the inspector
  117240. * @return a promise fulfilled when the debug layer is visible
  117241. */
  117242. show(config?: IInspectorOptions): Promise<DebugLayer>;
  117243. }
  117244. }
  117245. declare module BABYLON {
  117246. /**
  117247. * Class containing static functions to help procedurally build meshes
  117248. */
  117249. export class BoxBuilder {
  117250. /**
  117251. * Creates a box mesh
  117252. * * The parameter `size` sets the size (float) of each box side (default 1)
  117253. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  117254. * * 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)
  117255. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117259. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117260. * @param name defines the name of the mesh
  117261. * @param options defines the options used to create the mesh
  117262. * @param scene defines the hosting scene
  117263. * @returns the box mesh
  117264. */
  117265. static CreateBox(name: string, options: {
  117266. size?: number;
  117267. width?: number;
  117268. height?: number;
  117269. depth?: number;
  117270. faceUV?: Vector4[];
  117271. faceColors?: Color4[];
  117272. sideOrientation?: number;
  117273. frontUVs?: Vector4;
  117274. backUVs?: Vector4;
  117275. wrap?: boolean;
  117276. topBaseAt?: number;
  117277. bottomBaseAt?: number;
  117278. updatable?: boolean;
  117279. }, scene?: Nullable<Scene>): Mesh;
  117280. }
  117281. }
  117282. declare module BABYLON {
  117283. /**
  117284. * Class containing static functions to help procedurally build meshes
  117285. */
  117286. export class SphereBuilder {
  117287. /**
  117288. * Creates a sphere mesh
  117289. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117290. * * 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`)
  117291. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117292. * * 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
  117293. * * 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)
  117294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117297. * @param name defines the name of the mesh
  117298. * @param options defines the options used to create the mesh
  117299. * @param scene defines the hosting scene
  117300. * @returns the sphere mesh
  117301. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117302. */
  117303. static CreateSphere(name: string, options: {
  117304. segments?: number;
  117305. diameter?: number;
  117306. diameterX?: number;
  117307. diameterY?: number;
  117308. diameterZ?: number;
  117309. arc?: number;
  117310. slice?: number;
  117311. sideOrientation?: number;
  117312. frontUVs?: Vector4;
  117313. backUVs?: Vector4;
  117314. updatable?: boolean;
  117315. }, scene?: Nullable<Scene>): Mesh;
  117316. }
  117317. }
  117318. declare module BABYLON.Debug {
  117319. /**
  117320. * Used to show the physics impostor around the specific mesh
  117321. */
  117322. export class PhysicsViewer {
  117323. /** @hidden */
  117324. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  117325. /** @hidden */
  117326. protected _meshes: Array<Nullable<AbstractMesh>>;
  117327. /** @hidden */
  117328. protected _scene: Nullable<Scene>;
  117329. /** @hidden */
  117330. protected _numMeshes: number;
  117331. /** @hidden */
  117332. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  117333. private _renderFunction;
  117334. private _utilityLayer;
  117335. private _debugBoxMesh;
  117336. private _debugSphereMesh;
  117337. private _debugCylinderMesh;
  117338. private _debugMaterial;
  117339. private _debugMeshMeshes;
  117340. /**
  117341. * Creates a new PhysicsViewer
  117342. * @param scene defines the hosting scene
  117343. */
  117344. constructor(scene: Scene);
  117345. /** @hidden */
  117346. protected _updateDebugMeshes(): void;
  117347. /**
  117348. * Renders a specified physic impostor
  117349. * @param impostor defines the impostor to render
  117350. * @param targetMesh defines the mesh represented by the impostor
  117351. * @returns the new debug mesh used to render the impostor
  117352. */
  117353. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  117354. /**
  117355. * Hides a specified physic impostor
  117356. * @param impostor defines the impostor to hide
  117357. */
  117358. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  117359. private _getDebugMaterial;
  117360. private _getDebugBoxMesh;
  117361. private _getDebugSphereMesh;
  117362. private _getDebugCylinderMesh;
  117363. private _getDebugMeshMesh;
  117364. private _getDebugMesh;
  117365. /** Releases all resources */
  117366. dispose(): void;
  117367. }
  117368. }
  117369. declare module BABYLON {
  117370. /**
  117371. * Class containing static functions to help procedurally build meshes
  117372. */
  117373. export class LinesBuilder {
  117374. /**
  117375. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117376. * * 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
  117377. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117378. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117379. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117380. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117381. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117382. * * 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
  117383. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117386. * @param name defines the name of the new line system
  117387. * @param options defines the options used to create the line system
  117388. * @param scene defines the hosting scene
  117389. * @returns a new line system mesh
  117390. */
  117391. static CreateLineSystem(name: string, options: {
  117392. lines: Vector3[][];
  117393. updatable?: boolean;
  117394. instance?: Nullable<LinesMesh>;
  117395. colors?: Nullable<Color4[][]>;
  117396. useVertexAlpha?: boolean;
  117397. }, scene: Nullable<Scene>): LinesMesh;
  117398. /**
  117399. * Creates a line mesh
  117400. * 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
  117401. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117402. * * The parameter `points` is an array successive Vector3
  117403. * * 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
  117404. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117405. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117406. * * When updating an instance, remember that only point positions can change, not the number of points
  117407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117409. * @param name defines the name of the new line system
  117410. * @param options defines the options used to create the line system
  117411. * @param scene defines the hosting scene
  117412. * @returns a new line mesh
  117413. */
  117414. static CreateLines(name: string, options: {
  117415. points: Vector3[];
  117416. updatable?: boolean;
  117417. instance?: Nullable<LinesMesh>;
  117418. colors?: Color4[];
  117419. useVertexAlpha?: boolean;
  117420. }, scene?: Nullable<Scene>): LinesMesh;
  117421. /**
  117422. * Creates a dashed line mesh
  117423. * * 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
  117424. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117425. * * The parameter `points` is an array successive Vector3
  117426. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117427. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117428. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117429. * * 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
  117430. * * When updating an instance, remember that only point positions can change, not the number of points
  117431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117432. * @param name defines the name of the mesh
  117433. * @param options defines the options used to create the mesh
  117434. * @param scene defines the hosting scene
  117435. * @returns the dashed line mesh
  117436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117437. */
  117438. static CreateDashedLines(name: string, options: {
  117439. points: Vector3[];
  117440. dashSize?: number;
  117441. gapSize?: number;
  117442. dashNb?: number;
  117443. updatable?: boolean;
  117444. instance?: LinesMesh;
  117445. }, scene?: Nullable<Scene>): LinesMesh;
  117446. }
  117447. }
  117448. declare module BABYLON {
  117449. /**
  117450. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  117451. * in order to better appreciate the issue one might have.
  117452. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  117453. */
  117454. export class RayHelper {
  117455. /**
  117456. * Defines the ray we are currently tryin to visualize.
  117457. */
  117458. ray: Nullable<Ray>;
  117459. private _renderPoints;
  117460. private _renderLine;
  117461. private _renderFunction;
  117462. private _scene;
  117463. private _updateToMeshFunction;
  117464. private _attachedToMesh;
  117465. private _meshSpaceDirection;
  117466. private _meshSpaceOrigin;
  117467. /**
  117468. * Helper function to create a colored helper in a scene in one line.
  117469. * @param ray Defines the ray we are currently tryin to visualize
  117470. * @param scene Defines the scene the ray is used in
  117471. * @param color Defines the color we want to see the ray in
  117472. * @returns The newly created ray helper.
  117473. */
  117474. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  117475. /**
  117476. * Instantiate a new ray helper.
  117477. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  117478. * in order to better appreciate the issue one might have.
  117479. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  117480. * @param ray Defines the ray we are currently tryin to visualize
  117481. */
  117482. constructor(ray: Ray);
  117483. /**
  117484. * Shows the ray we are willing to debug.
  117485. * @param scene Defines the scene the ray needs to be rendered in
  117486. * @param color Defines the color the ray needs to be rendered in
  117487. */
  117488. show(scene: Scene, color?: Color3): void;
  117489. /**
  117490. * Hides the ray we are debugging.
  117491. */
  117492. hide(): void;
  117493. private _render;
  117494. /**
  117495. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  117496. * @param mesh Defines the mesh we want the helper attached to
  117497. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  117498. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  117499. * @param length Defines the length of the ray
  117500. */
  117501. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  117502. /**
  117503. * Detach the ray helper from the mesh it has previously been attached to.
  117504. */
  117505. detachFromMesh(): void;
  117506. private _updateToMesh;
  117507. /**
  117508. * Dispose the helper and release its associated resources.
  117509. */
  117510. dispose(): void;
  117511. }
  117512. }
  117513. declare module BABYLON.Debug {
  117514. /**
  117515. * Class used to render a debug view of a given skeleton
  117516. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  117517. */
  117518. export class SkeletonViewer {
  117519. /** defines the skeleton to render */
  117520. skeleton: Skeleton;
  117521. /** defines the mesh attached to the skeleton */
  117522. mesh: AbstractMesh;
  117523. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  117524. autoUpdateBonesMatrices: boolean;
  117525. /** defines the rendering group id to use with the viewer */
  117526. renderingGroupId: number;
  117527. /** Gets or sets the color used to render the skeleton */
  117528. color: Color3;
  117529. private _scene;
  117530. private _debugLines;
  117531. private _debugMesh;
  117532. private _isEnabled;
  117533. private _renderFunction;
  117534. private _utilityLayer;
  117535. /**
  117536. * Returns the mesh used to render the bones
  117537. */
  117538. get debugMesh(): Nullable<LinesMesh>;
  117539. /**
  117540. * Creates a new SkeletonViewer
  117541. * @param skeleton defines the skeleton to render
  117542. * @param mesh defines the mesh attached to the skeleton
  117543. * @param scene defines the hosting scene
  117544. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  117545. * @param renderingGroupId defines the rendering group id to use with the viewer
  117546. */
  117547. constructor(
  117548. /** defines the skeleton to render */
  117549. skeleton: Skeleton,
  117550. /** defines the mesh attached to the skeleton */
  117551. mesh: AbstractMesh, scene: Scene,
  117552. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  117553. autoUpdateBonesMatrices?: boolean,
  117554. /** defines the rendering group id to use with the viewer */
  117555. renderingGroupId?: number);
  117556. /** Gets or sets a boolean indicating if the viewer is enabled */
  117557. set isEnabled(value: boolean);
  117558. get isEnabled(): boolean;
  117559. private _getBonePosition;
  117560. private _getLinesForBonesWithLength;
  117561. private _getLinesForBonesNoLength;
  117562. /** Update the viewer to sync with current skeleton state */
  117563. update(): void;
  117564. /** Release associated resources */
  117565. dispose(): void;
  117566. }
  117567. }
  117568. declare module BABYLON {
  117569. /**
  117570. * Options to create the null engine
  117571. */
  117572. export class NullEngineOptions {
  117573. /**
  117574. * Render width (Default: 512)
  117575. */
  117576. renderWidth: number;
  117577. /**
  117578. * Render height (Default: 256)
  117579. */
  117580. renderHeight: number;
  117581. /**
  117582. * Texture size (Default: 512)
  117583. */
  117584. textureSize: number;
  117585. /**
  117586. * If delta time between frames should be constant
  117587. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117588. */
  117589. deterministicLockstep: boolean;
  117590. /**
  117591. * Maximum about of steps between frames (Default: 4)
  117592. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117593. */
  117594. lockstepMaxSteps: number;
  117595. }
  117596. /**
  117597. * The null engine class provides support for headless version of babylon.js.
  117598. * This can be used in server side scenario or for testing purposes
  117599. */
  117600. export class NullEngine extends Engine {
  117601. private _options;
  117602. /**
  117603. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  117604. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117605. * @returns true if engine is in deterministic lock step mode
  117606. */
  117607. isDeterministicLockStep(): boolean;
  117608. /**
  117609. * Gets the max steps when engine is running in deterministic lock step
  117610. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117611. * @returns the max steps
  117612. */
  117613. getLockstepMaxSteps(): number;
  117614. /**
  117615. * Gets the current hardware scaling level.
  117616. * By default the hardware scaling level is computed from the window device ratio.
  117617. * 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.
  117618. * @returns a number indicating the current hardware scaling level
  117619. */
  117620. getHardwareScalingLevel(): number;
  117621. constructor(options?: NullEngineOptions);
  117622. /**
  117623. * Creates a vertex buffer
  117624. * @param vertices the data for the vertex buffer
  117625. * @returns the new WebGL static buffer
  117626. */
  117627. createVertexBuffer(vertices: FloatArray): DataBuffer;
  117628. /**
  117629. * Creates a new index buffer
  117630. * @param indices defines the content of the index buffer
  117631. * @param updatable defines if the index buffer must be updatable
  117632. * @returns a new webGL buffer
  117633. */
  117634. createIndexBuffer(indices: IndicesArray): DataBuffer;
  117635. /**
  117636. * Clear the current render buffer or the current render target (if any is set up)
  117637. * @param color defines the color to use
  117638. * @param backBuffer defines if the back buffer must be cleared
  117639. * @param depth defines if the depth buffer must be cleared
  117640. * @param stencil defines if the stencil buffer must be cleared
  117641. */
  117642. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  117643. /**
  117644. * Gets the current render width
  117645. * @param useScreen defines if screen size must be used (or the current render target if any)
  117646. * @returns a number defining the current render width
  117647. */
  117648. getRenderWidth(useScreen?: boolean): number;
  117649. /**
  117650. * Gets the current render height
  117651. * @param useScreen defines if screen size must be used (or the current render target if any)
  117652. * @returns a number defining the current render height
  117653. */
  117654. getRenderHeight(useScreen?: boolean): number;
  117655. /**
  117656. * Set the WebGL's viewport
  117657. * @param viewport defines the viewport element to be used
  117658. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  117659. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  117660. */
  117661. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  117662. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  117663. /**
  117664. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  117665. * @param pipelineContext defines the pipeline context to use
  117666. * @param uniformsNames defines the list of uniform names
  117667. * @returns an array of webGL uniform locations
  117668. */
  117669. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  117670. /**
  117671. * Gets the lsit of active attributes for a given webGL program
  117672. * @param pipelineContext defines the pipeline context to use
  117673. * @param attributesNames defines the list of attribute names to get
  117674. * @returns an array of indices indicating the offset of each attribute
  117675. */
  117676. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  117677. /**
  117678. * Binds an effect to the webGL context
  117679. * @param effect defines the effect to bind
  117680. */
  117681. bindSamplers(effect: Effect): void;
  117682. /**
  117683. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  117684. * @param effect defines the effect to activate
  117685. */
  117686. enableEffect(effect: Effect): void;
  117687. /**
  117688. * Set various states to the webGL context
  117689. * @param culling defines backface culling state
  117690. * @param zOffset defines the value to apply to zOffset (0 by default)
  117691. * @param force defines if states must be applied even if cache is up to date
  117692. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  117693. */
  117694. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117695. /**
  117696. * Set the value of an uniform to an array of int32
  117697. * @param uniform defines the webGL uniform location where to store the value
  117698. * @param array defines the array of int32 to store
  117699. */
  117700. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  117701. /**
  117702. * Set the value of an uniform to an array of int32 (stored as vec2)
  117703. * @param uniform defines the webGL uniform location where to store the value
  117704. * @param array defines the array of int32 to store
  117705. */
  117706. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  117707. /**
  117708. * Set the value of an uniform to an array of int32 (stored as vec3)
  117709. * @param uniform defines the webGL uniform location where to store the value
  117710. * @param array defines the array of int32 to store
  117711. */
  117712. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  117713. /**
  117714. * Set the value of an uniform to an array of int32 (stored as vec4)
  117715. * @param uniform defines the webGL uniform location where to store the value
  117716. * @param array defines the array of int32 to store
  117717. */
  117718. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  117719. /**
  117720. * Set the value of an uniform to an array of float32
  117721. * @param uniform defines the webGL uniform location where to store the value
  117722. * @param array defines the array of float32 to store
  117723. */
  117724. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  117725. /**
  117726. * Set the value of an uniform to an array of float32 (stored as vec2)
  117727. * @param uniform defines the webGL uniform location where to store the value
  117728. * @param array defines the array of float32 to store
  117729. */
  117730. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  117731. /**
  117732. * Set the value of an uniform to an array of float32 (stored as vec3)
  117733. * @param uniform defines the webGL uniform location where to store the value
  117734. * @param array defines the array of float32 to store
  117735. */
  117736. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  117737. /**
  117738. * Set the value of an uniform to an array of float32 (stored as vec4)
  117739. * @param uniform defines the webGL uniform location where to store the value
  117740. * @param array defines the array of float32 to store
  117741. */
  117742. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  117743. /**
  117744. * Set the value of an uniform to an array of number
  117745. * @param uniform defines the webGL uniform location where to store the value
  117746. * @param array defines the array of number to store
  117747. */
  117748. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  117749. /**
  117750. * Set the value of an uniform to an array of number (stored as vec2)
  117751. * @param uniform defines the webGL uniform location where to store the value
  117752. * @param array defines the array of number to store
  117753. */
  117754. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  117755. /**
  117756. * Set the value of an uniform to an array of number (stored as vec3)
  117757. * @param uniform defines the webGL uniform location where to store the value
  117758. * @param array defines the array of number to store
  117759. */
  117760. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  117761. /**
  117762. * Set the value of an uniform to an array of number (stored as vec4)
  117763. * @param uniform defines the webGL uniform location where to store the value
  117764. * @param array defines the array of number to store
  117765. */
  117766. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  117767. /**
  117768. * Set the value of an uniform to an array of float32 (stored as matrices)
  117769. * @param uniform defines the webGL uniform location where to store the value
  117770. * @param matrices defines the array of float32 to store
  117771. */
  117772. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  117773. /**
  117774. * Set the value of an uniform to a matrix (3x3)
  117775. * @param uniform defines the webGL uniform location where to store the value
  117776. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  117777. */
  117778. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117779. /**
  117780. * Set the value of an uniform to a matrix (2x2)
  117781. * @param uniform defines the webGL uniform location where to store the value
  117782. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  117783. */
  117784. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117785. /**
  117786. * Set the value of an uniform to a number (float)
  117787. * @param uniform defines the webGL uniform location where to store the value
  117788. * @param value defines the float number to store
  117789. */
  117790. setFloat(uniform: WebGLUniformLocation, value: number): void;
  117791. /**
  117792. * Set the value of an uniform to a vec2
  117793. * @param uniform defines the webGL uniform location where to store the value
  117794. * @param x defines the 1st component of the value
  117795. * @param y defines the 2nd component of the value
  117796. */
  117797. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  117798. /**
  117799. * Set the value of an uniform to a vec3
  117800. * @param uniform defines the webGL uniform location where to store the value
  117801. * @param x defines the 1st component of the value
  117802. * @param y defines the 2nd component of the value
  117803. * @param z defines the 3rd component of the value
  117804. */
  117805. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  117806. /**
  117807. * Set the value of an uniform to a boolean
  117808. * @param uniform defines the webGL uniform location where to store the value
  117809. * @param bool defines the boolean to store
  117810. */
  117811. setBool(uniform: WebGLUniformLocation, bool: number): void;
  117812. /**
  117813. * Set the value of an uniform to a vec4
  117814. * @param uniform defines the webGL uniform location where to store the value
  117815. * @param x defines the 1st component of the value
  117816. * @param y defines the 2nd component of the value
  117817. * @param z defines the 3rd component of the value
  117818. * @param w defines the 4th component of the value
  117819. */
  117820. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  117821. /**
  117822. * Sets the current alpha mode
  117823. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  117824. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  117825. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117826. */
  117827. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  117828. /**
  117829. * Bind webGl buffers directly to the webGL context
  117830. * @param vertexBuffers defines the vertex buffer to bind
  117831. * @param indexBuffer defines the index buffer to bind
  117832. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  117833. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  117834. * @param effect defines the effect associated with the vertex buffer
  117835. */
  117836. bindBuffers(vertexBuffers: {
  117837. [key: string]: VertexBuffer;
  117838. }, indexBuffer: DataBuffer, effect: Effect): void;
  117839. /**
  117840. * Force the entire cache to be cleared
  117841. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  117842. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  117843. */
  117844. wipeCaches(bruteForce?: boolean): void;
  117845. /**
  117846. * Send a draw order
  117847. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  117848. * @param indexStart defines the starting index
  117849. * @param indexCount defines the number of index to draw
  117850. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117851. */
  117852. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  117853. /**
  117854. * Draw a list of indexed primitives
  117855. * @param fillMode defines the primitive to use
  117856. * @param indexStart defines the starting index
  117857. * @param indexCount defines the number of index to draw
  117858. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117859. */
  117860. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  117861. /**
  117862. * Draw a list of unindexed primitives
  117863. * @param fillMode defines the primitive to use
  117864. * @param verticesStart defines the index of first vertex to draw
  117865. * @param verticesCount defines the count of vertices to draw
  117866. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117867. */
  117868. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  117869. /** @hidden */
  117870. _createTexture(): WebGLTexture;
  117871. /** @hidden */
  117872. _releaseTexture(texture: InternalTexture): void;
  117873. /**
  117874. * Usually called from Texture.ts.
  117875. * Passed information to create a WebGLTexture
  117876. * @param urlArg defines a value which contains one of the following:
  117877. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  117878. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  117879. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  117880. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  117881. * @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)
  117882. * @param scene needed for loading to the correct scene
  117883. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  117884. * @param onLoad optional callback to be called upon successful completion
  117885. * @param onError optional callback to be called upon failure
  117886. * @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
  117887. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  117888. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  117889. * @param forcedExtension defines the extension to use to pick the right loader
  117890. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  117891. * @returns a InternalTexture for assignment back into BABYLON.Texture
  117892. */
  117893. 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;
  117894. /**
  117895. * Creates a new render target texture
  117896. * @param size defines the size of the texture
  117897. * @param options defines the options used to create the texture
  117898. * @returns a new render target texture stored in an InternalTexture
  117899. */
  117900. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  117901. /**
  117902. * Update the sampling mode of a given texture
  117903. * @param samplingMode defines the required sampling mode
  117904. * @param texture defines the texture to update
  117905. */
  117906. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  117907. /**
  117908. * Binds the frame buffer to the specified texture.
  117909. * @param texture The texture to render to or null for the default canvas
  117910. * @param faceIndex The face of the texture to render to in case of cube texture
  117911. * @param requiredWidth The width of the target to render to
  117912. * @param requiredHeight The height of the target to render to
  117913. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  117914. * @param depthStencilTexture The depth stencil texture to use to render
  117915. * @param lodLevel defines le lod level to bind to the frame buffer
  117916. */
  117917. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  117918. /**
  117919. * Unbind the current render target texture from the webGL context
  117920. * @param texture defines the render target texture to unbind
  117921. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  117922. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  117923. */
  117924. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  117925. /**
  117926. * Creates a dynamic vertex buffer
  117927. * @param vertices the data for the dynamic vertex buffer
  117928. * @returns the new WebGL dynamic buffer
  117929. */
  117930. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  117931. /**
  117932. * Update the content of a dynamic texture
  117933. * @param texture defines the texture to update
  117934. * @param canvas defines the canvas containing the source
  117935. * @param invertY defines if data must be stored with Y axis inverted
  117936. * @param premulAlpha defines if alpha is stored as premultiplied
  117937. * @param format defines the format of the data
  117938. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  117939. */
  117940. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  117941. /**
  117942. * Gets a boolean indicating if all created effects are ready
  117943. * @returns true if all effects are ready
  117944. */
  117945. areAllEffectsReady(): boolean;
  117946. /**
  117947. * @hidden
  117948. * Get the current error code of the webGL context
  117949. * @returns the error code
  117950. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  117951. */
  117952. getError(): number;
  117953. /** @hidden */
  117954. _getUnpackAlignement(): number;
  117955. /** @hidden */
  117956. _unpackFlipY(value: boolean): void;
  117957. /**
  117958. * Update a dynamic index buffer
  117959. * @param indexBuffer defines the target index buffer
  117960. * @param indices defines the data to update
  117961. * @param offset defines the offset in the target index buffer where update should start
  117962. */
  117963. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  117964. /**
  117965. * Updates a dynamic vertex buffer.
  117966. * @param vertexBuffer the vertex buffer to update
  117967. * @param vertices the data used to update the vertex buffer
  117968. * @param byteOffset the byte offset of the data (optional)
  117969. * @param byteLength the byte length of the data (optional)
  117970. */
  117971. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  117972. /** @hidden */
  117973. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  117974. /** @hidden */
  117975. _bindTexture(channel: number, texture: InternalTexture): void;
  117976. protected _deleteBuffer(buffer: WebGLBuffer): void;
  117977. /**
  117978. * 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
  117979. */
  117980. releaseEffects(): void;
  117981. displayLoadingUI(): void;
  117982. hideLoadingUI(): void;
  117983. /** @hidden */
  117984. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117985. /** @hidden */
  117986. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117987. /** @hidden */
  117988. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117989. /** @hidden */
  117990. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  117991. }
  117992. }
  117993. declare module BABYLON {
  117994. /** @hidden */
  117995. export class _OcclusionDataStorage {
  117996. /** @hidden */
  117997. occlusionInternalRetryCounter: number;
  117998. /** @hidden */
  117999. isOcclusionQueryInProgress: boolean;
  118000. /** @hidden */
  118001. isOccluded: boolean;
  118002. /** @hidden */
  118003. occlusionRetryCount: number;
  118004. /** @hidden */
  118005. occlusionType: number;
  118006. /** @hidden */
  118007. occlusionQueryAlgorithmType: number;
  118008. }
  118009. interface Engine {
  118010. /**
  118011. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  118012. * @return the new query
  118013. */
  118014. createQuery(): WebGLQuery;
  118015. /**
  118016. * Delete and release a webGL query
  118017. * @param query defines the query to delete
  118018. * @return the current engine
  118019. */
  118020. deleteQuery(query: WebGLQuery): Engine;
  118021. /**
  118022. * Check if a given query has resolved and got its value
  118023. * @param query defines the query to check
  118024. * @returns true if the query got its value
  118025. */
  118026. isQueryResultAvailable(query: WebGLQuery): boolean;
  118027. /**
  118028. * Gets the value of a given query
  118029. * @param query defines the query to check
  118030. * @returns the value of the query
  118031. */
  118032. getQueryResult(query: WebGLQuery): number;
  118033. /**
  118034. * Initiates an occlusion query
  118035. * @param algorithmType defines the algorithm to use
  118036. * @param query defines the query to use
  118037. * @returns the current engine
  118038. * @see http://doc.babylonjs.com/features/occlusionquery
  118039. */
  118040. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  118041. /**
  118042. * Ends an occlusion query
  118043. * @see http://doc.babylonjs.com/features/occlusionquery
  118044. * @param algorithmType defines the algorithm to use
  118045. * @returns the current engine
  118046. */
  118047. endOcclusionQuery(algorithmType: number): Engine;
  118048. /**
  118049. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  118050. * Please note that only one query can be issued at a time
  118051. * @returns a time token used to track the time span
  118052. */
  118053. startTimeQuery(): Nullable<_TimeToken>;
  118054. /**
  118055. * Ends a time query
  118056. * @param token defines the token used to measure the time span
  118057. * @returns the time spent (in ns)
  118058. */
  118059. endTimeQuery(token: _TimeToken): int;
  118060. /** @hidden */
  118061. _currentNonTimestampToken: Nullable<_TimeToken>;
  118062. /** @hidden */
  118063. _createTimeQuery(): WebGLQuery;
  118064. /** @hidden */
  118065. _deleteTimeQuery(query: WebGLQuery): void;
  118066. /** @hidden */
  118067. _getGlAlgorithmType(algorithmType: number): number;
  118068. /** @hidden */
  118069. _getTimeQueryResult(query: WebGLQuery): any;
  118070. /** @hidden */
  118071. _getTimeQueryAvailability(query: WebGLQuery): any;
  118072. }
  118073. interface AbstractMesh {
  118074. /**
  118075. * Backing filed
  118076. * @hidden
  118077. */
  118078. __occlusionDataStorage: _OcclusionDataStorage;
  118079. /**
  118080. * Access property
  118081. * @hidden
  118082. */
  118083. _occlusionDataStorage: _OcclusionDataStorage;
  118084. /**
  118085. * 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.
  118086. * The default value is -1 which means don't break the query and wait till the result
  118087. * @see http://doc.babylonjs.com/features/occlusionquery
  118088. */
  118089. occlusionRetryCount: number;
  118090. /**
  118091. * 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:
  118092. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  118093. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  118094. * * 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.
  118095. * @see http://doc.babylonjs.com/features/occlusionquery
  118096. */
  118097. occlusionType: number;
  118098. /**
  118099. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  118100. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  118101. * * 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.
  118102. * @see http://doc.babylonjs.com/features/occlusionquery
  118103. */
  118104. occlusionQueryAlgorithmType: number;
  118105. /**
  118106. * 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
  118107. * @see http://doc.babylonjs.com/features/occlusionquery
  118108. */
  118109. isOccluded: boolean;
  118110. /**
  118111. * Flag to check the progress status of the query
  118112. * @see http://doc.babylonjs.com/features/occlusionquery
  118113. */
  118114. isOcclusionQueryInProgress: boolean;
  118115. }
  118116. }
  118117. declare module BABYLON {
  118118. /** @hidden */
  118119. export var _forceTransformFeedbackToBundle: boolean;
  118120. interface Engine {
  118121. /**
  118122. * Creates a webGL transform feedback object
  118123. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  118124. * @returns the webGL transform feedback object
  118125. */
  118126. createTransformFeedback(): WebGLTransformFeedback;
  118127. /**
  118128. * Delete a webGL transform feedback object
  118129. * @param value defines the webGL transform feedback object to delete
  118130. */
  118131. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  118132. /**
  118133. * Bind a webGL transform feedback object to the webgl context
  118134. * @param value defines the webGL transform feedback object to bind
  118135. */
  118136. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  118137. /**
  118138. * Begins a transform feedback operation
  118139. * @param usePoints defines if points or triangles must be used
  118140. */
  118141. beginTransformFeedback(usePoints: boolean): void;
  118142. /**
  118143. * Ends a transform feedback operation
  118144. */
  118145. endTransformFeedback(): void;
  118146. /**
  118147. * Specify the varyings to use with transform feedback
  118148. * @param program defines the associated webGL program
  118149. * @param value defines the list of strings representing the varying names
  118150. */
  118151. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  118152. /**
  118153. * Bind a webGL buffer for a transform feedback operation
  118154. * @param value defines the webGL buffer to bind
  118155. */
  118156. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  118157. }
  118158. }
  118159. declare module BABYLON {
  118160. /**
  118161. * Creation options of the multi render target texture.
  118162. */
  118163. export interface IMultiRenderTargetOptions {
  118164. /**
  118165. * Define if the texture needs to create mip maps after render.
  118166. */
  118167. generateMipMaps?: boolean;
  118168. /**
  118169. * Define the types of all the draw buffers we want to create
  118170. */
  118171. types?: number[];
  118172. /**
  118173. * Define the sampling modes of all the draw buffers we want to create
  118174. */
  118175. samplingModes?: number[];
  118176. /**
  118177. * Define if a depth buffer is required
  118178. */
  118179. generateDepthBuffer?: boolean;
  118180. /**
  118181. * Define if a stencil buffer is required
  118182. */
  118183. generateStencilBuffer?: boolean;
  118184. /**
  118185. * Define if a depth texture is required instead of a depth buffer
  118186. */
  118187. generateDepthTexture?: boolean;
  118188. /**
  118189. * Define the number of desired draw buffers
  118190. */
  118191. textureCount?: number;
  118192. /**
  118193. * Define if aspect ratio should be adapted to the texture or stay the scene one
  118194. */
  118195. doNotChangeAspectRatio?: boolean;
  118196. /**
  118197. * Define the default type of the buffers we are creating
  118198. */
  118199. defaultType?: number;
  118200. }
  118201. /**
  118202. * A multi render target, like a render target provides the ability to render to a texture.
  118203. * Unlike the render target, it can render to several draw buffers in one draw.
  118204. * This is specially interesting in deferred rendering or for any effects requiring more than
  118205. * just one color from a single pass.
  118206. */
  118207. export class MultiRenderTarget extends RenderTargetTexture {
  118208. private _internalTextures;
  118209. private _textures;
  118210. private _multiRenderTargetOptions;
  118211. /**
  118212. * Get if draw buffers are currently supported by the used hardware and browser.
  118213. */
  118214. get isSupported(): boolean;
  118215. /**
  118216. * Get the list of textures generated by the multi render target.
  118217. */
  118218. get textures(): Texture[];
  118219. /**
  118220. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  118221. */
  118222. get depthTexture(): Texture;
  118223. /**
  118224. * Set the wrapping mode on U of all the textures we are rendering to.
  118225. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  118226. */
  118227. set wrapU(wrap: number);
  118228. /**
  118229. * Set the wrapping mode on V of all the textures we are rendering to.
  118230. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  118231. */
  118232. set wrapV(wrap: number);
  118233. /**
  118234. * Instantiate a new multi render target texture.
  118235. * A multi render target, like a render target provides the ability to render to a texture.
  118236. * Unlike the render target, it can render to several draw buffers in one draw.
  118237. * This is specially interesting in deferred rendering or for any effects requiring more than
  118238. * just one color from a single pass.
  118239. * @param name Define the name of the texture
  118240. * @param size Define the size of the buffers to render to
  118241. * @param count Define the number of target we are rendering into
  118242. * @param scene Define the scene the texture belongs to
  118243. * @param options Define the options used to create the multi render target
  118244. */
  118245. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  118246. /** @hidden */
  118247. _rebuild(): void;
  118248. private _createInternalTextures;
  118249. private _createTextures;
  118250. /**
  118251. * Define the number of samples used if MSAA is enabled.
  118252. */
  118253. get samples(): number;
  118254. set samples(value: number);
  118255. /**
  118256. * Resize all the textures in the multi render target.
  118257. * Be carrefull as it will recreate all the data in the new texture.
  118258. * @param size Define the new size
  118259. */
  118260. resize(size: any): void;
  118261. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  118262. /**
  118263. * Dispose the render targets and their associated resources
  118264. */
  118265. dispose(): void;
  118266. /**
  118267. * Release all the underlying texture used as draw buffers.
  118268. */
  118269. releaseInternalTextures(): void;
  118270. }
  118271. }
  118272. declare module BABYLON {
  118273. interface ThinEngine {
  118274. /**
  118275. * Unbind a list of render target textures from the webGL context
  118276. * This is used only when drawBuffer extension or webGL2 are active
  118277. * @param textures defines the render target textures to unbind
  118278. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  118279. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  118280. */
  118281. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  118282. /**
  118283. * Create a multi render target texture
  118284. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  118285. * @param size defines the size of the texture
  118286. * @param options defines the creation options
  118287. * @returns the cube texture as an InternalTexture
  118288. */
  118289. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  118290. /**
  118291. * Update the sample count for a given multiple render target texture
  118292. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118293. * @param textures defines the textures to update
  118294. * @param samples defines the sample count to set
  118295. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118296. */
  118297. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  118298. }
  118299. }
  118300. declare module BABYLON {
  118301. /**
  118302. * Class used to define an additional view for the engine
  118303. * @see https://doc.babylonjs.com/how_to/multi_canvases
  118304. */
  118305. export class EngineView {
  118306. /** Defines the canvas where to render the view */
  118307. target: HTMLCanvasElement;
  118308. /** Defines an optional camera used to render the view (will use active camera else) */
  118309. camera?: Camera;
  118310. }
  118311. interface Engine {
  118312. /**
  118313. * Gets or sets the HTML element to use for attaching events
  118314. */
  118315. inputElement: Nullable<HTMLElement>;
  118316. /**
  118317. * Gets the current engine view
  118318. * @see https://doc.babylonjs.com/how_to/multi_canvases
  118319. */
  118320. activeView: Nullable<EngineView>;
  118321. /** Gets or sets the list of views */
  118322. views: EngineView[];
  118323. /**
  118324. * Register a new child canvas
  118325. * @param canvas defines the canvas to register
  118326. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  118327. * @returns the associated view
  118328. */
  118329. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  118330. /**
  118331. * Remove a registered child canvas
  118332. * @param canvas defines the canvas to remove
  118333. * @returns the current engine
  118334. */
  118335. unRegisterView(canvas: HTMLCanvasElement): Engine;
  118336. }
  118337. }
  118338. declare module BABYLON {
  118339. /**
  118340. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  118341. */
  118342. export interface CubeMapInfo {
  118343. /**
  118344. * The pixel array for the front face.
  118345. * This is stored in format, left to right, up to down format.
  118346. */
  118347. front: Nullable<ArrayBufferView>;
  118348. /**
  118349. * The pixel array for the back face.
  118350. * This is stored in format, left to right, up to down format.
  118351. */
  118352. back: Nullable<ArrayBufferView>;
  118353. /**
  118354. * The pixel array for the left face.
  118355. * This is stored in format, left to right, up to down format.
  118356. */
  118357. left: Nullable<ArrayBufferView>;
  118358. /**
  118359. * The pixel array for the right face.
  118360. * This is stored in format, left to right, up to down format.
  118361. */
  118362. right: Nullable<ArrayBufferView>;
  118363. /**
  118364. * The pixel array for the up face.
  118365. * This is stored in format, left to right, up to down format.
  118366. */
  118367. up: Nullable<ArrayBufferView>;
  118368. /**
  118369. * The pixel array for the down face.
  118370. * This is stored in format, left to right, up to down format.
  118371. */
  118372. down: Nullable<ArrayBufferView>;
  118373. /**
  118374. * The size of the cubemap stored.
  118375. *
  118376. * Each faces will be size * size pixels.
  118377. */
  118378. size: number;
  118379. /**
  118380. * The format of the texture.
  118381. *
  118382. * RGBA, RGB.
  118383. */
  118384. format: number;
  118385. /**
  118386. * The type of the texture data.
  118387. *
  118388. * UNSIGNED_INT, FLOAT.
  118389. */
  118390. type: number;
  118391. /**
  118392. * Specifies whether the texture is in gamma space.
  118393. */
  118394. gammaSpace: boolean;
  118395. }
  118396. /**
  118397. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  118398. */
  118399. export class PanoramaToCubeMapTools {
  118400. private static FACE_FRONT;
  118401. private static FACE_BACK;
  118402. private static FACE_RIGHT;
  118403. private static FACE_LEFT;
  118404. private static FACE_DOWN;
  118405. private static FACE_UP;
  118406. /**
  118407. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  118408. *
  118409. * @param float32Array The source data.
  118410. * @param inputWidth The width of the input panorama.
  118411. * @param inputHeight The height of the input panorama.
  118412. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  118413. * @return The cubemap data
  118414. */
  118415. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  118416. private static CreateCubemapTexture;
  118417. private static CalcProjectionSpherical;
  118418. }
  118419. }
  118420. declare module BABYLON {
  118421. /**
  118422. * Helper class dealing with the extraction of spherical polynomial dataArray
  118423. * from a cube map.
  118424. */
  118425. export class CubeMapToSphericalPolynomialTools {
  118426. private static FileFaces;
  118427. /**
  118428. * Converts a texture to the according Spherical Polynomial data.
  118429. * This extracts the first 3 orders only as they are the only one used in the lighting.
  118430. *
  118431. * @param texture The texture to extract the information from.
  118432. * @return The Spherical Polynomial data.
  118433. */
  118434. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  118435. /**
  118436. * Converts a cubemap to the according Spherical Polynomial data.
  118437. * This extracts the first 3 orders only as they are the only one used in the lighting.
  118438. *
  118439. * @param cubeInfo The Cube map to extract the information from.
  118440. * @return The Spherical Polynomial data.
  118441. */
  118442. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  118443. }
  118444. }
  118445. declare module BABYLON {
  118446. interface BaseTexture {
  118447. /**
  118448. * Get the polynomial representation of the texture data.
  118449. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  118450. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  118451. */
  118452. sphericalPolynomial: Nullable<SphericalPolynomial>;
  118453. }
  118454. }
  118455. declare module BABYLON {
  118456. /** @hidden */
  118457. export var rgbdEncodePixelShader: {
  118458. name: string;
  118459. shader: string;
  118460. };
  118461. }
  118462. declare module BABYLON {
  118463. /** @hidden */
  118464. export var rgbdDecodePixelShader: {
  118465. name: string;
  118466. shader: string;
  118467. };
  118468. }
  118469. declare module BABYLON {
  118470. /**
  118471. * Raw texture data and descriptor sufficient for WebGL texture upload
  118472. */
  118473. export interface EnvironmentTextureInfo {
  118474. /**
  118475. * Version of the environment map
  118476. */
  118477. version: number;
  118478. /**
  118479. * Width of image
  118480. */
  118481. width: number;
  118482. /**
  118483. * Irradiance information stored in the file.
  118484. */
  118485. irradiance: any;
  118486. /**
  118487. * Specular information stored in the file.
  118488. */
  118489. specular: any;
  118490. }
  118491. /**
  118492. * Defines One Image in the file. It requires only the position in the file
  118493. * as well as the length.
  118494. */
  118495. interface BufferImageData {
  118496. /**
  118497. * Length of the image data.
  118498. */
  118499. length: number;
  118500. /**
  118501. * Position of the data from the null terminator delimiting the end of the JSON.
  118502. */
  118503. position: number;
  118504. }
  118505. /**
  118506. * Defines the specular data enclosed in the file.
  118507. * This corresponds to the version 1 of the data.
  118508. */
  118509. export interface EnvironmentTextureSpecularInfoV1 {
  118510. /**
  118511. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  118512. */
  118513. specularDataPosition?: number;
  118514. /**
  118515. * This contains all the images data needed to reconstruct the cubemap.
  118516. */
  118517. mipmaps: Array<BufferImageData>;
  118518. /**
  118519. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  118520. */
  118521. lodGenerationScale: number;
  118522. }
  118523. /**
  118524. * Sets of helpers addressing the serialization and deserialization of environment texture
  118525. * stored in a BabylonJS env file.
  118526. * Those files are usually stored as .env files.
  118527. */
  118528. export class EnvironmentTextureTools {
  118529. /**
  118530. * Magic number identifying the env file.
  118531. */
  118532. private static _MagicBytes;
  118533. /**
  118534. * Gets the environment info from an env file.
  118535. * @param data The array buffer containing the .env bytes.
  118536. * @returns the environment file info (the json header) if successfully parsed.
  118537. */
  118538. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  118539. /**
  118540. * Creates an environment texture from a loaded cube texture.
  118541. * @param texture defines the cube texture to convert in env file
  118542. * @return a promise containing the environment data if succesfull.
  118543. */
  118544. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  118545. /**
  118546. * Creates a JSON representation of the spherical data.
  118547. * @param texture defines the texture containing the polynomials
  118548. * @return the JSON representation of the spherical info
  118549. */
  118550. private static _CreateEnvTextureIrradiance;
  118551. /**
  118552. * Creates the ArrayBufferViews used for initializing environment texture image data.
  118553. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  118554. * @param info parameters that determine what views will be created for accessing the underlying buffer
  118555. * @return the views described by info providing access to the underlying buffer
  118556. */
  118557. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  118558. /**
  118559. * Uploads the texture info contained in the env file to the GPU.
  118560. * @param texture defines the internal texture to upload to
  118561. * @param arrayBuffer defines the buffer cotaining the data to load
  118562. * @param info defines the texture info retrieved through the GetEnvInfo method
  118563. * @returns a promise
  118564. */
  118565. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  118566. private static _OnImageReadyAsync;
  118567. /**
  118568. * Uploads the levels of image data to the GPU.
  118569. * @param texture defines the internal texture to upload to
  118570. * @param imageData defines the array buffer views of image data [mipmap][face]
  118571. * @returns a promise
  118572. */
  118573. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  118574. /**
  118575. * Uploads spherical polynomials information to the texture.
  118576. * @param texture defines the texture we are trying to upload the information to
  118577. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  118578. */
  118579. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  118580. /** @hidden */
  118581. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  118582. }
  118583. }
  118584. declare module BABYLON {
  118585. /**
  118586. * Contains position and normal vectors for a vertex
  118587. */
  118588. export class PositionNormalVertex {
  118589. /** the position of the vertex (defaut: 0,0,0) */
  118590. position: Vector3;
  118591. /** the normal of the vertex (defaut: 0,1,0) */
  118592. normal: Vector3;
  118593. /**
  118594. * Creates a PositionNormalVertex
  118595. * @param position the position of the vertex (defaut: 0,0,0)
  118596. * @param normal the normal of the vertex (defaut: 0,1,0)
  118597. */
  118598. constructor(
  118599. /** the position of the vertex (defaut: 0,0,0) */
  118600. position?: Vector3,
  118601. /** the normal of the vertex (defaut: 0,1,0) */
  118602. normal?: Vector3);
  118603. /**
  118604. * Clones the PositionNormalVertex
  118605. * @returns the cloned PositionNormalVertex
  118606. */
  118607. clone(): PositionNormalVertex;
  118608. }
  118609. /**
  118610. * Contains position, normal and uv vectors for a vertex
  118611. */
  118612. export class PositionNormalTextureVertex {
  118613. /** the position of the vertex (defaut: 0,0,0) */
  118614. position: Vector3;
  118615. /** the normal of the vertex (defaut: 0,1,0) */
  118616. normal: Vector3;
  118617. /** the uv of the vertex (default: 0,0) */
  118618. uv: Vector2;
  118619. /**
  118620. * Creates a PositionNormalTextureVertex
  118621. * @param position the position of the vertex (defaut: 0,0,0)
  118622. * @param normal the normal of the vertex (defaut: 0,1,0)
  118623. * @param uv the uv of the vertex (default: 0,0)
  118624. */
  118625. constructor(
  118626. /** the position of the vertex (defaut: 0,0,0) */
  118627. position?: Vector3,
  118628. /** the normal of the vertex (defaut: 0,1,0) */
  118629. normal?: Vector3,
  118630. /** the uv of the vertex (default: 0,0) */
  118631. uv?: Vector2);
  118632. /**
  118633. * Clones the PositionNormalTextureVertex
  118634. * @returns the cloned PositionNormalTextureVertex
  118635. */
  118636. clone(): PositionNormalTextureVertex;
  118637. }
  118638. }
  118639. declare module BABYLON {
  118640. /** @hidden */
  118641. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  118642. private _genericAttributeLocation;
  118643. private _varyingLocationCount;
  118644. private _varyingLocationMap;
  118645. private _replacements;
  118646. private _textureCount;
  118647. private _uniforms;
  118648. lineProcessor(line: string): string;
  118649. attributeProcessor(attribute: string): string;
  118650. varyingProcessor(varying: string, isFragment: boolean): string;
  118651. uniformProcessor(uniform: string): string;
  118652. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  118653. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  118654. }
  118655. }
  118656. declare module BABYLON {
  118657. /**
  118658. * Container for accessors for natively-stored mesh data buffers.
  118659. */
  118660. class NativeDataBuffer extends DataBuffer {
  118661. /**
  118662. * Accessor value used to identify/retrieve a natively-stored index buffer.
  118663. */
  118664. nativeIndexBuffer?: any;
  118665. /**
  118666. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  118667. */
  118668. nativeVertexBuffer?: any;
  118669. }
  118670. /** @hidden */
  118671. class NativeTexture extends InternalTexture {
  118672. getInternalTexture(): InternalTexture;
  118673. getViewCount(): number;
  118674. }
  118675. /** @hidden */
  118676. export class NativeEngine extends Engine {
  118677. private readonly _native;
  118678. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  118679. private readonly INVALID_HANDLE;
  118680. getHardwareScalingLevel(): number;
  118681. constructor();
  118682. /**
  118683. * Can be used to override the current requestAnimationFrame requester.
  118684. * @hidden
  118685. */
  118686. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  118687. /**
  118688. * Override default engine behavior.
  118689. * @param color
  118690. * @param backBuffer
  118691. * @param depth
  118692. * @param stencil
  118693. */
  118694. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  118695. /**
  118696. * Gets host document
  118697. * @returns the host document object
  118698. */
  118699. getHostDocument(): Nullable<Document>;
  118700. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  118701. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  118702. createVertexBuffer(data: DataArray): NativeDataBuffer;
  118703. recordVertexArrayObject(vertexBuffers: {
  118704. [key: string]: VertexBuffer;
  118705. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  118706. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  118707. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  118708. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  118709. /**
  118710. * Draw a list of indexed primitives
  118711. * @param fillMode defines the primitive to use
  118712. * @param indexStart defines the starting index
  118713. * @param indexCount defines the number of index to draw
  118714. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  118715. */
  118716. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  118717. /**
  118718. * Draw a list of unindexed primitives
  118719. * @param fillMode defines the primitive to use
  118720. * @param verticesStart defines the index of first vertex to draw
  118721. * @param verticesCount defines the count of vertices to draw
  118722. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  118723. */
  118724. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  118725. createPipelineContext(): IPipelineContext;
  118726. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  118727. /** @hidden */
  118728. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  118729. /** @hidden */
  118730. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  118731. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  118732. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  118733. protected _setProgram(program: WebGLProgram): void;
  118734. _releaseEffect(effect: Effect): void;
  118735. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118736. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  118737. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  118738. bindSamplers(effect: Effect): void;
  118739. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  118740. getRenderWidth(useScreen?: boolean): number;
  118741. getRenderHeight(useScreen?: boolean): number;
  118742. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  118743. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118744. /**
  118745. * Set the z offset to apply to current rendering
  118746. * @param value defines the offset to apply
  118747. */
  118748. setZOffset(value: number): void;
  118749. /**
  118750. * Gets the current value of the zOffset
  118751. * @returns the current zOffset state
  118752. */
  118753. getZOffset(): number;
  118754. /**
  118755. * Enable or disable depth buffering
  118756. * @param enable defines the state to set
  118757. */
  118758. setDepthBuffer(enable: boolean): void;
  118759. /**
  118760. * Gets a boolean indicating if depth writing is enabled
  118761. * @returns the current depth writing state
  118762. */
  118763. getDepthWrite(): boolean;
  118764. /**
  118765. * Enable or disable depth writing
  118766. * @param enable defines the state to set
  118767. */
  118768. setDepthWrite(enable: boolean): void;
  118769. /**
  118770. * Enable or disable color writing
  118771. * @param enable defines the state to set
  118772. */
  118773. setColorWrite(enable: boolean): void;
  118774. /**
  118775. * Gets a boolean indicating if color writing is enabled
  118776. * @returns the current color writing state
  118777. */
  118778. getColorWrite(): boolean;
  118779. /**
  118780. * Sets alpha constants used by some alpha blending modes
  118781. * @param r defines the red component
  118782. * @param g defines the green component
  118783. * @param b defines the blue component
  118784. * @param a defines the alpha component
  118785. */
  118786. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  118787. /**
  118788. * Sets the current alpha mode
  118789. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  118790. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  118791. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  118792. */
  118793. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  118794. /**
  118795. * Gets the current alpha mode
  118796. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  118797. * @returns the current alpha mode
  118798. */
  118799. getAlphaMode(): number;
  118800. setInt(uniform: WebGLUniformLocation, int: number): void;
  118801. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  118802. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  118803. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  118804. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  118805. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  118806. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  118807. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  118808. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  118809. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  118810. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  118811. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  118812. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  118813. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  118814. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  118815. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  118816. setFloat(uniform: WebGLUniformLocation, value: number): void;
  118817. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  118818. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  118819. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  118820. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  118821. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  118822. wipeCaches(bruteForce?: boolean): void;
  118823. _createTexture(): WebGLTexture;
  118824. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  118825. /**
  118826. * Usually called from BABYLON.Texture.ts.
  118827. * Passed information to create a WebGLTexture
  118828. * @param urlArg defines a value which contains one of the following:
  118829. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  118830. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  118831. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  118832. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  118833. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  118834. * @param scene needed for loading to the correct scene
  118835. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  118836. * @param onLoad optional callback to be called upon successful completion
  118837. * @param onError optional callback to be called upon failure
  118838. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  118839. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  118840. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  118841. * @param forcedExtension defines the extension to use to pick the right loader
  118842. * @returns a InternalTexture for assignment back into BABYLON.Texture
  118843. */
  118844. 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;
  118845. /**
  118846. * Creates a cube texture
  118847. * @param rootUrl defines the url where the files to load is located
  118848. * @param scene defines the current scene
  118849. * @param files defines the list of files to load (1 per face)
  118850. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  118851. * @param onLoad defines an optional callback raised when the texture is loaded
  118852. * @param onError defines an optional callback raised if there is an issue to load the texture
  118853. * @param format defines the format of the data
  118854. * @param forcedExtension defines the extension to use to pick the right loader
  118855. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  118856. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  118857. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  118858. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  118859. * @returns the cube texture as an InternalTexture
  118860. */
  118861. 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;
  118862. private _getSamplingFilter;
  118863. private static _GetNativeTextureFormat;
  118864. createRenderTargetTexture(size: number | {
  118865. width: number;
  118866. height: number;
  118867. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  118868. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  118869. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  118870. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  118871. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  118872. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  118873. /**
  118874. * Updates a dynamic vertex buffer.
  118875. * @param vertexBuffer the vertex buffer to update
  118876. * @param data the data used to update the vertex buffer
  118877. * @param byteOffset the byte offset of the data (optional)
  118878. * @param byteLength the byte length of the data (optional)
  118879. */
  118880. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  118881. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  118882. private _updateAnisotropicLevel;
  118883. private _getAddressMode;
  118884. /** @hidden */
  118885. _bindTexture(channel: number, texture: InternalTexture): void;
  118886. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  118887. releaseEffects(): void;
  118888. /** @hidden */
  118889. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  118890. /** @hidden */
  118891. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  118892. /** @hidden */
  118893. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  118894. /** @hidden */
  118895. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  118896. }
  118897. }
  118898. declare module BABYLON {
  118899. /**
  118900. * Gather the list of clipboard event types as constants.
  118901. */
  118902. export class ClipboardEventTypes {
  118903. /**
  118904. * The clipboard event is fired when a copy command is active (pressed).
  118905. */
  118906. static readonly COPY: number;
  118907. /**
  118908. * The clipboard event is fired when a cut command is active (pressed).
  118909. */
  118910. static readonly CUT: number;
  118911. /**
  118912. * The clipboard event is fired when a paste command is active (pressed).
  118913. */
  118914. static readonly PASTE: number;
  118915. }
  118916. /**
  118917. * This class is used to store clipboard related info for the onClipboardObservable event.
  118918. */
  118919. export class ClipboardInfo {
  118920. /**
  118921. * Defines the type of event (BABYLON.ClipboardEventTypes)
  118922. */
  118923. type: number;
  118924. /**
  118925. * Defines the related dom event
  118926. */
  118927. event: ClipboardEvent;
  118928. /**
  118929. *Creates an instance of ClipboardInfo.
  118930. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  118931. * @param event Defines the related dom event
  118932. */
  118933. constructor(
  118934. /**
  118935. * Defines the type of event (BABYLON.ClipboardEventTypes)
  118936. */
  118937. type: number,
  118938. /**
  118939. * Defines the related dom event
  118940. */
  118941. event: ClipboardEvent);
  118942. /**
  118943. * Get the clipboard event's type from the keycode.
  118944. * @param keyCode Defines the keyCode for the current keyboard event.
  118945. * @return {number}
  118946. */
  118947. static GetTypeFromCharacter(keyCode: number): number;
  118948. }
  118949. }
  118950. declare module BABYLON {
  118951. /**
  118952. * Google Daydream controller
  118953. */
  118954. export class DaydreamController extends WebVRController {
  118955. /**
  118956. * Base Url for the controller model.
  118957. */
  118958. static MODEL_BASE_URL: string;
  118959. /**
  118960. * File name for the controller model.
  118961. */
  118962. static MODEL_FILENAME: string;
  118963. /**
  118964. * Gamepad Id prefix used to identify Daydream Controller.
  118965. */
  118966. static readonly GAMEPAD_ID_PREFIX: string;
  118967. /**
  118968. * Creates a new DaydreamController from a gamepad
  118969. * @param vrGamepad the gamepad that the controller should be created from
  118970. */
  118971. constructor(vrGamepad: any);
  118972. /**
  118973. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  118974. * @param scene scene in which to add meshes
  118975. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  118976. */
  118977. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  118978. /**
  118979. * Called once for each button that changed state since the last frame
  118980. * @param buttonIdx Which button index changed
  118981. * @param state New state of the button
  118982. * @param changes Which properties on the state changed since last frame
  118983. */
  118984. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  118985. }
  118986. }
  118987. declare module BABYLON {
  118988. /**
  118989. * Gear VR Controller
  118990. */
  118991. export class GearVRController extends WebVRController {
  118992. /**
  118993. * Base Url for the controller model.
  118994. */
  118995. static MODEL_BASE_URL: string;
  118996. /**
  118997. * File name for the controller model.
  118998. */
  118999. static MODEL_FILENAME: string;
  119000. /**
  119001. * Gamepad Id prefix used to identify this controller.
  119002. */
  119003. static readonly GAMEPAD_ID_PREFIX: string;
  119004. private readonly _buttonIndexToObservableNameMap;
  119005. /**
  119006. * Creates a new GearVRController from a gamepad
  119007. * @param vrGamepad the gamepad that the controller should be created from
  119008. */
  119009. constructor(vrGamepad: any);
  119010. /**
  119011. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  119012. * @param scene scene in which to add meshes
  119013. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  119014. */
  119015. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  119016. /**
  119017. * Called once for each button that changed state since the last frame
  119018. * @param buttonIdx Which button index changed
  119019. * @param state New state of the button
  119020. * @param changes Which properties on the state changed since last frame
  119021. */
  119022. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  119023. }
  119024. }
  119025. declare module BABYLON {
  119026. /**
  119027. * Generic Controller
  119028. */
  119029. export class GenericController extends WebVRController {
  119030. /**
  119031. * Base Url for the controller model.
  119032. */
  119033. static readonly MODEL_BASE_URL: string;
  119034. /**
  119035. * File name for the controller model.
  119036. */
  119037. static readonly MODEL_FILENAME: string;
  119038. /**
  119039. * Creates a new GenericController from a gamepad
  119040. * @param vrGamepad the gamepad that the controller should be created from
  119041. */
  119042. constructor(vrGamepad: any);
  119043. /**
  119044. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  119045. * @param scene scene in which to add meshes
  119046. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  119047. */
  119048. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  119049. /**
  119050. * Called once for each button that changed state since the last frame
  119051. * @param buttonIdx Which button index changed
  119052. * @param state New state of the button
  119053. * @param changes Which properties on the state changed since last frame
  119054. */
  119055. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  119056. }
  119057. }
  119058. declare module BABYLON {
  119059. /**
  119060. * Oculus Touch Controller
  119061. */
  119062. export class OculusTouchController extends WebVRController {
  119063. /**
  119064. * Base Url for the controller model.
  119065. */
  119066. static MODEL_BASE_URL: string;
  119067. /**
  119068. * File name for the left controller model.
  119069. */
  119070. static MODEL_LEFT_FILENAME: string;
  119071. /**
  119072. * File name for the right controller model.
  119073. */
  119074. static MODEL_RIGHT_FILENAME: string;
  119075. /**
  119076. * Base Url for the Quest controller model.
  119077. */
  119078. static QUEST_MODEL_BASE_URL: string;
  119079. /**
  119080. * @hidden
  119081. * If the controllers are running on a device that needs the updated Quest controller models
  119082. */
  119083. static _IsQuest: boolean;
  119084. /**
  119085. * Fired when the secondary trigger on this controller is modified
  119086. */
  119087. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  119088. /**
  119089. * Fired when the thumb rest on this controller is modified
  119090. */
  119091. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  119092. /**
  119093. * Creates a new OculusTouchController from a gamepad
  119094. * @param vrGamepad the gamepad that the controller should be created from
  119095. */
  119096. constructor(vrGamepad: any);
  119097. /**
  119098. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  119099. * @param scene scene in which to add meshes
  119100. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  119101. */
  119102. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  119103. /**
  119104. * Fired when the A button on this controller is modified
  119105. */
  119106. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119107. /**
  119108. * Fired when the B button on this controller is modified
  119109. */
  119110. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119111. /**
  119112. * Fired when the X button on this controller is modified
  119113. */
  119114. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119115. /**
  119116. * Fired when the Y button on this controller is modified
  119117. */
  119118. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119119. /**
  119120. * Called once for each button that changed state since the last frame
  119121. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  119122. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  119123. * 2) secondary trigger (same)
  119124. * 3) A (right) X (left), touch, pressed = value
  119125. * 4) B / Y
  119126. * 5) thumb rest
  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. * Vive Controller
  119137. */
  119138. export class ViveController extends WebVRController {
  119139. /**
  119140. * Base Url for the controller model.
  119141. */
  119142. static MODEL_BASE_URL: string;
  119143. /**
  119144. * File name for the controller model.
  119145. */
  119146. static MODEL_FILENAME: string;
  119147. /**
  119148. * Creates a new ViveController from a gamepad
  119149. * @param vrGamepad the gamepad that the controller should be created from
  119150. */
  119151. constructor(vrGamepad: any);
  119152. /**
  119153. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  119154. * @param scene scene in which to add meshes
  119155. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  119156. */
  119157. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  119158. /**
  119159. * Fired when the left button on this controller is modified
  119160. */
  119161. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119162. /**
  119163. * Fired when the right button on this controller is modified
  119164. */
  119165. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119166. /**
  119167. * Fired when the menu button on this controller is modified
  119168. */
  119169. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119170. /**
  119171. * Called once for each button that changed state since the last frame
  119172. * Vive mapping:
  119173. * 0: touchpad
  119174. * 1: trigger
  119175. * 2: left AND right buttons
  119176. * 3: menu button
  119177. * @param buttonIdx Which button index changed
  119178. * @param state New state of the button
  119179. * @param changes Which properties on the state changed since last frame
  119180. */
  119181. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  119182. }
  119183. }
  119184. declare module BABYLON {
  119185. /**
  119186. * Defines the WindowsMotionController object that the state of the windows motion controller
  119187. */
  119188. export class WindowsMotionController extends WebVRController {
  119189. /**
  119190. * The base url used to load the left and right controller models
  119191. */
  119192. static MODEL_BASE_URL: string;
  119193. /**
  119194. * The name of the left controller model file
  119195. */
  119196. static MODEL_LEFT_FILENAME: string;
  119197. /**
  119198. * The name of the right controller model file
  119199. */
  119200. static MODEL_RIGHT_FILENAME: string;
  119201. /**
  119202. * The controller name prefix for this controller type
  119203. */
  119204. static readonly GAMEPAD_ID_PREFIX: string;
  119205. /**
  119206. * The controller id pattern for this controller type
  119207. */
  119208. private static readonly GAMEPAD_ID_PATTERN;
  119209. private _loadedMeshInfo;
  119210. protected readonly _mapping: {
  119211. buttons: string[];
  119212. buttonMeshNames: {
  119213. 'trigger': string;
  119214. 'menu': string;
  119215. 'grip': string;
  119216. 'thumbstick': string;
  119217. 'trackpad': string;
  119218. };
  119219. buttonObservableNames: {
  119220. 'trigger': string;
  119221. 'menu': string;
  119222. 'grip': string;
  119223. 'thumbstick': string;
  119224. 'trackpad': string;
  119225. };
  119226. axisMeshNames: string[];
  119227. pointingPoseMeshName: string;
  119228. };
  119229. /**
  119230. * Fired when the trackpad on this controller is clicked
  119231. */
  119232. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  119233. /**
  119234. * Fired when the trackpad on this controller is modified
  119235. */
  119236. onTrackpadValuesChangedObservable: Observable<StickValues>;
  119237. /**
  119238. * The current x and y values of this controller's trackpad
  119239. */
  119240. trackpad: StickValues;
  119241. /**
  119242. * Creates a new WindowsMotionController from a gamepad
  119243. * @param vrGamepad the gamepad that the controller should be created from
  119244. */
  119245. constructor(vrGamepad: any);
  119246. /**
  119247. * Fired when the trigger on this controller is modified
  119248. */
  119249. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119250. /**
  119251. * Fired when the menu button on this controller is modified
  119252. */
  119253. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119254. /**
  119255. * Fired when the grip button on this controller is modified
  119256. */
  119257. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119258. /**
  119259. * Fired when the thumbstick button on this controller is modified
  119260. */
  119261. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119262. /**
  119263. * Fired when the touchpad button on this controller is modified
  119264. */
  119265. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119266. /**
  119267. * Fired when the touchpad values on this controller are modified
  119268. */
  119269. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  119270. protected _updateTrackpad(): void;
  119271. /**
  119272. * Called once per frame by the engine.
  119273. */
  119274. update(): void;
  119275. /**
  119276. * Called once for each button that changed state since the last frame
  119277. * @param buttonIdx Which button index changed
  119278. * @param state New state of the button
  119279. * @param changes Which properties on the state changed since last frame
  119280. */
  119281. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  119282. /**
  119283. * Moves the buttons on the controller mesh based on their current state
  119284. * @param buttonName the name of the button to move
  119285. * @param buttonValue the value of the button which determines the buttons new position
  119286. */
  119287. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  119288. /**
  119289. * Moves the axis on the controller mesh based on its current state
  119290. * @param axis the index of the axis
  119291. * @param axisValue the value of the axis which determines the meshes new position
  119292. * @hidden
  119293. */
  119294. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  119295. /**
  119296. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  119297. * @param scene scene in which to add meshes
  119298. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  119299. */
  119300. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  119301. /**
  119302. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  119303. * can be transformed by button presses and axes values, based on this._mapping.
  119304. *
  119305. * @param scene scene in which the meshes exist
  119306. * @param meshes list of meshes that make up the controller model to process
  119307. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  119308. */
  119309. private processModel;
  119310. private createMeshInfo;
  119311. /**
  119312. * Gets the ray of the controller in the direction the controller is pointing
  119313. * @param length the length the resulting ray should be
  119314. * @returns a ray in the direction the controller is pointing
  119315. */
  119316. getForwardRay(length?: number): Ray;
  119317. /**
  119318. * Disposes of the controller
  119319. */
  119320. dispose(): void;
  119321. }
  119322. /**
  119323. * This class represents a new windows motion controller in XR.
  119324. */
  119325. export class XRWindowsMotionController extends WindowsMotionController {
  119326. /**
  119327. * Changing the original WIndowsMotionController mapping to fir the new mapping
  119328. */
  119329. protected readonly _mapping: {
  119330. buttons: string[];
  119331. buttonMeshNames: {
  119332. 'trigger': string;
  119333. 'menu': string;
  119334. 'grip': string;
  119335. 'thumbstick': string;
  119336. 'trackpad': string;
  119337. };
  119338. buttonObservableNames: {
  119339. 'trigger': string;
  119340. 'menu': string;
  119341. 'grip': string;
  119342. 'thumbstick': string;
  119343. 'trackpad': string;
  119344. };
  119345. axisMeshNames: string[];
  119346. pointingPoseMeshName: string;
  119347. };
  119348. /**
  119349. * Construct a new XR-Based windows motion controller
  119350. *
  119351. * @param gamepadInfo the gamepad object from the browser
  119352. */
  119353. constructor(gamepadInfo: any);
  119354. /**
  119355. * holds the thumbstick values (X,Y)
  119356. */
  119357. thumbstickValues: StickValues;
  119358. /**
  119359. * Fired when the thumbstick on this controller is clicked
  119360. */
  119361. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  119362. /**
  119363. * Fired when the thumbstick on this controller is modified
  119364. */
  119365. onThumbstickValuesChangedObservable: Observable<StickValues>;
  119366. /**
  119367. * Fired when the touchpad button on this controller is modified
  119368. */
  119369. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  119370. /**
  119371. * Fired when the touchpad values on this controller are modified
  119372. */
  119373. onTrackpadValuesChangedObservable: Observable<StickValues>;
  119374. /**
  119375. * Fired when the thumbstick button on this controller is modified
  119376. * here to prevent breaking changes
  119377. */
  119378. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119379. /**
  119380. * updating the thumbstick(!) and not the trackpad.
  119381. * This is named this way due to the difference between WebVR and XR and to avoid
  119382. * changing the parent class.
  119383. */
  119384. protected _updateTrackpad(): void;
  119385. /**
  119386. * Disposes the class with joy
  119387. */
  119388. dispose(): void;
  119389. }
  119390. }
  119391. declare module BABYLON {
  119392. /**
  119393. * Class containing static functions to help procedurally build meshes
  119394. */
  119395. export class PolyhedronBuilder {
  119396. /**
  119397. * Creates a polyhedron mesh
  119398. * * 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
  119399. * * The parameter `size` (positive float, default 1) sets the polygon size
  119400. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  119401. * * 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`
  119402. * * 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
  119403. * * 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)`)
  119404. * * 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
  119405. * * 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
  119406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119409. * @param name defines the name of the mesh
  119410. * @param options defines the options used to create the mesh
  119411. * @param scene defines the hosting scene
  119412. * @returns the polyhedron mesh
  119413. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  119414. */
  119415. static CreatePolyhedron(name: string, options: {
  119416. type?: number;
  119417. size?: number;
  119418. sizeX?: number;
  119419. sizeY?: number;
  119420. sizeZ?: number;
  119421. custom?: any;
  119422. faceUV?: Vector4[];
  119423. faceColors?: Color4[];
  119424. flat?: boolean;
  119425. updatable?: boolean;
  119426. sideOrientation?: number;
  119427. frontUVs?: Vector4;
  119428. backUVs?: Vector4;
  119429. }, scene?: Nullable<Scene>): Mesh;
  119430. }
  119431. }
  119432. declare module BABYLON {
  119433. /**
  119434. * Gizmo that enables scaling a mesh along 3 axis
  119435. */
  119436. export class ScaleGizmo extends Gizmo {
  119437. /**
  119438. * Internal gizmo used for interactions on the x axis
  119439. */
  119440. xGizmo: AxisScaleGizmo;
  119441. /**
  119442. * Internal gizmo used for interactions on the y axis
  119443. */
  119444. yGizmo: AxisScaleGizmo;
  119445. /**
  119446. * Internal gizmo used for interactions on the z axis
  119447. */
  119448. zGizmo: AxisScaleGizmo;
  119449. /**
  119450. * Internal gizmo used to scale all axis equally
  119451. */
  119452. uniformScaleGizmo: AxisScaleGizmo;
  119453. private _meshAttached;
  119454. private _updateGizmoRotationToMatchAttachedMesh;
  119455. private _snapDistance;
  119456. private _scaleRatio;
  119457. private _uniformScalingMesh;
  119458. private _octahedron;
  119459. private _sensitivity;
  119460. /** Fires an event when any of it's sub gizmos are dragged */
  119461. onDragStartObservable: Observable<unknown>;
  119462. /** Fires an event when any of it's sub gizmos are released from dragging */
  119463. onDragEndObservable: Observable<unknown>;
  119464. get attachedMesh(): Nullable<AbstractMesh>;
  119465. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119466. /**
  119467. * Creates a ScaleGizmo
  119468. * @param gizmoLayer The utility layer the gizmo will be added to
  119469. */
  119470. constructor(gizmoLayer?: UtilityLayerRenderer);
  119471. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119472. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119473. /**
  119474. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119475. */
  119476. set snapDistance(value: number);
  119477. get snapDistance(): number;
  119478. /**
  119479. * Ratio for the scale of the gizmo (Default: 1)
  119480. */
  119481. set scaleRatio(value: number);
  119482. get scaleRatio(): number;
  119483. /**
  119484. * Sensitivity factor for dragging (Default: 1)
  119485. */
  119486. set sensitivity(value: number);
  119487. get sensitivity(): number;
  119488. /**
  119489. * Disposes of the gizmo
  119490. */
  119491. dispose(): void;
  119492. }
  119493. }
  119494. declare module BABYLON {
  119495. /**
  119496. * Single axis scale gizmo
  119497. */
  119498. export class AxisScaleGizmo extends Gizmo {
  119499. /**
  119500. * Drag behavior responsible for the gizmos dragging interactions
  119501. */
  119502. dragBehavior: PointerDragBehavior;
  119503. private _pointerObserver;
  119504. /**
  119505. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119506. */
  119507. snapDistance: number;
  119508. /**
  119509. * Event that fires each time the gizmo snaps to a new location.
  119510. * * snapDistance is the the change in distance
  119511. */
  119512. onSnapObservable: Observable<{
  119513. snapDistance: number;
  119514. }>;
  119515. /**
  119516. * If the scaling operation should be done on all axis (default: false)
  119517. */
  119518. uniformScaling: boolean;
  119519. /**
  119520. * Custom sensitivity value for the drag strength
  119521. */
  119522. sensitivity: number;
  119523. private _isEnabled;
  119524. private _parent;
  119525. private _arrow;
  119526. private _coloredMaterial;
  119527. private _hoverMaterial;
  119528. /**
  119529. * Creates an AxisScaleGizmo
  119530. * @param gizmoLayer The utility layer the gizmo will be added to
  119531. * @param dragAxis The axis which the gizmo will be able to scale on
  119532. * @param color The color of the gizmo
  119533. */
  119534. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  119535. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119536. /**
  119537. * If the gizmo is enabled
  119538. */
  119539. set isEnabled(value: boolean);
  119540. get isEnabled(): boolean;
  119541. /**
  119542. * Disposes of the gizmo
  119543. */
  119544. dispose(): void;
  119545. /**
  119546. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119547. * @param mesh The mesh to replace the default mesh of the gizmo
  119548. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  119549. */
  119550. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  119551. }
  119552. }
  119553. declare module BABYLON {
  119554. /**
  119555. * Bounding box gizmo
  119556. */
  119557. export class BoundingBoxGizmo extends Gizmo {
  119558. private _lineBoundingBox;
  119559. private _rotateSpheresParent;
  119560. private _scaleBoxesParent;
  119561. private _boundingDimensions;
  119562. private _renderObserver;
  119563. private _pointerObserver;
  119564. private _scaleDragSpeed;
  119565. private _tmpQuaternion;
  119566. private _tmpVector;
  119567. private _tmpRotationMatrix;
  119568. /**
  119569. * 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)
  119570. */
  119571. ignoreChildren: boolean;
  119572. /**
  119573. * 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)
  119574. */
  119575. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  119576. /**
  119577. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  119578. */
  119579. rotationSphereSize: number;
  119580. /**
  119581. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  119582. */
  119583. scaleBoxSize: number;
  119584. /**
  119585. * 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)
  119586. */
  119587. fixedDragMeshScreenSize: boolean;
  119588. /**
  119589. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  119590. */
  119591. fixedDragMeshScreenSizeDistanceFactor: number;
  119592. /**
  119593. * Fired when a rotation sphere or scale box is dragged
  119594. */
  119595. onDragStartObservable: Observable<{}>;
  119596. /**
  119597. * Fired when a scale box is dragged
  119598. */
  119599. onScaleBoxDragObservable: Observable<{}>;
  119600. /**
  119601. * Fired when a scale box drag is ended
  119602. */
  119603. onScaleBoxDragEndObservable: Observable<{}>;
  119604. /**
  119605. * Fired when a rotation sphere is dragged
  119606. */
  119607. onRotationSphereDragObservable: Observable<{}>;
  119608. /**
  119609. * Fired when a rotation sphere drag is ended
  119610. */
  119611. onRotationSphereDragEndObservable: Observable<{}>;
  119612. /**
  119613. * 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)
  119614. */
  119615. scalePivot: Nullable<Vector3>;
  119616. /**
  119617. * Mesh used as a pivot to rotate the attached mesh
  119618. */
  119619. private _anchorMesh;
  119620. private _existingMeshScale;
  119621. private _dragMesh;
  119622. private pointerDragBehavior;
  119623. private coloredMaterial;
  119624. private hoverColoredMaterial;
  119625. /**
  119626. * Sets the color of the bounding box gizmo
  119627. * @param color the color to set
  119628. */
  119629. setColor(color: Color3): void;
  119630. /**
  119631. * Creates an BoundingBoxGizmo
  119632. * @param gizmoLayer The utility layer the gizmo will be added to
  119633. * @param color The color of the gizmo
  119634. */
  119635. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  119636. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119637. private _selectNode;
  119638. /**
  119639. * Updates the bounding box information for the Gizmo
  119640. */
  119641. updateBoundingBox(): void;
  119642. private _updateRotationSpheres;
  119643. private _updateScaleBoxes;
  119644. /**
  119645. * Enables rotation on the specified axis and disables rotation on the others
  119646. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  119647. */
  119648. setEnabledRotationAxis(axis: string): void;
  119649. /**
  119650. * Enables/disables scaling
  119651. * @param enable if scaling should be enabled
  119652. */
  119653. setEnabledScaling(enable: boolean): void;
  119654. private _updateDummy;
  119655. /**
  119656. * Enables a pointer drag behavior on the bounding box of the gizmo
  119657. */
  119658. enableDragBehavior(): void;
  119659. /**
  119660. * Disposes of the gizmo
  119661. */
  119662. dispose(): void;
  119663. /**
  119664. * 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)
  119665. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  119666. * @returns the bounding box mesh with the passed in mesh as a child
  119667. */
  119668. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  119669. /**
  119670. * CustomMeshes are not supported by this gizmo
  119671. * @param mesh The mesh to replace the default mesh of the gizmo
  119672. */
  119673. setCustomMesh(mesh: Mesh): void;
  119674. }
  119675. }
  119676. declare module BABYLON {
  119677. /**
  119678. * Single plane rotation gizmo
  119679. */
  119680. export class PlaneRotationGizmo extends Gizmo {
  119681. /**
  119682. * Drag behavior responsible for the gizmos dragging interactions
  119683. */
  119684. dragBehavior: PointerDragBehavior;
  119685. private _pointerObserver;
  119686. /**
  119687. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  119688. */
  119689. snapDistance: number;
  119690. /**
  119691. * Event that fires each time the gizmo snaps to a new location.
  119692. * * snapDistance is the the change in distance
  119693. */
  119694. onSnapObservable: Observable<{
  119695. snapDistance: number;
  119696. }>;
  119697. private _isEnabled;
  119698. private _parent;
  119699. /**
  119700. * Creates a PlaneRotationGizmo
  119701. * @param gizmoLayer The utility layer the gizmo will be added to
  119702. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  119703. * @param color The color of the gizmo
  119704. * @param tessellation Amount of tessellation to be used when creating rotation circles
  119705. * @param useEulerRotation Use and update Euler angle instead of quaternion
  119706. */
  119707. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  119708. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119709. /**
  119710. * If the gizmo is enabled
  119711. */
  119712. set isEnabled(value: boolean);
  119713. get isEnabled(): boolean;
  119714. /**
  119715. * Disposes of the gizmo
  119716. */
  119717. dispose(): void;
  119718. }
  119719. }
  119720. declare module BABYLON {
  119721. /**
  119722. * Gizmo that enables rotating a mesh along 3 axis
  119723. */
  119724. export class RotationGizmo extends Gizmo {
  119725. /**
  119726. * Internal gizmo used for interactions on the x axis
  119727. */
  119728. xGizmo: PlaneRotationGizmo;
  119729. /**
  119730. * Internal gizmo used for interactions on the y axis
  119731. */
  119732. yGizmo: PlaneRotationGizmo;
  119733. /**
  119734. * Internal gizmo used for interactions on the z axis
  119735. */
  119736. zGizmo: PlaneRotationGizmo;
  119737. /** Fires an event when any of it's sub gizmos are dragged */
  119738. onDragStartObservable: Observable<unknown>;
  119739. /** Fires an event when any of it's sub gizmos are released from dragging */
  119740. onDragEndObservable: Observable<unknown>;
  119741. private _meshAttached;
  119742. get attachedMesh(): Nullable<AbstractMesh>;
  119743. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119744. /**
  119745. * Creates a RotationGizmo
  119746. * @param gizmoLayer The utility layer the gizmo will be added to
  119747. * @param tessellation Amount of tessellation to be used when creating rotation circles
  119748. * @param useEulerRotation Use and update Euler angle instead of quaternion
  119749. */
  119750. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  119751. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119752. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119753. /**
  119754. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119755. */
  119756. set snapDistance(value: number);
  119757. get snapDistance(): number;
  119758. /**
  119759. * Ratio for the scale of the gizmo (Default: 1)
  119760. */
  119761. set scaleRatio(value: number);
  119762. get scaleRatio(): number;
  119763. /**
  119764. * Disposes of the gizmo
  119765. */
  119766. dispose(): void;
  119767. /**
  119768. * CustomMeshes are not supported by this gizmo
  119769. * @param mesh The mesh to replace the default mesh of the gizmo
  119770. */
  119771. setCustomMesh(mesh: Mesh): void;
  119772. }
  119773. }
  119774. declare module BABYLON {
  119775. /**
  119776. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  119777. */
  119778. export class GizmoManager implements IDisposable {
  119779. private scene;
  119780. /**
  119781. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  119782. */
  119783. gizmos: {
  119784. positionGizmo: Nullable<PositionGizmo>;
  119785. rotationGizmo: Nullable<RotationGizmo>;
  119786. scaleGizmo: Nullable<ScaleGizmo>;
  119787. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  119788. };
  119789. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  119790. clearGizmoOnEmptyPointerEvent: boolean;
  119791. /** Fires an event when the manager is attached to a mesh */
  119792. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  119793. private _gizmosEnabled;
  119794. private _pointerObserver;
  119795. private _attachedMesh;
  119796. private _boundingBoxColor;
  119797. private _defaultUtilityLayer;
  119798. private _defaultKeepDepthUtilityLayer;
  119799. /**
  119800. * When bounding box gizmo is enabled, this can be used to track drag/end events
  119801. */
  119802. boundingBoxDragBehavior: SixDofDragBehavior;
  119803. /**
  119804. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  119805. */
  119806. attachableMeshes: Nullable<Array<AbstractMesh>>;
  119807. /**
  119808. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  119809. */
  119810. usePointerToAttachGizmos: boolean;
  119811. /**
  119812. * Utility layer that the bounding box gizmo belongs to
  119813. */
  119814. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  119815. /**
  119816. * Utility layer that all gizmos besides bounding box belong to
  119817. */
  119818. get utilityLayer(): UtilityLayerRenderer;
  119819. /**
  119820. * Instatiates a gizmo manager
  119821. * @param scene the scene to overlay the gizmos on top of
  119822. */
  119823. constructor(scene: Scene);
  119824. /**
  119825. * Attaches a set of gizmos to the specified mesh
  119826. * @param mesh The mesh the gizmo's should be attached to
  119827. */
  119828. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  119829. /**
  119830. * If the position gizmo is enabled
  119831. */
  119832. set positionGizmoEnabled(value: boolean);
  119833. get positionGizmoEnabled(): boolean;
  119834. /**
  119835. * If the rotation gizmo is enabled
  119836. */
  119837. set rotationGizmoEnabled(value: boolean);
  119838. get rotationGizmoEnabled(): boolean;
  119839. /**
  119840. * If the scale gizmo is enabled
  119841. */
  119842. set scaleGizmoEnabled(value: boolean);
  119843. get scaleGizmoEnabled(): boolean;
  119844. /**
  119845. * If the boundingBox gizmo is enabled
  119846. */
  119847. set boundingBoxGizmoEnabled(value: boolean);
  119848. get boundingBoxGizmoEnabled(): boolean;
  119849. /**
  119850. * Disposes of the gizmo manager
  119851. */
  119852. dispose(): void;
  119853. }
  119854. }
  119855. declare module BABYLON {
  119856. /**
  119857. * A directional light is defined by a direction (what a surprise!).
  119858. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  119859. * 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.
  119860. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119861. */
  119862. export class DirectionalLight extends ShadowLight {
  119863. private _shadowFrustumSize;
  119864. /**
  119865. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  119866. */
  119867. get shadowFrustumSize(): number;
  119868. /**
  119869. * Specifies a fix frustum size for the shadow generation.
  119870. */
  119871. set shadowFrustumSize(value: number);
  119872. private _shadowOrthoScale;
  119873. /**
  119874. * Gets the shadow projection scale against the optimal computed one.
  119875. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  119876. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  119877. */
  119878. get shadowOrthoScale(): number;
  119879. /**
  119880. * Sets the shadow projection scale against the optimal computed one.
  119881. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  119882. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  119883. */
  119884. set shadowOrthoScale(value: number);
  119885. /**
  119886. * Automatically compute the projection matrix to best fit (including all the casters)
  119887. * on each frame.
  119888. */
  119889. autoUpdateExtends: boolean;
  119890. /**
  119891. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  119892. * on each frame. autoUpdateExtends must be set to true for this to work
  119893. */
  119894. autoCalcShadowZBounds: boolean;
  119895. private _orthoLeft;
  119896. private _orthoRight;
  119897. private _orthoTop;
  119898. private _orthoBottom;
  119899. /**
  119900. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  119901. * The directional light is emitted from everywhere in the given direction.
  119902. * It can cast shadows.
  119903. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119904. * @param name The friendly name of the light
  119905. * @param direction The direction of the light
  119906. * @param scene The scene the light belongs to
  119907. */
  119908. constructor(name: string, direction: Vector3, scene: Scene);
  119909. /**
  119910. * Returns the string "DirectionalLight".
  119911. * @return The class name
  119912. */
  119913. getClassName(): string;
  119914. /**
  119915. * Returns the integer 1.
  119916. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119917. */
  119918. getTypeID(): number;
  119919. /**
  119920. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  119921. * Returns the DirectionalLight Shadow projection matrix.
  119922. */
  119923. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119924. /**
  119925. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  119926. * Returns the DirectionalLight Shadow projection matrix.
  119927. */
  119928. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  119929. /**
  119930. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  119931. * Returns the DirectionalLight Shadow projection matrix.
  119932. */
  119933. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119934. protected _buildUniformLayout(): void;
  119935. /**
  119936. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  119937. * @param effect The effect to update
  119938. * @param lightIndex The index of the light in the effect to update
  119939. * @returns The directional light
  119940. */
  119941. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  119942. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  119943. /**
  119944. * Gets the minZ used for shadow according to both the scene and the light.
  119945. *
  119946. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  119947. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  119948. * @param activeCamera The camera we are returning the min for
  119949. * @returns the depth min z
  119950. */
  119951. getDepthMinZ(activeCamera: Camera): number;
  119952. /**
  119953. * Gets the maxZ used for shadow according to both the scene and the light.
  119954. *
  119955. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  119956. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  119957. * @param activeCamera The camera we are returning the max for
  119958. * @returns the depth max z
  119959. */
  119960. getDepthMaxZ(activeCamera: Camera): number;
  119961. /**
  119962. * Prepares the list of defines specific to the light type.
  119963. * @param defines the list of defines
  119964. * @param lightIndex defines the index of the light for the effect
  119965. */
  119966. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119967. }
  119968. }
  119969. declare module BABYLON {
  119970. /**
  119971. * Class containing static functions to help procedurally build meshes
  119972. */
  119973. export class HemisphereBuilder {
  119974. /**
  119975. * Creates a hemisphere mesh
  119976. * @param name defines the name of the mesh
  119977. * @param options defines the options used to create the mesh
  119978. * @param scene defines the hosting scene
  119979. * @returns the hemisphere mesh
  119980. */
  119981. static CreateHemisphere(name: string, options: {
  119982. segments?: number;
  119983. diameter?: number;
  119984. sideOrientation?: number;
  119985. }, scene: any): Mesh;
  119986. }
  119987. }
  119988. declare module BABYLON {
  119989. /**
  119990. * A spot light is defined by a position, a direction, an angle, and an exponent.
  119991. * These values define a cone of light starting from the position, emitting toward the direction.
  119992. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  119993. * and the exponent defines the speed of the decay of the light with distance (reach).
  119994. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119995. */
  119996. export class SpotLight extends ShadowLight {
  119997. private _angle;
  119998. private _innerAngle;
  119999. private _cosHalfAngle;
  120000. private _lightAngleScale;
  120001. private _lightAngleOffset;
  120002. /**
  120003. * Gets the cone angle of the spot light in Radians.
  120004. */
  120005. get angle(): number;
  120006. /**
  120007. * Sets the cone angle of the spot light in Radians.
  120008. */
  120009. set angle(value: number);
  120010. /**
  120011. * Only used in gltf falloff mode, this defines the angle where
  120012. * the directional falloff will start before cutting at angle which could be seen
  120013. * as outer angle.
  120014. */
  120015. get innerAngle(): number;
  120016. /**
  120017. * Only used in gltf falloff mode, this defines the angle where
  120018. * the directional falloff will start before cutting at angle which could be seen
  120019. * as outer angle.
  120020. */
  120021. set innerAngle(value: number);
  120022. private _shadowAngleScale;
  120023. /**
  120024. * Allows scaling the angle of the light for shadow generation only.
  120025. */
  120026. get shadowAngleScale(): number;
  120027. /**
  120028. * Allows scaling the angle of the light for shadow generation only.
  120029. */
  120030. set shadowAngleScale(value: number);
  120031. /**
  120032. * The light decay speed with the distance from the emission spot.
  120033. */
  120034. exponent: number;
  120035. private _projectionTextureMatrix;
  120036. /**
  120037. * Allows reading the projecton texture
  120038. */
  120039. get projectionTextureMatrix(): Matrix;
  120040. protected _projectionTextureLightNear: number;
  120041. /**
  120042. * Gets the near clip of the Spotlight for texture projection.
  120043. */
  120044. get projectionTextureLightNear(): number;
  120045. /**
  120046. * Sets the near clip of the Spotlight for texture projection.
  120047. */
  120048. set projectionTextureLightNear(value: number);
  120049. protected _projectionTextureLightFar: number;
  120050. /**
  120051. * Gets the far clip of the Spotlight for texture projection.
  120052. */
  120053. get projectionTextureLightFar(): number;
  120054. /**
  120055. * Sets the far clip of the Spotlight for texture projection.
  120056. */
  120057. set projectionTextureLightFar(value: number);
  120058. protected _projectionTextureUpDirection: Vector3;
  120059. /**
  120060. * Gets the Up vector of the Spotlight for texture projection.
  120061. */
  120062. get projectionTextureUpDirection(): Vector3;
  120063. /**
  120064. * Sets the Up vector of the Spotlight for texture projection.
  120065. */
  120066. set projectionTextureUpDirection(value: Vector3);
  120067. private _projectionTexture;
  120068. /**
  120069. * Gets the projection texture of the light.
  120070. */
  120071. get projectionTexture(): Nullable<BaseTexture>;
  120072. /**
  120073. * Sets the projection texture of the light.
  120074. */
  120075. set projectionTexture(value: Nullable<BaseTexture>);
  120076. private _projectionTextureViewLightDirty;
  120077. private _projectionTextureProjectionLightDirty;
  120078. private _projectionTextureDirty;
  120079. private _projectionTextureViewTargetVector;
  120080. private _projectionTextureViewLightMatrix;
  120081. private _projectionTextureProjectionLightMatrix;
  120082. private _projectionTextureScalingMatrix;
  120083. /**
  120084. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  120085. * It can cast shadows.
  120086. * Documentation : https://doc.babylonjs.com/babylon101/lights
  120087. * @param name The light friendly name
  120088. * @param position The position of the spot light in the scene
  120089. * @param direction The direction of the light in the scene
  120090. * @param angle The cone angle of the light in Radians
  120091. * @param exponent The light decay speed with the distance from the emission spot
  120092. * @param scene The scene the lights belongs to
  120093. */
  120094. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  120095. /**
  120096. * Returns the string "SpotLight".
  120097. * @returns the class name
  120098. */
  120099. getClassName(): string;
  120100. /**
  120101. * Returns the integer 2.
  120102. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  120103. */
  120104. getTypeID(): number;
  120105. /**
  120106. * Overrides the direction setter to recompute the projection texture view light Matrix.
  120107. */
  120108. protected _setDirection(value: Vector3): void;
  120109. /**
  120110. * Overrides the position setter to recompute the projection texture view light Matrix.
  120111. */
  120112. protected _setPosition(value: Vector3): void;
  120113. /**
  120114. * 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.
  120115. * Returns the SpotLight.
  120116. */
  120117. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  120118. protected _computeProjectionTextureViewLightMatrix(): void;
  120119. protected _computeProjectionTextureProjectionLightMatrix(): void;
  120120. /**
  120121. * Main function for light texture projection matrix computing.
  120122. */
  120123. protected _computeProjectionTextureMatrix(): void;
  120124. protected _buildUniformLayout(): void;
  120125. private _computeAngleValues;
  120126. /**
  120127. * Sets the passed Effect "effect" with the Light textures.
  120128. * @param effect The effect to update
  120129. * @param lightIndex The index of the light in the effect to update
  120130. * @returns The light
  120131. */
  120132. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  120133. /**
  120134. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  120135. * @param effect The effect to update
  120136. * @param lightIndex The index of the light in the effect to update
  120137. * @returns The spot light
  120138. */
  120139. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  120140. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  120141. /**
  120142. * Disposes the light and the associated resources.
  120143. */
  120144. dispose(): void;
  120145. /**
  120146. * Prepares the list of defines specific to the light type.
  120147. * @param defines the list of defines
  120148. * @param lightIndex defines the index of the light for the effect
  120149. */
  120150. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  120151. }
  120152. }
  120153. declare module BABYLON {
  120154. /**
  120155. * Gizmo that enables viewing a light
  120156. */
  120157. export class LightGizmo extends Gizmo {
  120158. private _lightMesh;
  120159. private _material;
  120160. private _cachedPosition;
  120161. private _cachedForward;
  120162. private _attachedMeshParent;
  120163. /**
  120164. * Creates a LightGizmo
  120165. * @param gizmoLayer The utility layer the gizmo will be added to
  120166. */
  120167. constructor(gizmoLayer?: UtilityLayerRenderer);
  120168. private _light;
  120169. /**
  120170. * The light that the gizmo is attached to
  120171. */
  120172. set light(light: Nullable<Light>);
  120173. get light(): Nullable<Light>;
  120174. /**
  120175. * Gets the material used to render the light gizmo
  120176. */
  120177. get material(): StandardMaterial;
  120178. /**
  120179. * @hidden
  120180. * Updates the gizmo to match the attached mesh's position/rotation
  120181. */
  120182. protected _update(): void;
  120183. private static _Scale;
  120184. /**
  120185. * Creates the lines for a light mesh
  120186. */
  120187. private static _CreateLightLines;
  120188. /**
  120189. * Disposes of the light gizmo
  120190. */
  120191. dispose(): void;
  120192. private static _CreateHemisphericLightMesh;
  120193. private static _CreatePointLightMesh;
  120194. private static _CreateSpotLightMesh;
  120195. private static _CreateDirectionalLightMesh;
  120196. }
  120197. }
  120198. declare module BABYLON {
  120199. /** @hidden */
  120200. export var backgroundFragmentDeclaration: {
  120201. name: string;
  120202. shader: string;
  120203. };
  120204. }
  120205. declare module BABYLON {
  120206. /** @hidden */
  120207. export var backgroundUboDeclaration: {
  120208. name: string;
  120209. shader: string;
  120210. };
  120211. }
  120212. declare module BABYLON {
  120213. /** @hidden */
  120214. export var backgroundPixelShader: {
  120215. name: string;
  120216. shader: string;
  120217. };
  120218. }
  120219. declare module BABYLON {
  120220. /** @hidden */
  120221. export var backgroundVertexDeclaration: {
  120222. name: string;
  120223. shader: string;
  120224. };
  120225. }
  120226. declare module BABYLON {
  120227. /** @hidden */
  120228. export var backgroundVertexShader: {
  120229. name: string;
  120230. shader: string;
  120231. };
  120232. }
  120233. declare module BABYLON {
  120234. /**
  120235. * Background material used to create an efficient environement around your scene.
  120236. */
  120237. export class BackgroundMaterial extends PushMaterial {
  120238. /**
  120239. * Standard reflectance value at parallel view angle.
  120240. */
  120241. static StandardReflectance0: number;
  120242. /**
  120243. * Standard reflectance value at grazing angle.
  120244. */
  120245. static StandardReflectance90: number;
  120246. protected _primaryColor: Color3;
  120247. /**
  120248. * Key light Color (multiply against the environement texture)
  120249. */
  120250. primaryColor: Color3;
  120251. protected __perceptualColor: Nullable<Color3>;
  120252. /**
  120253. * Experimental Internal Use Only.
  120254. *
  120255. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  120256. * This acts as a helper to set the primary color to a more "human friendly" value.
  120257. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  120258. * output color as close as possible from the chosen value.
  120259. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  120260. * part of lighting setup.)
  120261. */
  120262. get _perceptualColor(): Nullable<Color3>;
  120263. set _perceptualColor(value: Nullable<Color3>);
  120264. protected _primaryColorShadowLevel: float;
  120265. /**
  120266. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  120267. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  120268. */
  120269. get primaryColorShadowLevel(): float;
  120270. set primaryColorShadowLevel(value: float);
  120271. protected _primaryColorHighlightLevel: float;
  120272. /**
  120273. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  120274. * The primary color is used at the level chosen to define what the white area would look.
  120275. */
  120276. get primaryColorHighlightLevel(): float;
  120277. set primaryColorHighlightLevel(value: float);
  120278. protected _reflectionTexture: Nullable<BaseTexture>;
  120279. /**
  120280. * Reflection Texture used in the material.
  120281. * Should be author in a specific way for the best result (refer to the documentation).
  120282. */
  120283. reflectionTexture: Nullable<BaseTexture>;
  120284. protected _reflectionBlur: float;
  120285. /**
  120286. * Reflection Texture level of blur.
  120287. *
  120288. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  120289. * texture twice.
  120290. */
  120291. reflectionBlur: float;
  120292. protected _diffuseTexture: Nullable<BaseTexture>;
  120293. /**
  120294. * Diffuse Texture used in the material.
  120295. * Should be author in a specific way for the best result (refer to the documentation).
  120296. */
  120297. diffuseTexture: Nullable<BaseTexture>;
  120298. protected _shadowLights: Nullable<IShadowLight[]>;
  120299. /**
  120300. * Specify the list of lights casting shadow on the material.
  120301. * All scene shadow lights will be included if null.
  120302. */
  120303. shadowLights: Nullable<IShadowLight[]>;
  120304. protected _shadowLevel: float;
  120305. /**
  120306. * Helps adjusting the shadow to a softer level if required.
  120307. * 0 means black shadows and 1 means no shadows.
  120308. */
  120309. shadowLevel: float;
  120310. protected _sceneCenter: Vector3;
  120311. /**
  120312. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  120313. * It is usually zero but might be interesting to modify according to your setup.
  120314. */
  120315. sceneCenter: Vector3;
  120316. protected _opacityFresnel: boolean;
  120317. /**
  120318. * This helps specifying that the material is falling off to the sky box at grazing angle.
  120319. * This helps ensuring a nice transition when the camera goes under the ground.
  120320. */
  120321. opacityFresnel: boolean;
  120322. protected _reflectionFresnel: boolean;
  120323. /**
  120324. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  120325. * This helps adding a mirror texture on the ground.
  120326. */
  120327. reflectionFresnel: boolean;
  120328. protected _reflectionFalloffDistance: number;
  120329. /**
  120330. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  120331. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  120332. */
  120333. reflectionFalloffDistance: number;
  120334. protected _reflectionAmount: number;
  120335. /**
  120336. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  120337. */
  120338. reflectionAmount: number;
  120339. protected _reflectionReflectance0: number;
  120340. /**
  120341. * This specifies the weight of the reflection at grazing angle.
  120342. */
  120343. reflectionReflectance0: number;
  120344. protected _reflectionReflectance90: number;
  120345. /**
  120346. * This specifies the weight of the reflection at a perpendicular point of view.
  120347. */
  120348. reflectionReflectance90: number;
  120349. /**
  120350. * Sets the reflection reflectance fresnel values according to the default standard
  120351. * empirically know to work well :-)
  120352. */
  120353. set reflectionStandardFresnelWeight(value: number);
  120354. protected _useRGBColor: boolean;
  120355. /**
  120356. * Helps to directly use the maps channels instead of their level.
  120357. */
  120358. useRGBColor: boolean;
  120359. protected _enableNoise: boolean;
  120360. /**
  120361. * This helps reducing the banding effect that could occur on the background.
  120362. */
  120363. enableNoise: boolean;
  120364. /**
  120365. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  120366. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  120367. * Recommended to be keep at 1.0 except for special cases.
  120368. */
  120369. get fovMultiplier(): number;
  120370. set fovMultiplier(value: number);
  120371. private _fovMultiplier;
  120372. /**
  120373. * Enable the FOV adjustment feature controlled by fovMultiplier.
  120374. */
  120375. useEquirectangularFOV: boolean;
  120376. private _maxSimultaneousLights;
  120377. /**
  120378. * Number of Simultaneous lights allowed on the material.
  120379. */
  120380. maxSimultaneousLights: int;
  120381. /**
  120382. * Default configuration related to image processing available in the Background Material.
  120383. */
  120384. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120385. /**
  120386. * Keep track of the image processing observer to allow dispose and replace.
  120387. */
  120388. private _imageProcessingObserver;
  120389. /**
  120390. * Attaches a new image processing configuration to the PBR Material.
  120391. * @param configuration (if null the scene configuration will be use)
  120392. */
  120393. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120394. /**
  120395. * Gets the image processing configuration used either in this material.
  120396. */
  120397. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  120398. /**
  120399. * Sets the Default image processing configuration used either in the this material.
  120400. *
  120401. * If sets to null, the scene one is in use.
  120402. */
  120403. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  120404. /**
  120405. * Gets wether the color curves effect is enabled.
  120406. */
  120407. get cameraColorCurvesEnabled(): boolean;
  120408. /**
  120409. * Sets wether the color curves effect is enabled.
  120410. */
  120411. set cameraColorCurvesEnabled(value: boolean);
  120412. /**
  120413. * Gets wether the color grading effect is enabled.
  120414. */
  120415. get cameraColorGradingEnabled(): boolean;
  120416. /**
  120417. * Gets wether the color grading effect is enabled.
  120418. */
  120419. set cameraColorGradingEnabled(value: boolean);
  120420. /**
  120421. * Gets wether tonemapping is enabled or not.
  120422. */
  120423. get cameraToneMappingEnabled(): boolean;
  120424. /**
  120425. * Sets wether tonemapping is enabled or not
  120426. */
  120427. set cameraToneMappingEnabled(value: boolean);
  120428. /**
  120429. * The camera exposure used on this material.
  120430. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  120431. * This corresponds to a photographic exposure.
  120432. */
  120433. get cameraExposure(): float;
  120434. /**
  120435. * The camera exposure used on this material.
  120436. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  120437. * This corresponds to a photographic exposure.
  120438. */
  120439. set cameraExposure(value: float);
  120440. /**
  120441. * Gets The camera contrast used on this material.
  120442. */
  120443. get cameraContrast(): float;
  120444. /**
  120445. * Sets The camera contrast used on this material.
  120446. */
  120447. set cameraContrast(value: float);
  120448. /**
  120449. * Gets the Color Grading 2D Lookup Texture.
  120450. */
  120451. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  120452. /**
  120453. * Sets the Color Grading 2D Lookup Texture.
  120454. */
  120455. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  120456. /**
  120457. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  120458. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  120459. * 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;
  120460. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  120461. */
  120462. get cameraColorCurves(): Nullable<ColorCurves>;
  120463. /**
  120464. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  120465. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  120466. * 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;
  120467. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  120468. */
  120469. set cameraColorCurves(value: Nullable<ColorCurves>);
  120470. /**
  120471. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  120472. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  120473. */
  120474. switchToBGR: boolean;
  120475. private _renderTargets;
  120476. private _reflectionControls;
  120477. private _white;
  120478. private _primaryShadowColor;
  120479. private _primaryHighlightColor;
  120480. /**
  120481. * Instantiates a Background Material in the given scene
  120482. * @param name The friendly name of the material
  120483. * @param scene The scene to add the material to
  120484. */
  120485. constructor(name: string, scene: Scene);
  120486. /**
  120487. * Gets a boolean indicating that current material needs to register RTT
  120488. */
  120489. get hasRenderTargetTextures(): boolean;
  120490. /**
  120491. * The entire material has been created in order to prevent overdraw.
  120492. * @returns false
  120493. */
  120494. needAlphaTesting(): boolean;
  120495. /**
  120496. * The entire material has been created in order to prevent overdraw.
  120497. * @returns true if blending is enable
  120498. */
  120499. needAlphaBlending(): boolean;
  120500. /**
  120501. * Checks wether the material is ready to be rendered for a given mesh.
  120502. * @param mesh The mesh to render
  120503. * @param subMesh The submesh to check against
  120504. * @param useInstances Specify wether or not the material is used with instances
  120505. * @returns true if all the dependencies are ready (Textures, Effects...)
  120506. */
  120507. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120508. /**
  120509. * Compute the primary color according to the chosen perceptual color.
  120510. */
  120511. private _computePrimaryColorFromPerceptualColor;
  120512. /**
  120513. * Compute the highlights and shadow colors according to their chosen levels.
  120514. */
  120515. private _computePrimaryColors;
  120516. /**
  120517. * Build the uniform buffer used in the material.
  120518. */
  120519. buildUniformLayout(): void;
  120520. /**
  120521. * Unbind the material.
  120522. */
  120523. unbind(): void;
  120524. /**
  120525. * Bind only the world matrix to the material.
  120526. * @param world The world matrix to bind.
  120527. */
  120528. bindOnlyWorldMatrix(world: Matrix): void;
  120529. /**
  120530. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  120531. * @param world The world matrix to bind.
  120532. * @param subMesh The submesh to bind for.
  120533. */
  120534. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120535. /**
  120536. * Checks to see if a texture is used in the material.
  120537. * @param texture - Base texture to use.
  120538. * @returns - Boolean specifying if a texture is used in the material.
  120539. */
  120540. hasTexture(texture: BaseTexture): boolean;
  120541. /**
  120542. * Dispose the material.
  120543. * @param forceDisposeEffect Force disposal of the associated effect.
  120544. * @param forceDisposeTextures Force disposal of the associated textures.
  120545. */
  120546. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  120547. /**
  120548. * Clones the material.
  120549. * @param name The cloned name.
  120550. * @returns The cloned material.
  120551. */
  120552. clone(name: string): BackgroundMaterial;
  120553. /**
  120554. * Serializes the current material to its JSON representation.
  120555. * @returns The JSON representation.
  120556. */
  120557. serialize(): any;
  120558. /**
  120559. * Gets the class name of the material
  120560. * @returns "BackgroundMaterial"
  120561. */
  120562. getClassName(): string;
  120563. /**
  120564. * Parse a JSON input to create back a background material.
  120565. * @param source The JSON data to parse
  120566. * @param scene The scene to create the parsed material in
  120567. * @param rootUrl The root url of the assets the material depends upon
  120568. * @returns the instantiated BackgroundMaterial.
  120569. */
  120570. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  120571. }
  120572. }
  120573. declare module BABYLON {
  120574. /**
  120575. * Represents the different options available during the creation of
  120576. * a Environment helper.
  120577. *
  120578. * This can control the default ground, skybox and image processing setup of your scene.
  120579. */
  120580. export interface IEnvironmentHelperOptions {
  120581. /**
  120582. * Specifies wether or not to create a ground.
  120583. * True by default.
  120584. */
  120585. createGround: boolean;
  120586. /**
  120587. * Specifies the ground size.
  120588. * 15 by default.
  120589. */
  120590. groundSize: number;
  120591. /**
  120592. * The texture used on the ground for the main color.
  120593. * Comes from the BabylonJS CDN by default.
  120594. *
  120595. * Remarks: Can be either a texture or a url.
  120596. */
  120597. groundTexture: string | BaseTexture;
  120598. /**
  120599. * The color mixed in the ground texture by default.
  120600. * BabylonJS clearColor by default.
  120601. */
  120602. groundColor: Color3;
  120603. /**
  120604. * Specifies the ground opacity.
  120605. * 1 by default.
  120606. */
  120607. groundOpacity: number;
  120608. /**
  120609. * Enables the ground to receive shadows.
  120610. * True by default.
  120611. */
  120612. enableGroundShadow: boolean;
  120613. /**
  120614. * Helps preventing the shadow to be fully black on the ground.
  120615. * 0.5 by default.
  120616. */
  120617. groundShadowLevel: number;
  120618. /**
  120619. * Creates a mirror texture attach to the ground.
  120620. * false by default.
  120621. */
  120622. enableGroundMirror: boolean;
  120623. /**
  120624. * Specifies the ground mirror size ratio.
  120625. * 0.3 by default as the default kernel is 64.
  120626. */
  120627. groundMirrorSizeRatio: number;
  120628. /**
  120629. * Specifies the ground mirror blur kernel size.
  120630. * 64 by default.
  120631. */
  120632. groundMirrorBlurKernel: number;
  120633. /**
  120634. * Specifies the ground mirror visibility amount.
  120635. * 1 by default
  120636. */
  120637. groundMirrorAmount: number;
  120638. /**
  120639. * Specifies the ground mirror reflectance weight.
  120640. * This uses the standard weight of the background material to setup the fresnel effect
  120641. * of the mirror.
  120642. * 1 by default.
  120643. */
  120644. groundMirrorFresnelWeight: number;
  120645. /**
  120646. * Specifies the ground mirror Falloff distance.
  120647. * This can helps reducing the size of the reflection.
  120648. * 0 by Default.
  120649. */
  120650. groundMirrorFallOffDistance: number;
  120651. /**
  120652. * Specifies the ground mirror texture type.
  120653. * Unsigned Int by Default.
  120654. */
  120655. groundMirrorTextureType: number;
  120656. /**
  120657. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  120658. * the shown objects.
  120659. */
  120660. groundYBias: number;
  120661. /**
  120662. * Specifies wether or not to create a skybox.
  120663. * True by default.
  120664. */
  120665. createSkybox: boolean;
  120666. /**
  120667. * Specifies the skybox size.
  120668. * 20 by default.
  120669. */
  120670. skyboxSize: number;
  120671. /**
  120672. * The texture used on the skybox for the main color.
  120673. * Comes from the BabylonJS CDN by default.
  120674. *
  120675. * Remarks: Can be either a texture or a url.
  120676. */
  120677. skyboxTexture: string | BaseTexture;
  120678. /**
  120679. * The color mixed in the skybox texture by default.
  120680. * BabylonJS clearColor by default.
  120681. */
  120682. skyboxColor: Color3;
  120683. /**
  120684. * The background rotation around the Y axis of the scene.
  120685. * This helps aligning the key lights of your scene with the background.
  120686. * 0 by default.
  120687. */
  120688. backgroundYRotation: number;
  120689. /**
  120690. * Compute automatically the size of the elements to best fit with the scene.
  120691. */
  120692. sizeAuto: boolean;
  120693. /**
  120694. * Default position of the rootMesh if autoSize is not true.
  120695. */
  120696. rootPosition: Vector3;
  120697. /**
  120698. * Sets up the image processing in the scene.
  120699. * true by default.
  120700. */
  120701. setupImageProcessing: boolean;
  120702. /**
  120703. * The texture used as your environment texture in the scene.
  120704. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  120705. *
  120706. * Remarks: Can be either a texture or a url.
  120707. */
  120708. environmentTexture: string | BaseTexture;
  120709. /**
  120710. * The value of the exposure to apply to the scene.
  120711. * 0.6 by default if setupImageProcessing is true.
  120712. */
  120713. cameraExposure: number;
  120714. /**
  120715. * The value of the contrast to apply to the scene.
  120716. * 1.6 by default if setupImageProcessing is true.
  120717. */
  120718. cameraContrast: number;
  120719. /**
  120720. * Specifies wether or not tonemapping should be enabled in the scene.
  120721. * true by default if setupImageProcessing is true.
  120722. */
  120723. toneMappingEnabled: boolean;
  120724. }
  120725. /**
  120726. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  120727. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  120728. * It also helps with the default setup of your imageProcessing configuration.
  120729. */
  120730. export class EnvironmentHelper {
  120731. /**
  120732. * Default ground texture URL.
  120733. */
  120734. private static _groundTextureCDNUrl;
  120735. /**
  120736. * Default skybox texture URL.
  120737. */
  120738. private static _skyboxTextureCDNUrl;
  120739. /**
  120740. * Default environment texture URL.
  120741. */
  120742. private static _environmentTextureCDNUrl;
  120743. /**
  120744. * Creates the default options for the helper.
  120745. */
  120746. private static _getDefaultOptions;
  120747. private _rootMesh;
  120748. /**
  120749. * Gets the root mesh created by the helper.
  120750. */
  120751. get rootMesh(): Mesh;
  120752. private _skybox;
  120753. /**
  120754. * Gets the skybox created by the helper.
  120755. */
  120756. get skybox(): Nullable<Mesh>;
  120757. private _skyboxTexture;
  120758. /**
  120759. * Gets the skybox texture created by the helper.
  120760. */
  120761. get skyboxTexture(): Nullable<BaseTexture>;
  120762. private _skyboxMaterial;
  120763. /**
  120764. * Gets the skybox material created by the helper.
  120765. */
  120766. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  120767. private _ground;
  120768. /**
  120769. * Gets the ground mesh created by the helper.
  120770. */
  120771. get ground(): Nullable<Mesh>;
  120772. private _groundTexture;
  120773. /**
  120774. * Gets the ground texture created by the helper.
  120775. */
  120776. get groundTexture(): Nullable<BaseTexture>;
  120777. private _groundMirror;
  120778. /**
  120779. * Gets the ground mirror created by the helper.
  120780. */
  120781. get groundMirror(): Nullable<MirrorTexture>;
  120782. /**
  120783. * Gets the ground mirror render list to helps pushing the meshes
  120784. * you wish in the ground reflection.
  120785. */
  120786. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  120787. private _groundMaterial;
  120788. /**
  120789. * Gets the ground material created by the helper.
  120790. */
  120791. get groundMaterial(): Nullable<BackgroundMaterial>;
  120792. /**
  120793. * Stores the creation options.
  120794. */
  120795. private readonly _scene;
  120796. private _options;
  120797. /**
  120798. * This observable will be notified with any error during the creation of the environment,
  120799. * mainly texture creation errors.
  120800. */
  120801. onErrorObservable: Observable<{
  120802. message?: string;
  120803. exception?: any;
  120804. }>;
  120805. /**
  120806. * constructor
  120807. * @param options Defines the options we want to customize the helper
  120808. * @param scene The scene to add the material to
  120809. */
  120810. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  120811. /**
  120812. * Updates the background according to the new options
  120813. * @param options
  120814. */
  120815. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  120816. /**
  120817. * Sets the primary color of all the available elements.
  120818. * @param color the main color to affect to the ground and the background
  120819. */
  120820. setMainColor(color: Color3): void;
  120821. /**
  120822. * Setup the image processing according to the specified options.
  120823. */
  120824. private _setupImageProcessing;
  120825. /**
  120826. * Setup the environment texture according to the specified options.
  120827. */
  120828. private _setupEnvironmentTexture;
  120829. /**
  120830. * Setup the background according to the specified options.
  120831. */
  120832. private _setupBackground;
  120833. /**
  120834. * Get the scene sizes according to the setup.
  120835. */
  120836. private _getSceneSize;
  120837. /**
  120838. * Setup the ground according to the specified options.
  120839. */
  120840. private _setupGround;
  120841. /**
  120842. * Setup the ground material according to the specified options.
  120843. */
  120844. private _setupGroundMaterial;
  120845. /**
  120846. * Setup the ground diffuse texture according to the specified options.
  120847. */
  120848. private _setupGroundDiffuseTexture;
  120849. /**
  120850. * Setup the ground mirror texture according to the specified options.
  120851. */
  120852. private _setupGroundMirrorTexture;
  120853. /**
  120854. * Setup the ground to receive the mirror texture.
  120855. */
  120856. private _setupMirrorInGroundMaterial;
  120857. /**
  120858. * Setup the skybox according to the specified options.
  120859. */
  120860. private _setupSkybox;
  120861. /**
  120862. * Setup the skybox material according to the specified options.
  120863. */
  120864. private _setupSkyboxMaterial;
  120865. /**
  120866. * Setup the skybox reflection texture according to the specified options.
  120867. */
  120868. private _setupSkyboxReflectionTexture;
  120869. private _errorHandler;
  120870. /**
  120871. * Dispose all the elements created by the Helper.
  120872. */
  120873. dispose(): void;
  120874. }
  120875. }
  120876. declare module BABYLON {
  120877. /**
  120878. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  120879. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  120880. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  120881. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  120882. */
  120883. export class PhotoDome extends TransformNode {
  120884. /**
  120885. * Define the image as a Monoscopic panoramic 360 image.
  120886. */
  120887. static readonly MODE_MONOSCOPIC: number;
  120888. /**
  120889. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  120890. */
  120891. static readonly MODE_TOPBOTTOM: number;
  120892. /**
  120893. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  120894. */
  120895. static readonly MODE_SIDEBYSIDE: number;
  120896. private _useDirectMapping;
  120897. /**
  120898. * The texture being displayed on the sphere
  120899. */
  120900. protected _photoTexture: Texture;
  120901. /**
  120902. * Gets or sets the texture being displayed on the sphere
  120903. */
  120904. get photoTexture(): Texture;
  120905. set photoTexture(value: Texture);
  120906. /**
  120907. * Observable raised when an error occured while loading the 360 image
  120908. */
  120909. onLoadErrorObservable: Observable<string>;
  120910. /**
  120911. * The skybox material
  120912. */
  120913. protected _material: BackgroundMaterial;
  120914. /**
  120915. * The surface used for the skybox
  120916. */
  120917. protected _mesh: Mesh;
  120918. /**
  120919. * Gets the mesh used for the skybox.
  120920. */
  120921. get mesh(): Mesh;
  120922. /**
  120923. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  120924. * Also see the options.resolution property.
  120925. */
  120926. get fovMultiplier(): number;
  120927. set fovMultiplier(value: number);
  120928. private _imageMode;
  120929. /**
  120930. * Gets or set the current video mode for the video. It can be:
  120931. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  120932. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  120933. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  120934. */
  120935. get imageMode(): number;
  120936. set imageMode(value: number);
  120937. /**
  120938. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  120939. * @param name Element's name, child elements will append suffixes for their own names.
  120940. * @param urlsOfPhoto defines the url of the photo to display
  120941. * @param options defines an object containing optional or exposed sub element properties
  120942. * @param onError defines a callback called when an error occured while loading the texture
  120943. */
  120944. constructor(name: string, urlOfPhoto: string, options: {
  120945. resolution?: number;
  120946. size?: number;
  120947. useDirectMapping?: boolean;
  120948. faceForward?: boolean;
  120949. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  120950. private _onBeforeCameraRenderObserver;
  120951. private _changeImageMode;
  120952. /**
  120953. * Releases resources associated with this node.
  120954. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  120955. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  120956. */
  120957. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  120958. }
  120959. }
  120960. declare module BABYLON {
  120961. /**
  120962. * Class used to host RGBD texture specific utilities
  120963. */
  120964. export class RGBDTextureTools {
  120965. /**
  120966. * Expand the RGBD Texture from RGBD to Half Float if possible.
  120967. * @param texture the texture to expand.
  120968. */
  120969. static ExpandRGBDTexture(texture: Texture): void;
  120970. }
  120971. }
  120972. declare module BABYLON {
  120973. /**
  120974. * Class used to host texture specific utilities
  120975. */
  120976. export class BRDFTextureTools {
  120977. /**
  120978. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  120979. * @param scene defines the hosting scene
  120980. * @returns the environment BRDF texture
  120981. */
  120982. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  120983. private static _environmentBRDFBase64Texture;
  120984. }
  120985. }
  120986. declare module BABYLON {
  120987. /**
  120988. * @hidden
  120989. */
  120990. export interface IMaterialClearCoatDefines {
  120991. CLEARCOAT: boolean;
  120992. CLEARCOAT_DEFAULTIOR: boolean;
  120993. CLEARCOAT_TEXTURE: boolean;
  120994. CLEARCOAT_TEXTUREDIRECTUV: number;
  120995. CLEARCOAT_BUMP: boolean;
  120996. CLEARCOAT_BUMPDIRECTUV: number;
  120997. CLEARCOAT_TINT: boolean;
  120998. CLEARCOAT_TINT_TEXTURE: boolean;
  120999. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  121000. /** @hidden */
  121001. _areTexturesDirty: boolean;
  121002. }
  121003. /**
  121004. * Define the code related to the clear coat parameters of the pbr material.
  121005. */
  121006. export class PBRClearCoatConfiguration {
  121007. /**
  121008. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  121009. * The default fits with a polyurethane material.
  121010. */
  121011. private static readonly _DefaultIndexOfRefraction;
  121012. private _isEnabled;
  121013. /**
  121014. * Defines if the clear coat is enabled in the material.
  121015. */
  121016. isEnabled: boolean;
  121017. /**
  121018. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  121019. */
  121020. intensity: number;
  121021. /**
  121022. * Defines the clear coat layer roughness.
  121023. */
  121024. roughness: number;
  121025. private _indexOfRefraction;
  121026. /**
  121027. * Defines the index of refraction of the clear coat.
  121028. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  121029. * The default fits with a polyurethane material.
  121030. * Changing the default value is more performance intensive.
  121031. */
  121032. indexOfRefraction: number;
  121033. private _texture;
  121034. /**
  121035. * Stores the clear coat values in a texture.
  121036. */
  121037. texture: Nullable<BaseTexture>;
  121038. private _bumpTexture;
  121039. /**
  121040. * Define the clear coat specific bump texture.
  121041. */
  121042. bumpTexture: Nullable<BaseTexture>;
  121043. private _isTintEnabled;
  121044. /**
  121045. * Defines if the clear coat tint is enabled in the material.
  121046. */
  121047. isTintEnabled: boolean;
  121048. /**
  121049. * Defines the clear coat tint of the material.
  121050. * This is only use if tint is enabled
  121051. */
  121052. tintColor: Color3;
  121053. /**
  121054. * Defines the distance at which the tint color should be found in the
  121055. * clear coat media.
  121056. * This is only use if tint is enabled
  121057. */
  121058. tintColorAtDistance: number;
  121059. /**
  121060. * Defines the clear coat layer thickness.
  121061. * This is only use if tint is enabled
  121062. */
  121063. tintThickness: number;
  121064. private _tintTexture;
  121065. /**
  121066. * Stores the clear tint values in a texture.
  121067. * rgb is tint
  121068. * a is a thickness factor
  121069. */
  121070. tintTexture: Nullable<BaseTexture>;
  121071. /** @hidden */
  121072. private _internalMarkAllSubMeshesAsTexturesDirty;
  121073. /** @hidden */
  121074. _markAllSubMeshesAsTexturesDirty(): void;
  121075. /**
  121076. * Instantiate a new istance of clear coat configuration.
  121077. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  121078. */
  121079. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  121080. /**
  121081. * Gets wehter the submesh is ready to be used or not.
  121082. * @param defines the list of "defines" to update.
  121083. * @param scene defines the scene the material belongs to.
  121084. * @param engine defines the engine the material belongs to.
  121085. * @param disableBumpMap defines wether the material disables bump or not.
  121086. * @returns - boolean indicating that the submesh is ready or not.
  121087. */
  121088. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  121089. /**
  121090. * Checks to see if a texture is used in the material.
  121091. * @param defines the list of "defines" to update.
  121092. * @param scene defines the scene to the material belongs to.
  121093. */
  121094. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  121095. /**
  121096. * Binds the material data.
  121097. * @param uniformBuffer defines the Uniform buffer to fill in.
  121098. * @param scene defines the scene the material belongs to.
  121099. * @param engine defines the engine the material belongs to.
  121100. * @param disableBumpMap defines wether the material disables bump or not.
  121101. * @param isFrozen defines wether the material is frozen or not.
  121102. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  121103. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  121104. */
  121105. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  121106. /**
  121107. * Checks to see if a texture is used in the material.
  121108. * @param texture - Base texture to use.
  121109. * @returns - Boolean specifying if a texture is used in the material.
  121110. */
  121111. hasTexture(texture: BaseTexture): boolean;
  121112. /**
  121113. * Returns an array of the actively used textures.
  121114. * @param activeTextures Array of BaseTextures
  121115. */
  121116. getActiveTextures(activeTextures: BaseTexture[]): void;
  121117. /**
  121118. * Returns the animatable textures.
  121119. * @param animatables Array of animatable textures.
  121120. */
  121121. getAnimatables(animatables: IAnimatable[]): void;
  121122. /**
  121123. * Disposes the resources of the material.
  121124. * @param forceDisposeTextures - Forces the disposal of all textures.
  121125. */
  121126. dispose(forceDisposeTextures?: boolean): void;
  121127. /**
  121128. * Get the current class name of the texture useful for serialization or dynamic coding.
  121129. * @returns "PBRClearCoatConfiguration"
  121130. */
  121131. getClassName(): string;
  121132. /**
  121133. * Add fallbacks to the effect fallbacks list.
  121134. * @param defines defines the Base texture to use.
  121135. * @param fallbacks defines the current fallback list.
  121136. * @param currentRank defines the current fallback rank.
  121137. * @returns the new fallback rank.
  121138. */
  121139. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  121140. /**
  121141. * Add the required uniforms to the current list.
  121142. * @param uniforms defines the current uniform list.
  121143. */
  121144. static AddUniforms(uniforms: string[]): void;
  121145. /**
  121146. * Add the required samplers to the current list.
  121147. * @param samplers defines the current sampler list.
  121148. */
  121149. static AddSamplers(samplers: string[]): void;
  121150. /**
  121151. * Add the required uniforms to the current buffer.
  121152. * @param uniformBuffer defines the current uniform buffer.
  121153. */
  121154. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  121155. /**
  121156. * Makes a duplicate of the current configuration into another one.
  121157. * @param clearCoatConfiguration define the config where to copy the info
  121158. */
  121159. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  121160. /**
  121161. * Serializes this clear coat configuration.
  121162. * @returns - An object with the serialized config.
  121163. */
  121164. serialize(): any;
  121165. /**
  121166. * Parses a anisotropy Configuration from a serialized object.
  121167. * @param source - Serialized object.
  121168. * @param scene Defines the scene we are parsing for
  121169. * @param rootUrl Defines the rootUrl to load from
  121170. */
  121171. parse(source: any, scene: Scene, rootUrl: string): void;
  121172. }
  121173. }
  121174. declare module BABYLON {
  121175. /**
  121176. * @hidden
  121177. */
  121178. export interface IMaterialAnisotropicDefines {
  121179. ANISOTROPIC: boolean;
  121180. ANISOTROPIC_TEXTURE: boolean;
  121181. ANISOTROPIC_TEXTUREDIRECTUV: number;
  121182. MAINUV1: boolean;
  121183. _areTexturesDirty: boolean;
  121184. _needUVs: boolean;
  121185. }
  121186. /**
  121187. * Define the code related to the anisotropic parameters of the pbr material.
  121188. */
  121189. export class PBRAnisotropicConfiguration {
  121190. private _isEnabled;
  121191. /**
  121192. * Defines if the anisotropy is enabled in the material.
  121193. */
  121194. isEnabled: boolean;
  121195. /**
  121196. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  121197. */
  121198. intensity: number;
  121199. /**
  121200. * Defines if the effect is along the tangents, bitangents or in between.
  121201. * By default, the effect is "strectching" the highlights along the tangents.
  121202. */
  121203. direction: Vector2;
  121204. private _texture;
  121205. /**
  121206. * Stores the anisotropy values in a texture.
  121207. * rg is direction (like normal from -1 to 1)
  121208. * b is a intensity
  121209. */
  121210. texture: Nullable<BaseTexture>;
  121211. /** @hidden */
  121212. private _internalMarkAllSubMeshesAsTexturesDirty;
  121213. /** @hidden */
  121214. _markAllSubMeshesAsTexturesDirty(): void;
  121215. /**
  121216. * Instantiate a new istance of anisotropy configuration.
  121217. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  121218. */
  121219. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  121220. /**
  121221. * Specifies that the submesh is ready to be used.
  121222. * @param defines the list of "defines" to update.
  121223. * @param scene defines the scene the material belongs to.
  121224. * @returns - boolean indicating that the submesh is ready or not.
  121225. */
  121226. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  121227. /**
  121228. * Checks to see if a texture is used in the material.
  121229. * @param defines the list of "defines" to update.
  121230. * @param mesh the mesh we are preparing the defines for.
  121231. * @param scene defines the scene the material belongs to.
  121232. */
  121233. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  121234. /**
  121235. * Binds the material data.
  121236. * @param uniformBuffer defines the Uniform buffer to fill in.
  121237. * @param scene defines the scene the material belongs to.
  121238. * @param isFrozen defines wether the material is frozen or not.
  121239. */
  121240. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  121241. /**
  121242. * Checks to see if a texture is used in the material.
  121243. * @param texture - Base texture to use.
  121244. * @returns - Boolean specifying if a texture is used in the material.
  121245. */
  121246. hasTexture(texture: BaseTexture): boolean;
  121247. /**
  121248. * Returns an array of the actively used textures.
  121249. * @param activeTextures Array of BaseTextures
  121250. */
  121251. getActiveTextures(activeTextures: BaseTexture[]): void;
  121252. /**
  121253. * Returns the animatable textures.
  121254. * @param animatables Array of animatable textures.
  121255. */
  121256. getAnimatables(animatables: IAnimatable[]): void;
  121257. /**
  121258. * Disposes the resources of the material.
  121259. * @param forceDisposeTextures - Forces the disposal of all textures.
  121260. */
  121261. dispose(forceDisposeTextures?: boolean): void;
  121262. /**
  121263. * Get the current class name of the texture useful for serialization or dynamic coding.
  121264. * @returns "PBRAnisotropicConfiguration"
  121265. */
  121266. getClassName(): string;
  121267. /**
  121268. * Add fallbacks to the effect fallbacks list.
  121269. * @param defines defines the Base texture to use.
  121270. * @param fallbacks defines the current fallback list.
  121271. * @param currentRank defines the current fallback rank.
  121272. * @returns the new fallback rank.
  121273. */
  121274. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  121275. /**
  121276. * Add the required uniforms to the current list.
  121277. * @param uniforms defines the current uniform list.
  121278. */
  121279. static AddUniforms(uniforms: string[]): void;
  121280. /**
  121281. * Add the required uniforms to the current buffer.
  121282. * @param uniformBuffer defines the current uniform buffer.
  121283. */
  121284. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  121285. /**
  121286. * Add the required samplers to the current list.
  121287. * @param samplers defines the current sampler list.
  121288. */
  121289. static AddSamplers(samplers: string[]): void;
  121290. /**
  121291. * Makes a duplicate of the current configuration into another one.
  121292. * @param anisotropicConfiguration define the config where to copy the info
  121293. */
  121294. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  121295. /**
  121296. * Serializes this anisotropy configuration.
  121297. * @returns - An object with the serialized config.
  121298. */
  121299. serialize(): any;
  121300. /**
  121301. * Parses a anisotropy Configuration from a serialized object.
  121302. * @param source - Serialized object.
  121303. * @param scene Defines the scene we are parsing for
  121304. * @param rootUrl Defines the rootUrl to load from
  121305. */
  121306. parse(source: any, scene: Scene, rootUrl: string): void;
  121307. }
  121308. }
  121309. declare module BABYLON {
  121310. /**
  121311. * @hidden
  121312. */
  121313. export interface IMaterialBRDFDefines {
  121314. BRDF_V_HEIGHT_CORRELATED: boolean;
  121315. MS_BRDF_ENERGY_CONSERVATION: boolean;
  121316. SPHERICAL_HARMONICS: boolean;
  121317. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  121318. /** @hidden */
  121319. _areMiscDirty: boolean;
  121320. }
  121321. /**
  121322. * Define the code related to the BRDF parameters of the pbr material.
  121323. */
  121324. export class PBRBRDFConfiguration {
  121325. /**
  121326. * Default value used for the energy conservation.
  121327. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  121328. */
  121329. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  121330. /**
  121331. * Default value used for the Smith Visibility Height Correlated mode.
  121332. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  121333. */
  121334. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  121335. /**
  121336. * Default value used for the IBL diffuse part.
  121337. * This can help switching back to the polynomials mode globally which is a tiny bit
  121338. * less GPU intensive at the drawback of a lower quality.
  121339. */
  121340. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  121341. /**
  121342. * Default value used for activating energy conservation for the specular workflow.
  121343. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  121344. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  121345. */
  121346. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  121347. private _useEnergyConservation;
  121348. /**
  121349. * Defines if the material uses energy conservation.
  121350. */
  121351. useEnergyConservation: boolean;
  121352. private _useSmithVisibilityHeightCorrelated;
  121353. /**
  121354. * LEGACY Mode set to false
  121355. * Defines if the material uses height smith correlated visibility term.
  121356. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  121357. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  121358. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  121359. * Not relying on height correlated will also disable energy conservation.
  121360. */
  121361. useSmithVisibilityHeightCorrelated: boolean;
  121362. private _useSphericalHarmonics;
  121363. /**
  121364. * LEGACY Mode set to false
  121365. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  121366. * diffuse part of the IBL.
  121367. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  121368. * to the ground truth.
  121369. */
  121370. useSphericalHarmonics: boolean;
  121371. private _useSpecularGlossinessInputEnergyConservation;
  121372. /**
  121373. * Defines if the material uses energy conservation, when the specular workflow is active.
  121374. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  121375. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  121376. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  121377. */
  121378. useSpecularGlossinessInputEnergyConservation: boolean;
  121379. /** @hidden */
  121380. private _internalMarkAllSubMeshesAsMiscDirty;
  121381. /** @hidden */
  121382. _markAllSubMeshesAsMiscDirty(): void;
  121383. /**
  121384. * Instantiate a new istance of clear coat configuration.
  121385. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  121386. */
  121387. constructor(markAllSubMeshesAsMiscDirty: () => void);
  121388. /**
  121389. * Checks to see if a texture is used in the material.
  121390. * @param defines the list of "defines" to update.
  121391. */
  121392. prepareDefines(defines: IMaterialBRDFDefines): void;
  121393. /**
  121394. * Get the current class name of the texture useful for serialization or dynamic coding.
  121395. * @returns "PBRClearCoatConfiguration"
  121396. */
  121397. getClassName(): string;
  121398. /**
  121399. * Makes a duplicate of the current configuration into another one.
  121400. * @param brdfConfiguration define the config where to copy the info
  121401. */
  121402. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  121403. /**
  121404. * Serializes this BRDF configuration.
  121405. * @returns - An object with the serialized config.
  121406. */
  121407. serialize(): any;
  121408. /**
  121409. * Parses a anisotropy Configuration from a serialized object.
  121410. * @param source - Serialized object.
  121411. * @param scene Defines the scene we are parsing for
  121412. * @param rootUrl Defines the rootUrl to load from
  121413. */
  121414. parse(source: any, scene: Scene, rootUrl: string): void;
  121415. }
  121416. }
  121417. declare module BABYLON {
  121418. /**
  121419. * @hidden
  121420. */
  121421. export interface IMaterialSheenDefines {
  121422. SHEEN: boolean;
  121423. SHEEN_TEXTURE: boolean;
  121424. SHEEN_TEXTUREDIRECTUV: number;
  121425. SHEEN_LINKWITHALBEDO: boolean;
  121426. /** @hidden */
  121427. _areTexturesDirty: boolean;
  121428. }
  121429. /**
  121430. * Define the code related to the Sheen parameters of the pbr material.
  121431. */
  121432. export class PBRSheenConfiguration {
  121433. private _isEnabled;
  121434. /**
  121435. * Defines if the material uses sheen.
  121436. */
  121437. isEnabled: boolean;
  121438. private _linkSheenWithAlbedo;
  121439. /**
  121440. * Defines if the sheen is linked to the sheen color.
  121441. */
  121442. linkSheenWithAlbedo: boolean;
  121443. /**
  121444. * Defines the sheen intensity.
  121445. */
  121446. intensity: number;
  121447. /**
  121448. * Defines the sheen color.
  121449. */
  121450. color: Color3;
  121451. private _texture;
  121452. /**
  121453. * Stores the sheen tint values in a texture.
  121454. * rgb is tint
  121455. * a is a intensity
  121456. */
  121457. texture: Nullable<BaseTexture>;
  121458. /** @hidden */
  121459. private _internalMarkAllSubMeshesAsTexturesDirty;
  121460. /** @hidden */
  121461. _markAllSubMeshesAsTexturesDirty(): void;
  121462. /**
  121463. * Instantiate a new istance of clear coat configuration.
  121464. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  121465. */
  121466. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  121467. /**
  121468. * Specifies that the submesh is ready to be used.
  121469. * @param defines the list of "defines" to update.
  121470. * @param scene defines the scene the material belongs to.
  121471. * @returns - boolean indicating that the submesh is ready or not.
  121472. */
  121473. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  121474. /**
  121475. * Checks to see if a texture is used in the material.
  121476. * @param defines the list of "defines" to update.
  121477. * @param scene defines the scene the material belongs to.
  121478. */
  121479. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  121480. /**
  121481. * Binds the material data.
  121482. * @param uniformBuffer defines the Uniform buffer to fill in.
  121483. * @param scene defines the scene the material belongs to.
  121484. * @param isFrozen defines wether the material is frozen or not.
  121485. */
  121486. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  121487. /**
  121488. * Checks to see if a texture is used in the material.
  121489. * @param texture - Base texture to use.
  121490. * @returns - Boolean specifying if a texture is used in the material.
  121491. */
  121492. hasTexture(texture: BaseTexture): boolean;
  121493. /**
  121494. * Returns an array of the actively used textures.
  121495. * @param activeTextures Array of BaseTextures
  121496. */
  121497. getActiveTextures(activeTextures: BaseTexture[]): void;
  121498. /**
  121499. * Returns the animatable textures.
  121500. * @param animatables Array of animatable textures.
  121501. */
  121502. getAnimatables(animatables: IAnimatable[]): void;
  121503. /**
  121504. * Disposes the resources of the material.
  121505. * @param forceDisposeTextures - Forces the disposal of all textures.
  121506. */
  121507. dispose(forceDisposeTextures?: boolean): void;
  121508. /**
  121509. * Get the current class name of the texture useful for serialization or dynamic coding.
  121510. * @returns "PBRSheenConfiguration"
  121511. */
  121512. getClassName(): string;
  121513. /**
  121514. * Add fallbacks to the effect fallbacks list.
  121515. * @param defines defines the Base texture to use.
  121516. * @param fallbacks defines the current fallback list.
  121517. * @param currentRank defines the current fallback rank.
  121518. * @returns the new fallback rank.
  121519. */
  121520. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  121521. /**
  121522. * Add the required uniforms to the current list.
  121523. * @param uniforms defines the current uniform list.
  121524. */
  121525. static AddUniforms(uniforms: string[]): void;
  121526. /**
  121527. * Add the required uniforms to the current buffer.
  121528. * @param uniformBuffer defines the current uniform buffer.
  121529. */
  121530. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  121531. /**
  121532. * Add the required samplers to the current list.
  121533. * @param samplers defines the current sampler list.
  121534. */
  121535. static AddSamplers(samplers: string[]): void;
  121536. /**
  121537. * Makes a duplicate of the current configuration into another one.
  121538. * @param sheenConfiguration define the config where to copy the info
  121539. */
  121540. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  121541. /**
  121542. * Serializes this BRDF configuration.
  121543. * @returns - An object with the serialized config.
  121544. */
  121545. serialize(): any;
  121546. /**
  121547. * Parses a anisotropy Configuration from a serialized object.
  121548. * @param source - Serialized object.
  121549. * @param scene Defines the scene we are parsing for
  121550. * @param rootUrl Defines the rootUrl to load from
  121551. */
  121552. parse(source: any, scene: Scene, rootUrl: string): void;
  121553. }
  121554. }
  121555. declare module BABYLON {
  121556. /**
  121557. * @hidden
  121558. */
  121559. export interface IMaterialSubSurfaceDefines {
  121560. SUBSURFACE: boolean;
  121561. SS_REFRACTION: boolean;
  121562. SS_TRANSLUCENCY: boolean;
  121563. SS_SCATERRING: boolean;
  121564. SS_THICKNESSANDMASK_TEXTURE: boolean;
  121565. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  121566. SS_REFRACTIONMAP_3D: boolean;
  121567. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  121568. SS_LODINREFRACTIONALPHA: boolean;
  121569. SS_GAMMAREFRACTION: boolean;
  121570. SS_RGBDREFRACTION: boolean;
  121571. SS_LINEARSPECULARREFRACTION: boolean;
  121572. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  121573. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  121574. /** @hidden */
  121575. _areTexturesDirty: boolean;
  121576. }
  121577. /**
  121578. * Define the code related to the sub surface parameters of the pbr material.
  121579. */
  121580. export class PBRSubSurfaceConfiguration {
  121581. private _isRefractionEnabled;
  121582. /**
  121583. * Defines if the refraction is enabled in the material.
  121584. */
  121585. isRefractionEnabled: boolean;
  121586. private _isTranslucencyEnabled;
  121587. /**
  121588. * Defines if the translucency is enabled in the material.
  121589. */
  121590. isTranslucencyEnabled: boolean;
  121591. private _isScatteringEnabled;
  121592. /**
  121593. * Defines the refraction intensity of the material.
  121594. * The refraction when enabled replaces the Diffuse part of the material.
  121595. * The intensity helps transitionning between diffuse and refraction.
  121596. */
  121597. refractionIntensity: number;
  121598. /**
  121599. * Defines the translucency intensity of the material.
  121600. * When translucency has been enabled, this defines how much of the "translucency"
  121601. * is addded to the diffuse part of the material.
  121602. */
  121603. translucencyIntensity: number;
  121604. /**
  121605. * Defines the scattering intensity of the material.
  121606. * When scattering has been enabled, this defines how much of the "scattered light"
  121607. * is addded to the diffuse part of the material.
  121608. */
  121609. scatteringIntensity: number;
  121610. private _thicknessTexture;
  121611. /**
  121612. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  121613. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  121614. * 0 would mean minimumThickness
  121615. * 1 would mean maximumThickness
  121616. * The other channels might be use as a mask to vary the different effects intensity.
  121617. */
  121618. thicknessTexture: Nullable<BaseTexture>;
  121619. private _refractionTexture;
  121620. /**
  121621. * Defines the texture to use for refraction.
  121622. */
  121623. refractionTexture: Nullable<BaseTexture>;
  121624. private _indexOfRefraction;
  121625. /**
  121626. * Defines the index of refraction used in the material.
  121627. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  121628. */
  121629. indexOfRefraction: number;
  121630. private _invertRefractionY;
  121631. /**
  121632. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  121633. */
  121634. invertRefractionY: boolean;
  121635. private _linkRefractionWithTransparency;
  121636. /**
  121637. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  121638. * Materials half opaque for instance using refraction could benefit from this control.
  121639. */
  121640. linkRefractionWithTransparency: boolean;
  121641. /**
  121642. * Defines the minimum thickness stored in the thickness map.
  121643. * If no thickness map is defined, this value will be used to simulate thickness.
  121644. */
  121645. minimumThickness: number;
  121646. /**
  121647. * Defines the maximum thickness stored in the thickness map.
  121648. */
  121649. maximumThickness: number;
  121650. /**
  121651. * Defines the volume tint of the material.
  121652. * This is used for both translucency and scattering.
  121653. */
  121654. tintColor: Color3;
  121655. /**
  121656. * Defines the distance at which the tint color should be found in the media.
  121657. * This is used for refraction only.
  121658. */
  121659. tintColorAtDistance: number;
  121660. /**
  121661. * Defines how far each channel transmit through the media.
  121662. * It is defined as a color to simplify it selection.
  121663. */
  121664. diffusionDistance: Color3;
  121665. private _useMaskFromThicknessTexture;
  121666. /**
  121667. * Stores the intensity of the different subsurface effects in the thickness texture.
  121668. * * the green channel is the translucency intensity.
  121669. * * the blue channel is the scattering intensity.
  121670. * * the alpha channel is the refraction intensity.
  121671. */
  121672. useMaskFromThicknessTexture: boolean;
  121673. /** @hidden */
  121674. private _internalMarkAllSubMeshesAsTexturesDirty;
  121675. /** @hidden */
  121676. _markAllSubMeshesAsTexturesDirty(): void;
  121677. /**
  121678. * Instantiate a new istance of sub surface configuration.
  121679. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  121680. */
  121681. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  121682. /**
  121683. * Gets wehter the submesh is ready to be used or not.
  121684. * @param defines the list of "defines" to update.
  121685. * @param scene defines the scene the material belongs to.
  121686. * @returns - boolean indicating that the submesh is ready or not.
  121687. */
  121688. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  121689. /**
  121690. * Checks to see if a texture is used in the material.
  121691. * @param defines the list of "defines" to update.
  121692. * @param scene defines the scene to the material belongs to.
  121693. */
  121694. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  121695. /**
  121696. * Binds the material data.
  121697. * @param uniformBuffer defines the Uniform buffer to fill in.
  121698. * @param scene defines the scene the material belongs to.
  121699. * @param engine defines the engine the material belongs to.
  121700. * @param isFrozen defines wether the material is frozen or not.
  121701. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  121702. */
  121703. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  121704. /**
  121705. * Unbinds the material from the mesh.
  121706. * @param activeEffect defines the effect that should be unbound from.
  121707. * @returns true if unbound, otherwise false
  121708. */
  121709. unbind(activeEffect: Effect): boolean;
  121710. /**
  121711. * Returns the texture used for refraction or null if none is used.
  121712. * @param scene defines the scene the material belongs to.
  121713. * @returns - Refraction texture if present. If no refraction texture and refraction
  121714. * is linked with transparency, returns environment texture. Otherwise, returns null.
  121715. */
  121716. private _getRefractionTexture;
  121717. /**
  121718. * Returns true if alpha blending should be disabled.
  121719. */
  121720. get disableAlphaBlending(): boolean;
  121721. /**
  121722. * Fills the list of render target textures.
  121723. * @param renderTargets the list of render targets to update
  121724. */
  121725. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  121726. /**
  121727. * Checks to see if a texture is used in the material.
  121728. * @param texture - Base texture to use.
  121729. * @returns - Boolean specifying if a texture is used in the material.
  121730. */
  121731. hasTexture(texture: BaseTexture): boolean;
  121732. /**
  121733. * Gets a boolean indicating that current material needs to register RTT
  121734. * @returns true if this uses a render target otherwise false.
  121735. */
  121736. hasRenderTargetTextures(): boolean;
  121737. /**
  121738. * Returns an array of the actively used textures.
  121739. * @param activeTextures Array of BaseTextures
  121740. */
  121741. getActiveTextures(activeTextures: BaseTexture[]): void;
  121742. /**
  121743. * Returns the animatable textures.
  121744. * @param animatables Array of animatable textures.
  121745. */
  121746. getAnimatables(animatables: IAnimatable[]): void;
  121747. /**
  121748. * Disposes the resources of the material.
  121749. * @param forceDisposeTextures - Forces the disposal of all textures.
  121750. */
  121751. dispose(forceDisposeTextures?: boolean): void;
  121752. /**
  121753. * Get the current class name of the texture useful for serialization or dynamic coding.
  121754. * @returns "PBRSubSurfaceConfiguration"
  121755. */
  121756. getClassName(): string;
  121757. /**
  121758. * Add fallbacks to the effect fallbacks list.
  121759. * @param defines defines the Base texture to use.
  121760. * @param fallbacks defines the current fallback list.
  121761. * @param currentRank defines the current fallback rank.
  121762. * @returns the new fallback rank.
  121763. */
  121764. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  121765. /**
  121766. * Add the required uniforms to the current list.
  121767. * @param uniforms defines the current uniform list.
  121768. */
  121769. static AddUniforms(uniforms: string[]): void;
  121770. /**
  121771. * Add the required samplers to the current list.
  121772. * @param samplers defines the current sampler list.
  121773. */
  121774. static AddSamplers(samplers: string[]): void;
  121775. /**
  121776. * Add the required uniforms to the current buffer.
  121777. * @param uniformBuffer defines the current uniform buffer.
  121778. */
  121779. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  121780. /**
  121781. * Makes a duplicate of the current configuration into another one.
  121782. * @param configuration define the config where to copy the info
  121783. */
  121784. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  121785. /**
  121786. * Serializes this Sub Surface configuration.
  121787. * @returns - An object with the serialized config.
  121788. */
  121789. serialize(): any;
  121790. /**
  121791. * Parses a anisotropy Configuration from a serialized object.
  121792. * @param source - Serialized object.
  121793. * @param scene Defines the scene we are parsing for
  121794. * @param rootUrl Defines the rootUrl to load from
  121795. */
  121796. parse(source: any, scene: Scene, rootUrl: string): void;
  121797. }
  121798. }
  121799. declare module BABYLON {
  121800. /** @hidden */
  121801. export var pbrFragmentDeclaration: {
  121802. name: string;
  121803. shader: string;
  121804. };
  121805. }
  121806. declare module BABYLON {
  121807. /** @hidden */
  121808. export var pbrUboDeclaration: {
  121809. name: string;
  121810. shader: string;
  121811. };
  121812. }
  121813. declare module BABYLON {
  121814. /** @hidden */
  121815. export var pbrFragmentExtraDeclaration: {
  121816. name: string;
  121817. shader: string;
  121818. };
  121819. }
  121820. declare module BABYLON {
  121821. /** @hidden */
  121822. export var pbrFragmentSamplersDeclaration: {
  121823. name: string;
  121824. shader: string;
  121825. };
  121826. }
  121827. declare module BABYLON {
  121828. /** @hidden */
  121829. export var pbrHelperFunctions: {
  121830. name: string;
  121831. shader: string;
  121832. };
  121833. }
  121834. declare module BABYLON {
  121835. /** @hidden */
  121836. export var harmonicsFunctions: {
  121837. name: string;
  121838. shader: string;
  121839. };
  121840. }
  121841. declare module BABYLON {
  121842. /** @hidden */
  121843. export var pbrDirectLightingSetupFunctions: {
  121844. name: string;
  121845. shader: string;
  121846. };
  121847. }
  121848. declare module BABYLON {
  121849. /** @hidden */
  121850. export var pbrDirectLightingFalloffFunctions: {
  121851. name: string;
  121852. shader: string;
  121853. };
  121854. }
  121855. declare module BABYLON {
  121856. /** @hidden */
  121857. export var pbrBRDFFunctions: {
  121858. name: string;
  121859. shader: string;
  121860. };
  121861. }
  121862. declare module BABYLON {
  121863. /** @hidden */
  121864. export var pbrDirectLightingFunctions: {
  121865. name: string;
  121866. shader: string;
  121867. };
  121868. }
  121869. declare module BABYLON {
  121870. /** @hidden */
  121871. export var pbrIBLFunctions: {
  121872. name: string;
  121873. shader: string;
  121874. };
  121875. }
  121876. declare module BABYLON {
  121877. /** @hidden */
  121878. export var pbrDebug: {
  121879. name: string;
  121880. shader: string;
  121881. };
  121882. }
  121883. declare module BABYLON {
  121884. /** @hidden */
  121885. export var pbrPixelShader: {
  121886. name: string;
  121887. shader: string;
  121888. };
  121889. }
  121890. declare module BABYLON {
  121891. /** @hidden */
  121892. export var pbrVertexDeclaration: {
  121893. name: string;
  121894. shader: string;
  121895. };
  121896. }
  121897. declare module BABYLON {
  121898. /** @hidden */
  121899. export var pbrVertexShader: {
  121900. name: string;
  121901. shader: string;
  121902. };
  121903. }
  121904. declare module BABYLON {
  121905. /**
  121906. * Manages the defines for the PBR Material.
  121907. * @hidden
  121908. */
  121909. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  121910. PBR: boolean;
  121911. MAINUV1: boolean;
  121912. MAINUV2: boolean;
  121913. UV1: boolean;
  121914. UV2: boolean;
  121915. ALBEDO: boolean;
  121916. ALBEDODIRECTUV: number;
  121917. VERTEXCOLOR: boolean;
  121918. AMBIENT: boolean;
  121919. AMBIENTDIRECTUV: number;
  121920. AMBIENTINGRAYSCALE: boolean;
  121921. OPACITY: boolean;
  121922. VERTEXALPHA: boolean;
  121923. OPACITYDIRECTUV: number;
  121924. OPACITYRGB: boolean;
  121925. ALPHATEST: boolean;
  121926. DEPTHPREPASS: boolean;
  121927. ALPHABLEND: boolean;
  121928. ALPHAFROMALBEDO: boolean;
  121929. ALPHATESTVALUE: string;
  121930. SPECULAROVERALPHA: boolean;
  121931. RADIANCEOVERALPHA: boolean;
  121932. ALPHAFRESNEL: boolean;
  121933. LINEARALPHAFRESNEL: boolean;
  121934. PREMULTIPLYALPHA: boolean;
  121935. EMISSIVE: boolean;
  121936. EMISSIVEDIRECTUV: number;
  121937. REFLECTIVITY: boolean;
  121938. REFLECTIVITYDIRECTUV: number;
  121939. SPECULARTERM: boolean;
  121940. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  121941. MICROSURFACEAUTOMATIC: boolean;
  121942. LODBASEDMICROSFURACE: boolean;
  121943. MICROSURFACEMAP: boolean;
  121944. MICROSURFACEMAPDIRECTUV: number;
  121945. METALLICWORKFLOW: boolean;
  121946. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  121947. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  121948. METALLNESSSTOREINMETALMAPBLUE: boolean;
  121949. AOSTOREINMETALMAPRED: boolean;
  121950. METALLICF0FACTORFROMMETALLICMAP: boolean;
  121951. ENVIRONMENTBRDF: boolean;
  121952. ENVIRONMENTBRDF_RGBD: boolean;
  121953. NORMAL: boolean;
  121954. TANGENT: boolean;
  121955. BUMP: boolean;
  121956. BUMPDIRECTUV: number;
  121957. OBJECTSPACE_NORMALMAP: boolean;
  121958. PARALLAX: boolean;
  121959. PARALLAXOCCLUSION: boolean;
  121960. NORMALXYSCALE: boolean;
  121961. LIGHTMAP: boolean;
  121962. LIGHTMAPDIRECTUV: number;
  121963. USELIGHTMAPASSHADOWMAP: boolean;
  121964. GAMMALIGHTMAP: boolean;
  121965. RGBDLIGHTMAP: boolean;
  121966. REFLECTION: boolean;
  121967. REFLECTIONMAP_3D: boolean;
  121968. REFLECTIONMAP_SPHERICAL: boolean;
  121969. REFLECTIONMAP_PLANAR: boolean;
  121970. REFLECTIONMAP_CUBIC: boolean;
  121971. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  121972. REFLECTIONMAP_PROJECTION: boolean;
  121973. REFLECTIONMAP_SKYBOX: boolean;
  121974. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  121975. REFLECTIONMAP_EXPLICIT: boolean;
  121976. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  121977. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  121978. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  121979. INVERTCUBICMAP: boolean;
  121980. USESPHERICALFROMREFLECTIONMAP: boolean;
  121981. USEIRRADIANCEMAP: boolean;
  121982. SPHERICAL_HARMONICS: boolean;
  121983. USESPHERICALINVERTEX: boolean;
  121984. REFLECTIONMAP_OPPOSITEZ: boolean;
  121985. LODINREFLECTIONALPHA: boolean;
  121986. GAMMAREFLECTION: boolean;
  121987. RGBDREFLECTION: boolean;
  121988. LINEARSPECULARREFLECTION: boolean;
  121989. RADIANCEOCCLUSION: boolean;
  121990. HORIZONOCCLUSION: boolean;
  121991. INSTANCES: boolean;
  121992. NUM_BONE_INFLUENCERS: number;
  121993. BonesPerMesh: number;
  121994. BONETEXTURE: boolean;
  121995. NONUNIFORMSCALING: boolean;
  121996. MORPHTARGETS: boolean;
  121997. MORPHTARGETS_NORMAL: boolean;
  121998. MORPHTARGETS_TANGENT: boolean;
  121999. MORPHTARGETS_UV: boolean;
  122000. NUM_MORPH_INFLUENCERS: number;
  122001. IMAGEPROCESSING: boolean;
  122002. VIGNETTE: boolean;
  122003. VIGNETTEBLENDMODEMULTIPLY: boolean;
  122004. VIGNETTEBLENDMODEOPAQUE: boolean;
  122005. TONEMAPPING: boolean;
  122006. TONEMAPPING_ACES: boolean;
  122007. CONTRAST: boolean;
  122008. COLORCURVES: boolean;
  122009. COLORGRADING: boolean;
  122010. COLORGRADING3D: boolean;
  122011. SAMPLER3DGREENDEPTH: boolean;
  122012. SAMPLER3DBGRMAP: boolean;
  122013. IMAGEPROCESSINGPOSTPROCESS: boolean;
  122014. EXPOSURE: boolean;
  122015. MULTIVIEW: boolean;
  122016. USEPHYSICALLIGHTFALLOFF: boolean;
  122017. USEGLTFLIGHTFALLOFF: boolean;
  122018. TWOSIDEDLIGHTING: boolean;
  122019. SHADOWFLOAT: boolean;
  122020. CLIPPLANE: boolean;
  122021. CLIPPLANE2: boolean;
  122022. CLIPPLANE3: boolean;
  122023. CLIPPLANE4: boolean;
  122024. CLIPPLANE5: boolean;
  122025. CLIPPLANE6: boolean;
  122026. POINTSIZE: boolean;
  122027. FOG: boolean;
  122028. LOGARITHMICDEPTH: boolean;
  122029. FORCENORMALFORWARD: boolean;
  122030. SPECULARAA: boolean;
  122031. CLEARCOAT: boolean;
  122032. CLEARCOAT_DEFAULTIOR: boolean;
  122033. CLEARCOAT_TEXTURE: boolean;
  122034. CLEARCOAT_TEXTUREDIRECTUV: number;
  122035. CLEARCOAT_BUMP: boolean;
  122036. CLEARCOAT_BUMPDIRECTUV: number;
  122037. CLEARCOAT_TINT: boolean;
  122038. CLEARCOAT_TINT_TEXTURE: boolean;
  122039. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  122040. ANISOTROPIC: boolean;
  122041. ANISOTROPIC_TEXTURE: boolean;
  122042. ANISOTROPIC_TEXTUREDIRECTUV: number;
  122043. BRDF_V_HEIGHT_CORRELATED: boolean;
  122044. MS_BRDF_ENERGY_CONSERVATION: boolean;
  122045. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  122046. SHEEN: boolean;
  122047. SHEEN_TEXTURE: boolean;
  122048. SHEEN_TEXTUREDIRECTUV: number;
  122049. SHEEN_LINKWITHALBEDO: boolean;
  122050. SUBSURFACE: boolean;
  122051. SS_REFRACTION: boolean;
  122052. SS_TRANSLUCENCY: boolean;
  122053. SS_SCATERRING: boolean;
  122054. SS_THICKNESSANDMASK_TEXTURE: boolean;
  122055. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  122056. SS_REFRACTIONMAP_3D: boolean;
  122057. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  122058. SS_LODINREFRACTIONALPHA: boolean;
  122059. SS_GAMMAREFRACTION: boolean;
  122060. SS_RGBDREFRACTION: boolean;
  122061. SS_LINEARSPECULARREFRACTION: boolean;
  122062. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  122063. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  122064. UNLIT: boolean;
  122065. DEBUGMODE: number;
  122066. /**
  122067. * Initializes the PBR Material defines.
  122068. */
  122069. constructor();
  122070. /**
  122071. * Resets the PBR Material defines.
  122072. */
  122073. reset(): void;
  122074. }
  122075. /**
  122076. * The Physically based material base class of BJS.
  122077. *
  122078. * This offers the main features of a standard PBR material.
  122079. * For more information, please refer to the documentation :
  122080. * https://doc.babylonjs.com/how_to/physically_based_rendering
  122081. */
  122082. export abstract class PBRBaseMaterial extends PushMaterial {
  122083. /**
  122084. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  122085. */
  122086. static readonly PBRMATERIAL_OPAQUE: number;
  122087. /**
  122088. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  122089. */
  122090. static readonly PBRMATERIAL_ALPHATEST: number;
  122091. /**
  122092. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  122093. */
  122094. static readonly PBRMATERIAL_ALPHABLEND: number;
  122095. /**
  122096. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  122097. * They are also discarded below the alpha cutoff threshold to improve performances.
  122098. */
  122099. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  122100. /**
  122101. * Defines the default value of how much AO map is occluding the analytical lights
  122102. * (point spot...).
  122103. */
  122104. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  122105. /**
  122106. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  122107. */
  122108. static readonly LIGHTFALLOFF_PHYSICAL: number;
  122109. /**
  122110. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  122111. * to enhance interoperability with other engines.
  122112. */
  122113. static readonly LIGHTFALLOFF_GLTF: number;
  122114. /**
  122115. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  122116. * to enhance interoperability with other materials.
  122117. */
  122118. static readonly LIGHTFALLOFF_STANDARD: number;
  122119. /**
  122120. * Intensity of the direct lights e.g. the four lights available in your scene.
  122121. * This impacts both the direct diffuse and specular highlights.
  122122. */
  122123. protected _directIntensity: number;
  122124. /**
  122125. * Intensity of the emissive part of the material.
  122126. * This helps controlling the emissive effect without modifying the emissive color.
  122127. */
  122128. protected _emissiveIntensity: number;
  122129. /**
  122130. * Intensity of the environment e.g. how much the environment will light the object
  122131. * either through harmonics for rough material or through the refelction for shiny ones.
  122132. */
  122133. protected _environmentIntensity: number;
  122134. /**
  122135. * This is a special control allowing the reduction of the specular highlights coming from the
  122136. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  122137. */
  122138. protected _specularIntensity: number;
  122139. /**
  122140. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  122141. */
  122142. private _lightingInfos;
  122143. /**
  122144. * Debug Control allowing disabling the bump map on this material.
  122145. */
  122146. protected _disableBumpMap: boolean;
  122147. /**
  122148. * AKA Diffuse Texture in standard nomenclature.
  122149. */
  122150. protected _albedoTexture: Nullable<BaseTexture>;
  122151. /**
  122152. * AKA Occlusion Texture in other nomenclature.
  122153. */
  122154. protected _ambientTexture: Nullable<BaseTexture>;
  122155. /**
  122156. * AKA Occlusion Texture Intensity in other nomenclature.
  122157. */
  122158. protected _ambientTextureStrength: number;
  122159. /**
  122160. * Defines how much the AO map is occluding the analytical lights (point spot...).
  122161. * 1 means it completely occludes it
  122162. * 0 mean it has no impact
  122163. */
  122164. protected _ambientTextureImpactOnAnalyticalLights: number;
  122165. /**
  122166. * Stores the alpha values in a texture.
  122167. */
  122168. protected _opacityTexture: Nullable<BaseTexture>;
  122169. /**
  122170. * Stores the reflection values in a texture.
  122171. */
  122172. protected _reflectionTexture: Nullable<BaseTexture>;
  122173. /**
  122174. * Stores the emissive values in a texture.
  122175. */
  122176. protected _emissiveTexture: Nullable<BaseTexture>;
  122177. /**
  122178. * AKA Specular texture in other nomenclature.
  122179. */
  122180. protected _reflectivityTexture: Nullable<BaseTexture>;
  122181. /**
  122182. * Used to switch from specular/glossiness to metallic/roughness workflow.
  122183. */
  122184. protected _metallicTexture: Nullable<BaseTexture>;
  122185. /**
  122186. * Specifies the metallic scalar of the metallic/roughness workflow.
  122187. * Can also be used to scale the metalness values of the metallic texture.
  122188. */
  122189. protected _metallic: Nullable<number>;
  122190. /**
  122191. * Specifies the roughness scalar of the metallic/roughness workflow.
  122192. * Can also be used to scale the roughness values of the metallic texture.
  122193. */
  122194. protected _roughness: Nullable<number>;
  122195. /**
  122196. * Specifies the an F0 factor to help configuring the material F0.
  122197. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  122198. * to 0.5 the previously hard coded value stays the same.
  122199. * Can also be used to scale the F0 values of the metallic texture.
  122200. */
  122201. protected _metallicF0Factor: number;
  122202. /**
  122203. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  122204. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  122205. * your expectation as it multiplies with the texture data.
  122206. */
  122207. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  122208. /**
  122209. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  122210. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  122211. */
  122212. protected _microSurfaceTexture: Nullable<BaseTexture>;
  122213. /**
  122214. * Stores surface normal data used to displace a mesh in a texture.
  122215. */
  122216. protected _bumpTexture: Nullable<BaseTexture>;
  122217. /**
  122218. * Stores the pre-calculated light information of a mesh in a texture.
  122219. */
  122220. protected _lightmapTexture: Nullable<BaseTexture>;
  122221. /**
  122222. * The color of a material in ambient lighting.
  122223. */
  122224. protected _ambientColor: Color3;
  122225. /**
  122226. * AKA Diffuse Color in other nomenclature.
  122227. */
  122228. protected _albedoColor: Color3;
  122229. /**
  122230. * AKA Specular Color in other nomenclature.
  122231. */
  122232. protected _reflectivityColor: Color3;
  122233. /**
  122234. * The color applied when light is reflected from a material.
  122235. */
  122236. protected _reflectionColor: Color3;
  122237. /**
  122238. * The color applied when light is emitted from a material.
  122239. */
  122240. protected _emissiveColor: Color3;
  122241. /**
  122242. * AKA Glossiness in other nomenclature.
  122243. */
  122244. protected _microSurface: number;
  122245. /**
  122246. * Specifies that the material will use the light map as a show map.
  122247. */
  122248. protected _useLightmapAsShadowmap: boolean;
  122249. /**
  122250. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  122251. * makes the reflect vector face the model (under horizon).
  122252. */
  122253. protected _useHorizonOcclusion: boolean;
  122254. /**
  122255. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  122256. * too much the area relying on ambient texture to define their ambient occlusion.
  122257. */
  122258. protected _useRadianceOcclusion: boolean;
  122259. /**
  122260. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  122261. */
  122262. protected _useAlphaFromAlbedoTexture: boolean;
  122263. /**
  122264. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  122265. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  122266. */
  122267. protected _useSpecularOverAlpha: boolean;
  122268. /**
  122269. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  122270. */
  122271. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  122272. /**
  122273. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  122274. */
  122275. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  122276. /**
  122277. * Specifies if the metallic texture contains the roughness information in its green channel.
  122278. */
  122279. protected _useRoughnessFromMetallicTextureGreen: boolean;
  122280. /**
  122281. * Specifies if the metallic texture contains the metallness information in its blue channel.
  122282. */
  122283. protected _useMetallnessFromMetallicTextureBlue: boolean;
  122284. /**
  122285. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  122286. */
  122287. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  122288. /**
  122289. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  122290. */
  122291. protected _useAmbientInGrayScale: boolean;
  122292. /**
  122293. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  122294. * The material will try to infer what glossiness each pixel should be.
  122295. */
  122296. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  122297. /**
  122298. * Defines the falloff type used in this material.
  122299. * It by default is Physical.
  122300. */
  122301. protected _lightFalloff: number;
  122302. /**
  122303. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  122304. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  122305. */
  122306. protected _useRadianceOverAlpha: boolean;
  122307. /**
  122308. * Allows using an object space normal map (instead of tangent space).
  122309. */
  122310. protected _useObjectSpaceNormalMap: boolean;
  122311. /**
  122312. * Allows using the bump map in parallax mode.
  122313. */
  122314. protected _useParallax: boolean;
  122315. /**
  122316. * Allows using the bump map in parallax occlusion mode.
  122317. */
  122318. protected _useParallaxOcclusion: boolean;
  122319. /**
  122320. * Controls the scale bias of the parallax mode.
  122321. */
  122322. protected _parallaxScaleBias: number;
  122323. /**
  122324. * If sets to true, disables all the lights affecting the material.
  122325. */
  122326. protected _disableLighting: boolean;
  122327. /**
  122328. * Number of Simultaneous lights allowed on the material.
  122329. */
  122330. protected _maxSimultaneousLights: number;
  122331. /**
  122332. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  122333. */
  122334. protected _invertNormalMapX: boolean;
  122335. /**
  122336. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  122337. */
  122338. protected _invertNormalMapY: boolean;
  122339. /**
  122340. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  122341. */
  122342. protected _twoSidedLighting: boolean;
  122343. /**
  122344. * Defines the alpha limits in alpha test mode.
  122345. */
  122346. protected _alphaCutOff: number;
  122347. /**
  122348. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  122349. */
  122350. protected _forceAlphaTest: boolean;
  122351. /**
  122352. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  122353. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  122354. */
  122355. protected _useAlphaFresnel: boolean;
  122356. /**
  122357. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  122358. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  122359. */
  122360. protected _useLinearAlphaFresnel: boolean;
  122361. /**
  122362. * The transparency mode of the material.
  122363. */
  122364. protected _transparencyMode: Nullable<number>;
  122365. /**
  122366. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  122367. * from cos thetav and roughness:
  122368. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  122369. */
  122370. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  122371. /**
  122372. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  122373. */
  122374. protected _forceIrradianceInFragment: boolean;
  122375. /**
  122376. * Force normal to face away from face.
  122377. */
  122378. protected _forceNormalForward: boolean;
  122379. /**
  122380. * Enables specular anti aliasing in the PBR shader.
  122381. * It will both interacts on the Geometry for analytical and IBL lighting.
  122382. * It also prefilter the roughness map based on the bump values.
  122383. */
  122384. protected _enableSpecularAntiAliasing: boolean;
  122385. /**
  122386. * Default configuration related to image processing available in the PBR Material.
  122387. */
  122388. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122389. /**
  122390. * Keep track of the image processing observer to allow dispose and replace.
  122391. */
  122392. private _imageProcessingObserver;
  122393. /**
  122394. * Attaches a new image processing configuration to the PBR Material.
  122395. * @param configuration
  122396. */
  122397. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122398. /**
  122399. * Stores the available render targets.
  122400. */
  122401. private _renderTargets;
  122402. /**
  122403. * Sets the global ambient color for the material used in lighting calculations.
  122404. */
  122405. private _globalAmbientColor;
  122406. /**
  122407. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  122408. */
  122409. private _useLogarithmicDepth;
  122410. /**
  122411. * If set to true, no lighting calculations will be applied.
  122412. */
  122413. private _unlit;
  122414. private _debugMode;
  122415. /**
  122416. * @hidden
  122417. * This is reserved for the inspector.
  122418. * Defines the material debug mode.
  122419. * It helps seeing only some components of the material while troubleshooting.
  122420. */
  122421. debugMode: number;
  122422. /**
  122423. * @hidden
  122424. * This is reserved for the inspector.
  122425. * Specify from where on screen the debug mode should start.
  122426. * The value goes from -1 (full screen) to 1 (not visible)
  122427. * It helps with side by side comparison against the final render
  122428. * This defaults to -1
  122429. */
  122430. private debugLimit;
  122431. /**
  122432. * @hidden
  122433. * This is reserved for the inspector.
  122434. * As the default viewing range might not be enough (if the ambient is really small for instance)
  122435. * You can use the factor to better multiply the final value.
  122436. */
  122437. private debugFactor;
  122438. /**
  122439. * Defines the clear coat layer parameters for the material.
  122440. */
  122441. readonly clearCoat: PBRClearCoatConfiguration;
  122442. /**
  122443. * Defines the anisotropic parameters for the material.
  122444. */
  122445. readonly anisotropy: PBRAnisotropicConfiguration;
  122446. /**
  122447. * Defines the BRDF parameters for the material.
  122448. */
  122449. readonly brdf: PBRBRDFConfiguration;
  122450. /**
  122451. * Defines the Sheen parameters for the material.
  122452. */
  122453. readonly sheen: PBRSheenConfiguration;
  122454. /**
  122455. * Defines the SubSurface parameters for the material.
  122456. */
  122457. readonly subSurface: PBRSubSurfaceConfiguration;
  122458. /**
  122459. * Custom callback helping to override the default shader used in the material.
  122460. */
  122461. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  122462. protected _rebuildInParallel: boolean;
  122463. /**
  122464. * Instantiates a new PBRMaterial instance.
  122465. *
  122466. * @param name The material name
  122467. * @param scene The scene the material will be use in.
  122468. */
  122469. constructor(name: string, scene: Scene);
  122470. /**
  122471. * Gets a boolean indicating that current material needs to register RTT
  122472. */
  122473. get hasRenderTargetTextures(): boolean;
  122474. /**
  122475. * Gets the name of the material class.
  122476. */
  122477. getClassName(): string;
  122478. /**
  122479. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  122480. */
  122481. get useLogarithmicDepth(): boolean;
  122482. /**
  122483. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  122484. */
  122485. set useLogarithmicDepth(value: boolean);
  122486. /**
  122487. * Gets the current transparency mode.
  122488. */
  122489. get transparencyMode(): Nullable<number>;
  122490. /**
  122491. * Sets the transparency mode of the material.
  122492. *
  122493. * | Value | Type | Description |
  122494. * | ----- | ----------------------------------- | ----------- |
  122495. * | 0 | OPAQUE | |
  122496. * | 1 | ALPHATEST | |
  122497. * | 2 | ALPHABLEND | |
  122498. * | 3 | ALPHATESTANDBLEND | |
  122499. *
  122500. */
  122501. set transparencyMode(value: Nullable<number>);
  122502. /**
  122503. * Returns true if alpha blending should be disabled.
  122504. */
  122505. private get _disableAlphaBlending();
  122506. /**
  122507. * Specifies whether or not this material should be rendered in alpha blend mode.
  122508. */
  122509. needAlphaBlending(): boolean;
  122510. /**
  122511. * Specifies if the mesh will require alpha blending.
  122512. * @param mesh - BJS mesh.
  122513. */
  122514. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  122515. /**
  122516. * Specifies whether or not this material should be rendered in alpha test mode.
  122517. */
  122518. needAlphaTesting(): boolean;
  122519. /**
  122520. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  122521. */
  122522. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  122523. /**
  122524. * Gets the texture used for the alpha test.
  122525. */
  122526. getAlphaTestTexture(): Nullable<BaseTexture>;
  122527. /**
  122528. * Specifies that the submesh is ready to be used.
  122529. * @param mesh - BJS mesh.
  122530. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  122531. * @param useInstances - Specifies that instances should be used.
  122532. * @returns - boolean indicating that the submesh is ready or not.
  122533. */
  122534. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122535. /**
  122536. * Specifies if the material uses metallic roughness workflow.
  122537. * @returns boolean specifiying if the material uses metallic roughness workflow.
  122538. */
  122539. isMetallicWorkflow(): boolean;
  122540. private _prepareEffect;
  122541. private _prepareDefines;
  122542. /**
  122543. * Force shader compilation
  122544. */
  122545. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  122546. /**
  122547. * Initializes the uniform buffer layout for the shader.
  122548. */
  122549. buildUniformLayout(): void;
  122550. /**
  122551. * Unbinds the material from the mesh
  122552. */
  122553. unbind(): void;
  122554. /**
  122555. * Binds the submesh data.
  122556. * @param world - The world matrix.
  122557. * @param mesh - The BJS mesh.
  122558. * @param subMesh - A submesh of the BJS mesh.
  122559. */
  122560. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122561. /**
  122562. * Returns the animatable textures.
  122563. * @returns - Array of animatable textures.
  122564. */
  122565. getAnimatables(): IAnimatable[];
  122566. /**
  122567. * Returns the texture used for reflections.
  122568. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  122569. */
  122570. private _getReflectionTexture;
  122571. /**
  122572. * Returns an array of the actively used textures.
  122573. * @returns - Array of BaseTextures
  122574. */
  122575. getActiveTextures(): BaseTexture[];
  122576. /**
  122577. * Checks to see if a texture is used in the material.
  122578. * @param texture - Base texture to use.
  122579. * @returns - Boolean specifying if a texture is used in the material.
  122580. */
  122581. hasTexture(texture: BaseTexture): boolean;
  122582. /**
  122583. * Disposes the resources of the material.
  122584. * @param forceDisposeEffect - Forces the disposal of effects.
  122585. * @param forceDisposeTextures - Forces the disposal of all textures.
  122586. */
  122587. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122588. }
  122589. }
  122590. declare module BABYLON {
  122591. /**
  122592. * The Physically based material of BJS.
  122593. *
  122594. * This offers the main features of a standard PBR material.
  122595. * For more information, please refer to the documentation :
  122596. * https://doc.babylonjs.com/how_to/physically_based_rendering
  122597. */
  122598. export class PBRMaterial extends PBRBaseMaterial {
  122599. /**
  122600. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  122601. */
  122602. static readonly PBRMATERIAL_OPAQUE: number;
  122603. /**
  122604. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  122605. */
  122606. static readonly PBRMATERIAL_ALPHATEST: number;
  122607. /**
  122608. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  122609. */
  122610. static readonly PBRMATERIAL_ALPHABLEND: number;
  122611. /**
  122612. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  122613. * They are also discarded below the alpha cutoff threshold to improve performances.
  122614. */
  122615. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  122616. /**
  122617. * Defines the default value of how much AO map is occluding the analytical lights
  122618. * (point spot...).
  122619. */
  122620. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  122621. /**
  122622. * Intensity of the direct lights e.g. the four lights available in your scene.
  122623. * This impacts both the direct diffuse and specular highlights.
  122624. */
  122625. directIntensity: number;
  122626. /**
  122627. * Intensity of the emissive part of the material.
  122628. * This helps controlling the emissive effect without modifying the emissive color.
  122629. */
  122630. emissiveIntensity: number;
  122631. /**
  122632. * Intensity of the environment e.g. how much the environment will light the object
  122633. * either through harmonics for rough material or through the refelction for shiny ones.
  122634. */
  122635. environmentIntensity: number;
  122636. /**
  122637. * This is a special control allowing the reduction of the specular highlights coming from the
  122638. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  122639. */
  122640. specularIntensity: number;
  122641. /**
  122642. * Debug Control allowing disabling the bump map on this material.
  122643. */
  122644. disableBumpMap: boolean;
  122645. /**
  122646. * AKA Diffuse Texture in standard nomenclature.
  122647. */
  122648. albedoTexture: BaseTexture;
  122649. /**
  122650. * AKA Occlusion Texture in other nomenclature.
  122651. */
  122652. ambientTexture: BaseTexture;
  122653. /**
  122654. * AKA Occlusion Texture Intensity in other nomenclature.
  122655. */
  122656. ambientTextureStrength: number;
  122657. /**
  122658. * Defines how much the AO map is occluding the analytical lights (point spot...).
  122659. * 1 means it completely occludes it
  122660. * 0 mean it has no impact
  122661. */
  122662. ambientTextureImpactOnAnalyticalLights: number;
  122663. /**
  122664. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  122665. */
  122666. opacityTexture: BaseTexture;
  122667. /**
  122668. * Stores the reflection values in a texture.
  122669. */
  122670. reflectionTexture: Nullable<BaseTexture>;
  122671. /**
  122672. * Stores the emissive values in a texture.
  122673. */
  122674. emissiveTexture: BaseTexture;
  122675. /**
  122676. * AKA Specular texture in other nomenclature.
  122677. */
  122678. reflectivityTexture: BaseTexture;
  122679. /**
  122680. * Used to switch from specular/glossiness to metallic/roughness workflow.
  122681. */
  122682. metallicTexture: BaseTexture;
  122683. /**
  122684. * Specifies the metallic scalar of the metallic/roughness workflow.
  122685. * Can also be used to scale the metalness values of the metallic texture.
  122686. */
  122687. metallic: Nullable<number>;
  122688. /**
  122689. * Specifies the roughness scalar of the metallic/roughness workflow.
  122690. * Can also be used to scale the roughness values of the metallic texture.
  122691. */
  122692. roughness: Nullable<number>;
  122693. /**
  122694. * Specifies the an F0 factor to help configuring the material F0.
  122695. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  122696. * to 0.5 the previously hard coded value stays the same.
  122697. * Can also be used to scale the F0 values of the metallic texture.
  122698. */
  122699. metallicF0Factor: number;
  122700. /**
  122701. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  122702. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  122703. * your expectation as it multiplies with the texture data.
  122704. */
  122705. useMetallicF0FactorFromMetallicTexture: boolean;
  122706. /**
  122707. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  122708. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  122709. */
  122710. microSurfaceTexture: BaseTexture;
  122711. /**
  122712. * Stores surface normal data used to displace a mesh in a texture.
  122713. */
  122714. bumpTexture: BaseTexture;
  122715. /**
  122716. * Stores the pre-calculated light information of a mesh in a texture.
  122717. */
  122718. lightmapTexture: BaseTexture;
  122719. /**
  122720. * Stores the refracted light information in a texture.
  122721. */
  122722. get refractionTexture(): Nullable<BaseTexture>;
  122723. set refractionTexture(value: Nullable<BaseTexture>);
  122724. /**
  122725. * The color of a material in ambient lighting.
  122726. */
  122727. ambientColor: Color3;
  122728. /**
  122729. * AKA Diffuse Color in other nomenclature.
  122730. */
  122731. albedoColor: Color3;
  122732. /**
  122733. * AKA Specular Color in other nomenclature.
  122734. */
  122735. reflectivityColor: Color3;
  122736. /**
  122737. * The color reflected from the material.
  122738. */
  122739. reflectionColor: Color3;
  122740. /**
  122741. * The color emitted from the material.
  122742. */
  122743. emissiveColor: Color3;
  122744. /**
  122745. * AKA Glossiness in other nomenclature.
  122746. */
  122747. microSurface: number;
  122748. /**
  122749. * source material index of refraction (IOR)' / 'destination material IOR.
  122750. */
  122751. get indexOfRefraction(): number;
  122752. set indexOfRefraction(value: number);
  122753. /**
  122754. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  122755. */
  122756. get invertRefractionY(): boolean;
  122757. set invertRefractionY(value: boolean);
  122758. /**
  122759. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  122760. * Materials half opaque for instance using refraction could benefit from this control.
  122761. */
  122762. get linkRefractionWithTransparency(): boolean;
  122763. set linkRefractionWithTransparency(value: boolean);
  122764. /**
  122765. * If true, the light map contains occlusion information instead of lighting info.
  122766. */
  122767. useLightmapAsShadowmap: boolean;
  122768. /**
  122769. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  122770. */
  122771. useAlphaFromAlbedoTexture: boolean;
  122772. /**
  122773. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  122774. */
  122775. forceAlphaTest: boolean;
  122776. /**
  122777. * Defines the alpha limits in alpha test mode.
  122778. */
  122779. alphaCutOff: number;
  122780. /**
  122781. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  122782. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  122783. */
  122784. useSpecularOverAlpha: boolean;
  122785. /**
  122786. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  122787. */
  122788. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  122789. /**
  122790. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  122791. */
  122792. useRoughnessFromMetallicTextureAlpha: boolean;
  122793. /**
  122794. * Specifies if the metallic texture contains the roughness information in its green channel.
  122795. */
  122796. useRoughnessFromMetallicTextureGreen: boolean;
  122797. /**
  122798. * Specifies if the metallic texture contains the metallness information in its blue channel.
  122799. */
  122800. useMetallnessFromMetallicTextureBlue: boolean;
  122801. /**
  122802. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  122803. */
  122804. useAmbientOcclusionFromMetallicTextureRed: boolean;
  122805. /**
  122806. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  122807. */
  122808. useAmbientInGrayScale: boolean;
  122809. /**
  122810. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  122811. * The material will try to infer what glossiness each pixel should be.
  122812. */
  122813. useAutoMicroSurfaceFromReflectivityMap: boolean;
  122814. /**
  122815. * BJS is using an harcoded light falloff based on a manually sets up range.
  122816. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  122817. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  122818. */
  122819. get usePhysicalLightFalloff(): boolean;
  122820. /**
  122821. * BJS is using an harcoded light falloff based on a manually sets up range.
  122822. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  122823. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  122824. */
  122825. set usePhysicalLightFalloff(value: boolean);
  122826. /**
  122827. * In order to support the falloff compatibility with gltf, a special mode has been added
  122828. * to reproduce the gltf light falloff.
  122829. */
  122830. get useGLTFLightFalloff(): boolean;
  122831. /**
  122832. * In order to support the falloff compatibility with gltf, a special mode has been added
  122833. * to reproduce the gltf light falloff.
  122834. */
  122835. set useGLTFLightFalloff(value: boolean);
  122836. /**
  122837. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  122838. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  122839. */
  122840. useRadianceOverAlpha: boolean;
  122841. /**
  122842. * Allows using an object space normal map (instead of tangent space).
  122843. */
  122844. useObjectSpaceNormalMap: boolean;
  122845. /**
  122846. * Allows using the bump map in parallax mode.
  122847. */
  122848. useParallax: boolean;
  122849. /**
  122850. * Allows using the bump map in parallax occlusion mode.
  122851. */
  122852. useParallaxOcclusion: boolean;
  122853. /**
  122854. * Controls the scale bias of the parallax mode.
  122855. */
  122856. parallaxScaleBias: number;
  122857. /**
  122858. * If sets to true, disables all the lights affecting the material.
  122859. */
  122860. disableLighting: boolean;
  122861. /**
  122862. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  122863. */
  122864. forceIrradianceInFragment: boolean;
  122865. /**
  122866. * Number of Simultaneous lights allowed on the material.
  122867. */
  122868. maxSimultaneousLights: number;
  122869. /**
  122870. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  122871. */
  122872. invertNormalMapX: boolean;
  122873. /**
  122874. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  122875. */
  122876. invertNormalMapY: boolean;
  122877. /**
  122878. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  122879. */
  122880. twoSidedLighting: boolean;
  122881. /**
  122882. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  122883. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  122884. */
  122885. useAlphaFresnel: boolean;
  122886. /**
  122887. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  122888. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  122889. */
  122890. useLinearAlphaFresnel: boolean;
  122891. /**
  122892. * Let user defines the brdf lookup texture used for IBL.
  122893. * A default 8bit version is embedded but you could point at :
  122894. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  122895. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  122896. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  122897. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  122898. */
  122899. environmentBRDFTexture: Nullable<BaseTexture>;
  122900. /**
  122901. * Force normal to face away from face.
  122902. */
  122903. forceNormalForward: boolean;
  122904. /**
  122905. * Enables specular anti aliasing in the PBR shader.
  122906. * It will both interacts on the Geometry for analytical and IBL lighting.
  122907. * It also prefilter the roughness map based on the bump values.
  122908. */
  122909. enableSpecularAntiAliasing: boolean;
  122910. /**
  122911. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  122912. * makes the reflect vector face the model (under horizon).
  122913. */
  122914. useHorizonOcclusion: boolean;
  122915. /**
  122916. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  122917. * too much the area relying on ambient texture to define their ambient occlusion.
  122918. */
  122919. useRadianceOcclusion: boolean;
  122920. /**
  122921. * If set to true, no lighting calculations will be applied.
  122922. */
  122923. unlit: boolean;
  122924. /**
  122925. * Gets the image processing configuration used either in this material.
  122926. */
  122927. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  122928. /**
  122929. * Sets the Default image processing configuration used either in the this material.
  122930. *
  122931. * If sets to null, the scene one is in use.
  122932. */
  122933. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  122934. /**
  122935. * Gets wether the color curves effect is enabled.
  122936. */
  122937. get cameraColorCurvesEnabled(): boolean;
  122938. /**
  122939. * Sets wether the color curves effect is enabled.
  122940. */
  122941. set cameraColorCurvesEnabled(value: boolean);
  122942. /**
  122943. * Gets wether the color grading effect is enabled.
  122944. */
  122945. get cameraColorGradingEnabled(): boolean;
  122946. /**
  122947. * Gets wether the color grading effect is enabled.
  122948. */
  122949. set cameraColorGradingEnabled(value: boolean);
  122950. /**
  122951. * Gets wether tonemapping is enabled or not.
  122952. */
  122953. get cameraToneMappingEnabled(): boolean;
  122954. /**
  122955. * Sets wether tonemapping is enabled or not
  122956. */
  122957. set cameraToneMappingEnabled(value: boolean);
  122958. /**
  122959. * The camera exposure used on this material.
  122960. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122961. * This corresponds to a photographic exposure.
  122962. */
  122963. get cameraExposure(): number;
  122964. /**
  122965. * The camera exposure used on this material.
  122966. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122967. * This corresponds to a photographic exposure.
  122968. */
  122969. set cameraExposure(value: number);
  122970. /**
  122971. * Gets The camera contrast used on this material.
  122972. */
  122973. get cameraContrast(): number;
  122974. /**
  122975. * Sets The camera contrast used on this material.
  122976. */
  122977. set cameraContrast(value: number);
  122978. /**
  122979. * Gets the Color Grading 2D Lookup Texture.
  122980. */
  122981. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122982. /**
  122983. * Sets the Color Grading 2D Lookup Texture.
  122984. */
  122985. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122986. /**
  122987. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122988. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122989. * 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;
  122990. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122991. */
  122992. get cameraColorCurves(): Nullable<ColorCurves>;
  122993. /**
  122994. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122995. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122996. * 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;
  122997. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122998. */
  122999. set cameraColorCurves(value: Nullable<ColorCurves>);
  123000. /**
  123001. * Instantiates a new PBRMaterial instance.
  123002. *
  123003. * @param name The material name
  123004. * @param scene The scene the material will be use in.
  123005. */
  123006. constructor(name: string, scene: Scene);
  123007. /**
  123008. * Returns the name of this material class.
  123009. */
  123010. getClassName(): string;
  123011. /**
  123012. * Makes a duplicate of the current material.
  123013. * @param name - name to use for the new material.
  123014. */
  123015. clone(name: string): PBRMaterial;
  123016. /**
  123017. * Serializes this PBR Material.
  123018. * @returns - An object with the serialized material.
  123019. */
  123020. serialize(): any;
  123021. /**
  123022. * Parses a PBR Material from a serialized object.
  123023. * @param source - Serialized object.
  123024. * @param scene - BJS scene instance.
  123025. * @param rootUrl - url for the scene object
  123026. * @returns - PBRMaterial
  123027. */
  123028. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  123029. }
  123030. }
  123031. declare module BABYLON {
  123032. /**
  123033. * Direct draw surface info
  123034. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  123035. */
  123036. export interface DDSInfo {
  123037. /**
  123038. * Width of the texture
  123039. */
  123040. width: number;
  123041. /**
  123042. * Width of the texture
  123043. */
  123044. height: number;
  123045. /**
  123046. * Number of Mipmaps for the texture
  123047. * @see https://en.wikipedia.org/wiki/Mipmap
  123048. */
  123049. mipmapCount: number;
  123050. /**
  123051. * If the textures format is a known fourCC format
  123052. * @see https://www.fourcc.org/
  123053. */
  123054. isFourCC: boolean;
  123055. /**
  123056. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  123057. */
  123058. isRGB: boolean;
  123059. /**
  123060. * If the texture is a lumincance format
  123061. */
  123062. isLuminance: boolean;
  123063. /**
  123064. * If this is a cube texture
  123065. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  123066. */
  123067. isCube: boolean;
  123068. /**
  123069. * If the texture is a compressed format eg. FOURCC_DXT1
  123070. */
  123071. isCompressed: boolean;
  123072. /**
  123073. * The dxgiFormat of the texture
  123074. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  123075. */
  123076. dxgiFormat: number;
  123077. /**
  123078. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  123079. */
  123080. textureType: number;
  123081. /**
  123082. * Sphericle polynomial created for the dds texture
  123083. */
  123084. sphericalPolynomial?: SphericalPolynomial;
  123085. }
  123086. /**
  123087. * Class used to provide DDS decompression tools
  123088. */
  123089. export class DDSTools {
  123090. /**
  123091. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  123092. */
  123093. static StoreLODInAlphaChannel: boolean;
  123094. /**
  123095. * Gets DDS information from an array buffer
  123096. * @param arrayBuffer defines the array buffer to read data from
  123097. * @returns the DDS information
  123098. */
  123099. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  123100. private static _FloatView;
  123101. private static _Int32View;
  123102. private static _ToHalfFloat;
  123103. private static _FromHalfFloat;
  123104. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  123105. private static _GetHalfFloatRGBAArrayBuffer;
  123106. private static _GetFloatRGBAArrayBuffer;
  123107. private static _GetFloatAsUIntRGBAArrayBuffer;
  123108. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  123109. private static _GetRGBAArrayBuffer;
  123110. private static _ExtractLongWordOrder;
  123111. private static _GetRGBArrayBuffer;
  123112. private static _GetLuminanceArrayBuffer;
  123113. /**
  123114. * Uploads DDS Levels to a Babylon Texture
  123115. * @hidden
  123116. */
  123117. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  123118. }
  123119. interface ThinEngine {
  123120. /**
  123121. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  123122. * @param rootUrl defines the url where the file to load is located
  123123. * @param scene defines the current scene
  123124. * @param lodScale defines scale to apply to the mip map selection
  123125. * @param lodOffset defines offset to apply to the mip map selection
  123126. * @param onLoad defines an optional callback raised when the texture is loaded
  123127. * @param onError defines an optional callback raised if there is an issue to load the texture
  123128. * @param format defines the format of the data
  123129. * @param forcedExtension defines the extension to use to pick the right loader
  123130. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  123131. * @returns the cube texture as an InternalTexture
  123132. */
  123133. 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;
  123134. }
  123135. }
  123136. declare module BABYLON {
  123137. /**
  123138. * Implementation of the DDS Texture Loader.
  123139. * @hidden
  123140. */
  123141. export class _DDSTextureLoader implements IInternalTextureLoader {
  123142. /**
  123143. * Defines wether the loader supports cascade loading the different faces.
  123144. */
  123145. readonly supportCascades: boolean;
  123146. /**
  123147. * This returns if the loader support the current file information.
  123148. * @param extension defines the file extension of the file being loaded
  123149. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123150. * @param fallback defines the fallback internal texture if any
  123151. * @param isBase64 defines whether the texture is encoded as a base64
  123152. * @param isBuffer defines whether the texture data are stored as a buffer
  123153. * @returns true if the loader can load the specified file
  123154. */
  123155. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  123156. /**
  123157. * Transform the url before loading if required.
  123158. * @param rootUrl the url of the texture
  123159. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123160. * @returns the transformed texture
  123161. */
  123162. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  123163. /**
  123164. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  123165. * @param rootUrl the url of the texture
  123166. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123167. * @returns the fallback texture
  123168. */
  123169. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  123170. /**
  123171. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  123172. * @param data contains the texture data
  123173. * @param texture defines the BabylonJS internal texture
  123174. * @param createPolynomials will be true if polynomials have been requested
  123175. * @param onLoad defines the callback to trigger once the texture is ready
  123176. * @param onError defines the callback to trigger in case of error
  123177. */
  123178. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  123179. /**
  123180. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  123181. * @param data contains the texture data
  123182. * @param texture defines the BabylonJS internal texture
  123183. * @param callback defines the method to call once ready to upload
  123184. */
  123185. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  123186. }
  123187. }
  123188. declare module BABYLON {
  123189. /**
  123190. * Implementation of the ENV Texture Loader.
  123191. * @hidden
  123192. */
  123193. export class _ENVTextureLoader implements IInternalTextureLoader {
  123194. /**
  123195. * Defines wether the loader supports cascade loading the different faces.
  123196. */
  123197. readonly supportCascades: boolean;
  123198. /**
  123199. * This returns if the loader support the current file information.
  123200. * @param extension defines the file extension of the file being loaded
  123201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123202. * @param fallback defines the fallback internal texture if any
  123203. * @param isBase64 defines whether the texture is encoded as a base64
  123204. * @param isBuffer defines whether the texture data are stored as a buffer
  123205. * @returns true if the loader can load the specified file
  123206. */
  123207. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  123208. /**
  123209. * Transform the url before loading if required.
  123210. * @param rootUrl the url of the texture
  123211. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123212. * @returns the transformed texture
  123213. */
  123214. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  123215. /**
  123216. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  123217. * @param rootUrl the url of the texture
  123218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123219. * @returns the fallback texture
  123220. */
  123221. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  123222. /**
  123223. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  123224. * @param data contains the texture data
  123225. * @param texture defines the BabylonJS internal texture
  123226. * @param createPolynomials will be true if polynomials have been requested
  123227. * @param onLoad defines the callback to trigger once the texture is ready
  123228. * @param onError defines the callback to trigger in case of error
  123229. */
  123230. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  123231. /**
  123232. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  123233. * @param data contains the texture data
  123234. * @param texture defines the BabylonJS internal texture
  123235. * @param callback defines the method to call once ready to upload
  123236. */
  123237. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  123238. }
  123239. }
  123240. declare module BABYLON {
  123241. /**
  123242. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  123243. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  123244. */
  123245. export class KhronosTextureContainer {
  123246. /** contents of the KTX container file */
  123247. arrayBuffer: any;
  123248. private static HEADER_LEN;
  123249. private static COMPRESSED_2D;
  123250. private static COMPRESSED_3D;
  123251. private static TEX_2D;
  123252. private static TEX_3D;
  123253. /**
  123254. * Gets the openGL type
  123255. */
  123256. glType: number;
  123257. /**
  123258. * Gets the openGL type size
  123259. */
  123260. glTypeSize: number;
  123261. /**
  123262. * Gets the openGL format
  123263. */
  123264. glFormat: number;
  123265. /**
  123266. * Gets the openGL internal format
  123267. */
  123268. glInternalFormat: number;
  123269. /**
  123270. * Gets the base internal format
  123271. */
  123272. glBaseInternalFormat: number;
  123273. /**
  123274. * Gets image width in pixel
  123275. */
  123276. pixelWidth: number;
  123277. /**
  123278. * Gets image height in pixel
  123279. */
  123280. pixelHeight: number;
  123281. /**
  123282. * Gets image depth in pixels
  123283. */
  123284. pixelDepth: number;
  123285. /**
  123286. * Gets the number of array elements
  123287. */
  123288. numberOfArrayElements: number;
  123289. /**
  123290. * Gets the number of faces
  123291. */
  123292. numberOfFaces: number;
  123293. /**
  123294. * Gets the number of mipmap levels
  123295. */
  123296. numberOfMipmapLevels: number;
  123297. /**
  123298. * Gets the bytes of key value data
  123299. */
  123300. bytesOfKeyValueData: number;
  123301. /**
  123302. * Gets the load type
  123303. */
  123304. loadType: number;
  123305. /**
  123306. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  123307. */
  123308. isInvalid: boolean;
  123309. /**
  123310. * Creates a new KhronosTextureContainer
  123311. * @param arrayBuffer contents of the KTX container file
  123312. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  123313. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  123314. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  123315. */
  123316. constructor(
  123317. /** contents of the KTX container file */
  123318. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  123319. /**
  123320. * Uploads KTX content to a Babylon Texture.
  123321. * It is assumed that the texture has already been created & is currently bound
  123322. * @hidden
  123323. */
  123324. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  123325. private _upload2DCompressedLevels;
  123326. }
  123327. }
  123328. declare module BABYLON {
  123329. /**
  123330. * Implementation of the KTX Texture Loader.
  123331. * @hidden
  123332. */
  123333. export class _KTXTextureLoader implements IInternalTextureLoader {
  123334. /**
  123335. * Defines wether the loader supports cascade loading the different faces.
  123336. */
  123337. readonly supportCascades: boolean;
  123338. /**
  123339. * This returns if the loader support the current file information.
  123340. * @param extension defines the file extension of the file being loaded
  123341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123342. * @param fallback defines the fallback internal texture if any
  123343. * @param isBase64 defines whether the texture is encoded as a base64
  123344. * @param isBuffer defines whether the texture data are stored as a buffer
  123345. * @returns true if the loader can load the specified file
  123346. */
  123347. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  123348. /**
  123349. * Transform the url before loading if required.
  123350. * @param rootUrl the url of the texture
  123351. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123352. * @returns the transformed texture
  123353. */
  123354. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  123355. /**
  123356. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  123357. * @param rootUrl the url of the texture
  123358. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123359. * @returns the fallback texture
  123360. */
  123361. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  123362. /**
  123363. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  123364. * @param data contains the texture data
  123365. * @param texture defines the BabylonJS internal texture
  123366. * @param createPolynomials will be true if polynomials have been requested
  123367. * @param onLoad defines the callback to trigger once the texture is ready
  123368. * @param onError defines the callback to trigger in case of error
  123369. */
  123370. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  123371. /**
  123372. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  123373. * @param data contains the texture data
  123374. * @param texture defines the BabylonJS internal texture
  123375. * @param callback defines the method to call once ready to upload
  123376. */
  123377. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  123378. }
  123379. }
  123380. declare module BABYLON {
  123381. /** @hidden */
  123382. export var _forceSceneHelpersToBundle: boolean;
  123383. interface Scene {
  123384. /**
  123385. * Creates a default light for the scene.
  123386. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  123387. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  123388. */
  123389. createDefaultLight(replace?: boolean): void;
  123390. /**
  123391. * Creates a default camera for the scene.
  123392. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  123393. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  123394. * @param replace has default false, when true replaces the active camera in the scene
  123395. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  123396. */
  123397. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  123398. /**
  123399. * Creates a default camera and a default light.
  123400. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  123401. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  123402. * @param replace has the default false, when true replaces the active camera/light in the scene
  123403. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  123404. */
  123405. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  123406. /**
  123407. * Creates a new sky box
  123408. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  123409. * @param environmentTexture defines the texture to use as environment texture
  123410. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  123411. * @param scale defines the overall scale of the skybox
  123412. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  123413. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  123414. * @returns a new mesh holding the sky box
  123415. */
  123416. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  123417. /**
  123418. * Creates a new environment
  123419. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  123420. * @param options defines the options you can use to configure the environment
  123421. * @returns the new EnvironmentHelper
  123422. */
  123423. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  123424. /**
  123425. * Creates a new VREXperienceHelper
  123426. * @see http://doc.babylonjs.com/how_to/webvr_helper
  123427. * @param webVROptions defines the options used to create the new VREXperienceHelper
  123428. * @returns a new VREXperienceHelper
  123429. */
  123430. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  123431. /**
  123432. * Creates a new WebXRDefaultExperience
  123433. * @see http://doc.babylonjs.com/how_to/webxr
  123434. * @param options experience options
  123435. * @returns a promise for a new WebXRDefaultExperience
  123436. */
  123437. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  123438. }
  123439. }
  123440. declare module BABYLON {
  123441. /**
  123442. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  123443. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  123444. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  123445. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123446. */
  123447. export class VideoDome extends TransformNode {
  123448. /**
  123449. * Define the video source as a Monoscopic panoramic 360 video.
  123450. */
  123451. static readonly MODE_MONOSCOPIC: number;
  123452. /**
  123453. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  123454. */
  123455. static readonly MODE_TOPBOTTOM: number;
  123456. /**
  123457. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  123458. */
  123459. static readonly MODE_SIDEBYSIDE: number;
  123460. private _halfDome;
  123461. private _useDirectMapping;
  123462. /**
  123463. * The video texture being displayed on the sphere
  123464. */
  123465. protected _videoTexture: VideoTexture;
  123466. /**
  123467. * Gets the video texture being displayed on the sphere
  123468. */
  123469. get videoTexture(): VideoTexture;
  123470. /**
  123471. * The skybox material
  123472. */
  123473. protected _material: BackgroundMaterial;
  123474. /**
  123475. * The surface used for the skybox
  123476. */
  123477. protected _mesh: Mesh;
  123478. /**
  123479. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  123480. */
  123481. private _halfDomeMask;
  123482. /**
  123483. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123484. * Also see the options.resolution property.
  123485. */
  123486. get fovMultiplier(): number;
  123487. set fovMultiplier(value: number);
  123488. private _videoMode;
  123489. /**
  123490. * Gets or set the current video mode for the video. It can be:
  123491. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  123492. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  123493. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  123494. */
  123495. get videoMode(): number;
  123496. set videoMode(value: number);
  123497. /**
  123498. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  123499. *
  123500. */
  123501. get halfDome(): boolean;
  123502. /**
  123503. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  123504. */
  123505. set halfDome(enabled: boolean);
  123506. /**
  123507. * Oberserver used in Stereoscopic VR Mode.
  123508. */
  123509. private _onBeforeCameraRenderObserver;
  123510. /**
  123511. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  123512. * @param name Element's name, child elements will append suffixes for their own names.
  123513. * @param urlsOrVideo defines the url(s) or the video element to use
  123514. * @param options An object containing optional or exposed sub element properties
  123515. */
  123516. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  123517. resolution?: number;
  123518. clickToPlay?: boolean;
  123519. autoPlay?: boolean;
  123520. loop?: boolean;
  123521. size?: number;
  123522. poster?: string;
  123523. faceForward?: boolean;
  123524. useDirectMapping?: boolean;
  123525. halfDomeMode?: boolean;
  123526. }, scene: Scene);
  123527. private _changeVideoMode;
  123528. /**
  123529. * Releases resources associated with this node.
  123530. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123531. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123532. */
  123533. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123534. }
  123535. }
  123536. declare module BABYLON {
  123537. /**
  123538. * This class can be used to get instrumentation data from a Babylon engine
  123539. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  123540. */
  123541. export class EngineInstrumentation implements IDisposable {
  123542. /**
  123543. * Define the instrumented engine.
  123544. */
  123545. engine: Engine;
  123546. private _captureGPUFrameTime;
  123547. private _gpuFrameTimeToken;
  123548. private _gpuFrameTime;
  123549. private _captureShaderCompilationTime;
  123550. private _shaderCompilationTime;
  123551. private _onBeginFrameObserver;
  123552. private _onEndFrameObserver;
  123553. private _onBeforeShaderCompilationObserver;
  123554. private _onAfterShaderCompilationObserver;
  123555. /**
  123556. * Gets the perf counter used for GPU frame time
  123557. */
  123558. get gpuFrameTimeCounter(): PerfCounter;
  123559. /**
  123560. * Gets the GPU frame time capture status
  123561. */
  123562. get captureGPUFrameTime(): boolean;
  123563. /**
  123564. * Enable or disable the GPU frame time capture
  123565. */
  123566. set captureGPUFrameTime(value: boolean);
  123567. /**
  123568. * Gets the perf counter used for shader compilation time
  123569. */
  123570. get shaderCompilationTimeCounter(): PerfCounter;
  123571. /**
  123572. * Gets the shader compilation time capture status
  123573. */
  123574. get captureShaderCompilationTime(): boolean;
  123575. /**
  123576. * Enable or disable the shader compilation time capture
  123577. */
  123578. set captureShaderCompilationTime(value: boolean);
  123579. /**
  123580. * Instantiates a new engine instrumentation.
  123581. * This class can be used to get instrumentation data from a Babylon engine
  123582. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  123583. * @param engine Defines the engine to instrument
  123584. */
  123585. constructor(
  123586. /**
  123587. * Define the instrumented engine.
  123588. */
  123589. engine: Engine);
  123590. /**
  123591. * Dispose and release associated resources.
  123592. */
  123593. dispose(): void;
  123594. }
  123595. }
  123596. declare module BABYLON {
  123597. /**
  123598. * This class can be used to get instrumentation data from a Babylon engine
  123599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  123600. */
  123601. export class SceneInstrumentation implements IDisposable {
  123602. /**
  123603. * Defines the scene to instrument
  123604. */
  123605. scene: Scene;
  123606. private _captureActiveMeshesEvaluationTime;
  123607. private _activeMeshesEvaluationTime;
  123608. private _captureRenderTargetsRenderTime;
  123609. private _renderTargetsRenderTime;
  123610. private _captureFrameTime;
  123611. private _frameTime;
  123612. private _captureRenderTime;
  123613. private _renderTime;
  123614. private _captureInterFrameTime;
  123615. private _interFrameTime;
  123616. private _captureParticlesRenderTime;
  123617. private _particlesRenderTime;
  123618. private _captureSpritesRenderTime;
  123619. private _spritesRenderTime;
  123620. private _capturePhysicsTime;
  123621. private _physicsTime;
  123622. private _captureAnimationsTime;
  123623. private _animationsTime;
  123624. private _captureCameraRenderTime;
  123625. private _cameraRenderTime;
  123626. private _onBeforeActiveMeshesEvaluationObserver;
  123627. private _onAfterActiveMeshesEvaluationObserver;
  123628. private _onBeforeRenderTargetsRenderObserver;
  123629. private _onAfterRenderTargetsRenderObserver;
  123630. private _onAfterRenderObserver;
  123631. private _onBeforeDrawPhaseObserver;
  123632. private _onAfterDrawPhaseObserver;
  123633. private _onBeforeAnimationsObserver;
  123634. private _onBeforeParticlesRenderingObserver;
  123635. private _onAfterParticlesRenderingObserver;
  123636. private _onBeforeSpritesRenderingObserver;
  123637. private _onAfterSpritesRenderingObserver;
  123638. private _onBeforePhysicsObserver;
  123639. private _onAfterPhysicsObserver;
  123640. private _onAfterAnimationsObserver;
  123641. private _onBeforeCameraRenderObserver;
  123642. private _onAfterCameraRenderObserver;
  123643. /**
  123644. * Gets the perf counter used for active meshes evaluation time
  123645. */
  123646. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  123647. /**
  123648. * Gets the active meshes evaluation time capture status
  123649. */
  123650. get captureActiveMeshesEvaluationTime(): boolean;
  123651. /**
  123652. * Enable or disable the active meshes evaluation time capture
  123653. */
  123654. set captureActiveMeshesEvaluationTime(value: boolean);
  123655. /**
  123656. * Gets the perf counter used for render targets render time
  123657. */
  123658. get renderTargetsRenderTimeCounter(): PerfCounter;
  123659. /**
  123660. * Gets the render targets render time capture status
  123661. */
  123662. get captureRenderTargetsRenderTime(): boolean;
  123663. /**
  123664. * Enable or disable the render targets render time capture
  123665. */
  123666. set captureRenderTargetsRenderTime(value: boolean);
  123667. /**
  123668. * Gets the perf counter used for particles render time
  123669. */
  123670. get particlesRenderTimeCounter(): PerfCounter;
  123671. /**
  123672. * Gets the particles render time capture status
  123673. */
  123674. get captureParticlesRenderTime(): boolean;
  123675. /**
  123676. * Enable or disable the particles render time capture
  123677. */
  123678. set captureParticlesRenderTime(value: boolean);
  123679. /**
  123680. * Gets the perf counter used for sprites render time
  123681. */
  123682. get spritesRenderTimeCounter(): PerfCounter;
  123683. /**
  123684. * Gets the sprites render time capture status
  123685. */
  123686. get captureSpritesRenderTime(): boolean;
  123687. /**
  123688. * Enable or disable the sprites render time capture
  123689. */
  123690. set captureSpritesRenderTime(value: boolean);
  123691. /**
  123692. * Gets the perf counter used for physics time
  123693. */
  123694. get physicsTimeCounter(): PerfCounter;
  123695. /**
  123696. * Gets the physics time capture status
  123697. */
  123698. get capturePhysicsTime(): boolean;
  123699. /**
  123700. * Enable or disable the physics time capture
  123701. */
  123702. set capturePhysicsTime(value: boolean);
  123703. /**
  123704. * Gets the perf counter used for animations time
  123705. */
  123706. get animationsTimeCounter(): PerfCounter;
  123707. /**
  123708. * Gets the animations time capture status
  123709. */
  123710. get captureAnimationsTime(): boolean;
  123711. /**
  123712. * Enable or disable the animations time capture
  123713. */
  123714. set captureAnimationsTime(value: boolean);
  123715. /**
  123716. * Gets the perf counter used for frame time capture
  123717. */
  123718. get frameTimeCounter(): PerfCounter;
  123719. /**
  123720. * Gets the frame time capture status
  123721. */
  123722. get captureFrameTime(): boolean;
  123723. /**
  123724. * Enable or disable the frame time capture
  123725. */
  123726. set captureFrameTime(value: boolean);
  123727. /**
  123728. * Gets the perf counter used for inter-frames time capture
  123729. */
  123730. get interFrameTimeCounter(): PerfCounter;
  123731. /**
  123732. * Gets the inter-frames time capture status
  123733. */
  123734. get captureInterFrameTime(): boolean;
  123735. /**
  123736. * Enable or disable the inter-frames time capture
  123737. */
  123738. set captureInterFrameTime(value: boolean);
  123739. /**
  123740. * Gets the perf counter used for render time capture
  123741. */
  123742. get renderTimeCounter(): PerfCounter;
  123743. /**
  123744. * Gets the render time capture status
  123745. */
  123746. get captureRenderTime(): boolean;
  123747. /**
  123748. * Enable or disable the render time capture
  123749. */
  123750. set captureRenderTime(value: boolean);
  123751. /**
  123752. * Gets the perf counter used for camera render time capture
  123753. */
  123754. get cameraRenderTimeCounter(): PerfCounter;
  123755. /**
  123756. * Gets the camera render time capture status
  123757. */
  123758. get captureCameraRenderTime(): boolean;
  123759. /**
  123760. * Enable or disable the camera render time capture
  123761. */
  123762. set captureCameraRenderTime(value: boolean);
  123763. /**
  123764. * Gets the perf counter used for draw calls
  123765. */
  123766. get drawCallsCounter(): PerfCounter;
  123767. /**
  123768. * Instantiates a new scene instrumentation.
  123769. * This class can be used to get instrumentation data from a Babylon engine
  123770. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  123771. * @param scene Defines the scene to instrument
  123772. */
  123773. constructor(
  123774. /**
  123775. * Defines the scene to instrument
  123776. */
  123777. scene: Scene);
  123778. /**
  123779. * Dispose and release associated resources.
  123780. */
  123781. dispose(): void;
  123782. }
  123783. }
  123784. declare module BABYLON {
  123785. /** @hidden */
  123786. export var glowMapGenerationPixelShader: {
  123787. name: string;
  123788. shader: string;
  123789. };
  123790. }
  123791. declare module BABYLON {
  123792. /** @hidden */
  123793. export var glowMapGenerationVertexShader: {
  123794. name: string;
  123795. shader: string;
  123796. };
  123797. }
  123798. declare module BABYLON {
  123799. /**
  123800. * Effect layer options. This helps customizing the behaviour
  123801. * of the effect layer.
  123802. */
  123803. export interface IEffectLayerOptions {
  123804. /**
  123805. * Multiplication factor apply to the canvas size to compute the render target size
  123806. * used to generated the objects (the smaller the faster).
  123807. */
  123808. mainTextureRatio: number;
  123809. /**
  123810. * Enforces a fixed size texture to ensure effect stability across devices.
  123811. */
  123812. mainTextureFixedSize?: number;
  123813. /**
  123814. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  123815. */
  123816. alphaBlendingMode: number;
  123817. /**
  123818. * The camera attached to the layer.
  123819. */
  123820. camera: Nullable<Camera>;
  123821. /**
  123822. * The rendering group to draw the layer in.
  123823. */
  123824. renderingGroupId: number;
  123825. }
  123826. /**
  123827. * The effect layer Helps adding post process effect blended with the main pass.
  123828. *
  123829. * This can be for instance use to generate glow or higlight effects on the scene.
  123830. *
  123831. * The effect layer class can not be used directly and is intented to inherited from to be
  123832. * customized per effects.
  123833. */
  123834. export abstract class EffectLayer {
  123835. private _vertexBuffers;
  123836. private _indexBuffer;
  123837. private _cachedDefines;
  123838. private _effectLayerMapGenerationEffect;
  123839. private _effectLayerOptions;
  123840. private _mergeEffect;
  123841. protected _scene: Scene;
  123842. protected _engine: Engine;
  123843. protected _maxSize: number;
  123844. protected _mainTextureDesiredSize: ISize;
  123845. protected _mainTexture: RenderTargetTexture;
  123846. protected _shouldRender: boolean;
  123847. protected _postProcesses: PostProcess[];
  123848. protected _textures: BaseTexture[];
  123849. protected _emissiveTextureAndColor: {
  123850. texture: Nullable<BaseTexture>;
  123851. color: Color4;
  123852. };
  123853. /**
  123854. * The name of the layer
  123855. */
  123856. name: string;
  123857. /**
  123858. * The clear color of the texture used to generate the glow map.
  123859. */
  123860. neutralColor: Color4;
  123861. /**
  123862. * Specifies wether the highlight layer is enabled or not.
  123863. */
  123864. isEnabled: boolean;
  123865. /**
  123866. * Gets the camera attached to the layer.
  123867. */
  123868. get camera(): Nullable<Camera>;
  123869. /**
  123870. * Gets the rendering group id the layer should render in.
  123871. */
  123872. get renderingGroupId(): number;
  123873. set renderingGroupId(renderingGroupId: number);
  123874. /**
  123875. * An event triggered when the effect layer has been disposed.
  123876. */
  123877. onDisposeObservable: Observable<EffectLayer>;
  123878. /**
  123879. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  123880. */
  123881. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  123882. /**
  123883. * An event triggered when the generated texture is being merged in the scene.
  123884. */
  123885. onBeforeComposeObservable: Observable<EffectLayer>;
  123886. /**
  123887. * An event triggered when the mesh is rendered into the effect render target.
  123888. */
  123889. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  123890. /**
  123891. * An event triggered after the mesh has been rendered into the effect render target.
  123892. */
  123893. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  123894. /**
  123895. * An event triggered when the generated texture has been merged in the scene.
  123896. */
  123897. onAfterComposeObservable: Observable<EffectLayer>;
  123898. /**
  123899. * An event triggered when the efffect layer changes its size.
  123900. */
  123901. onSizeChangedObservable: Observable<EffectLayer>;
  123902. /** @hidden */
  123903. static _SceneComponentInitialization: (scene: Scene) => void;
  123904. /**
  123905. * Instantiates a new effect Layer and references it in the scene.
  123906. * @param name The name of the layer
  123907. * @param scene The scene to use the layer in
  123908. */
  123909. constructor(
  123910. /** The Friendly of the effect in the scene */
  123911. name: string, scene: Scene);
  123912. /**
  123913. * Get the effect name of the layer.
  123914. * @return The effect name
  123915. */
  123916. abstract getEffectName(): string;
  123917. /**
  123918. * Checks for the readiness of the element composing the layer.
  123919. * @param subMesh the mesh to check for
  123920. * @param useInstances specify wether or not to use instances to render the mesh
  123921. * @return true if ready otherwise, false
  123922. */
  123923. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123924. /**
  123925. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  123926. * @returns true if the effect requires stencil during the main canvas render pass.
  123927. */
  123928. abstract needStencil(): boolean;
  123929. /**
  123930. * Create the merge effect. This is the shader use to blit the information back
  123931. * to the main canvas at the end of the scene rendering.
  123932. * @returns The effect containing the shader used to merge the effect on the main canvas
  123933. */
  123934. protected abstract _createMergeEffect(): Effect;
  123935. /**
  123936. * Creates the render target textures and post processes used in the effect layer.
  123937. */
  123938. protected abstract _createTextureAndPostProcesses(): void;
  123939. /**
  123940. * Implementation specific of rendering the generating effect on the main canvas.
  123941. * @param effect The effect used to render through
  123942. */
  123943. protected abstract _internalRender(effect: Effect): void;
  123944. /**
  123945. * Sets the required values for both the emissive texture and and the main color.
  123946. */
  123947. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  123948. /**
  123949. * Free any resources and references associated to a mesh.
  123950. * Internal use
  123951. * @param mesh The mesh to free.
  123952. */
  123953. abstract _disposeMesh(mesh: Mesh): void;
  123954. /**
  123955. * Serializes this layer (Glow or Highlight for example)
  123956. * @returns a serialized layer object
  123957. */
  123958. abstract serialize?(): any;
  123959. /**
  123960. * Initializes the effect layer with the required options.
  123961. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  123962. */
  123963. protected _init(options: Partial<IEffectLayerOptions>): void;
  123964. /**
  123965. * Generates the index buffer of the full screen quad blending to the main canvas.
  123966. */
  123967. private _generateIndexBuffer;
  123968. /**
  123969. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  123970. */
  123971. private _generateVertexBuffer;
  123972. /**
  123973. * Sets the main texture desired size which is the closest power of two
  123974. * of the engine canvas size.
  123975. */
  123976. private _setMainTextureSize;
  123977. /**
  123978. * Creates the main texture for the effect layer.
  123979. */
  123980. protected _createMainTexture(): void;
  123981. /**
  123982. * Adds specific effects defines.
  123983. * @param defines The defines to add specifics to.
  123984. */
  123985. protected _addCustomEffectDefines(defines: string[]): void;
  123986. /**
  123987. * Checks for the readiness of the element composing the layer.
  123988. * @param subMesh the mesh to check for
  123989. * @param useInstances specify wether or not to use instances to render the mesh
  123990. * @param emissiveTexture the associated emissive texture used to generate the glow
  123991. * @return true if ready otherwise, false
  123992. */
  123993. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  123994. /**
  123995. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  123996. */
  123997. render(): void;
  123998. /**
  123999. * Determine if a given mesh will be used in the current effect.
  124000. * @param mesh mesh to test
  124001. * @returns true if the mesh will be used
  124002. */
  124003. hasMesh(mesh: AbstractMesh): boolean;
  124004. /**
  124005. * Returns true if the layer contains information to display, otherwise false.
  124006. * @returns true if the glow layer should be rendered
  124007. */
  124008. shouldRender(): boolean;
  124009. /**
  124010. * Returns true if the mesh should render, otherwise false.
  124011. * @param mesh The mesh to render
  124012. * @returns true if it should render otherwise false
  124013. */
  124014. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  124015. /**
  124016. * Returns true if the mesh can be rendered, otherwise false.
  124017. * @param mesh The mesh to render
  124018. * @param material The material used on the mesh
  124019. * @returns true if it can be rendered otherwise false
  124020. */
  124021. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  124022. /**
  124023. * Returns true if the mesh should render, otherwise false.
  124024. * @param mesh The mesh to render
  124025. * @returns true if it should render otherwise false
  124026. */
  124027. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  124028. /**
  124029. * Renders the submesh passed in parameter to the generation map.
  124030. */
  124031. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  124032. /**
  124033. * Defines wether the current material of the mesh should be use to render the effect.
  124034. * @param mesh defines the current mesh to render
  124035. */
  124036. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  124037. /**
  124038. * Rebuild the required buffers.
  124039. * @hidden Internal use only.
  124040. */
  124041. _rebuild(): void;
  124042. /**
  124043. * Dispose only the render target textures and post process.
  124044. */
  124045. private _disposeTextureAndPostProcesses;
  124046. /**
  124047. * Dispose the highlight layer and free resources.
  124048. */
  124049. dispose(): void;
  124050. /**
  124051. * Gets the class name of the effect layer
  124052. * @returns the string with the class name of the effect layer
  124053. */
  124054. getClassName(): string;
  124055. /**
  124056. * Creates an effect layer from parsed effect layer data
  124057. * @param parsedEffectLayer defines effect layer data
  124058. * @param scene defines the current scene
  124059. * @param rootUrl defines the root URL containing the effect layer information
  124060. * @returns a parsed effect Layer
  124061. */
  124062. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  124063. }
  124064. }
  124065. declare module BABYLON {
  124066. interface AbstractScene {
  124067. /**
  124068. * The list of effect layers (highlights/glow) added to the scene
  124069. * @see http://doc.babylonjs.com/how_to/highlight_layer
  124070. * @see http://doc.babylonjs.com/how_to/glow_layer
  124071. */
  124072. effectLayers: Array<EffectLayer>;
  124073. /**
  124074. * Removes the given effect layer from this scene.
  124075. * @param toRemove defines the effect layer to remove
  124076. * @returns the index of the removed effect layer
  124077. */
  124078. removeEffectLayer(toRemove: EffectLayer): number;
  124079. /**
  124080. * Adds the given effect layer to this scene
  124081. * @param newEffectLayer defines the effect layer to add
  124082. */
  124083. addEffectLayer(newEffectLayer: EffectLayer): void;
  124084. }
  124085. /**
  124086. * Defines the layer scene component responsible to manage any effect layers
  124087. * in a given scene.
  124088. */
  124089. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  124090. /**
  124091. * The component name helpfull to identify the component in the list of scene components.
  124092. */
  124093. readonly name: string;
  124094. /**
  124095. * The scene the component belongs to.
  124096. */
  124097. scene: Scene;
  124098. private _engine;
  124099. private _renderEffects;
  124100. private _needStencil;
  124101. private _previousStencilState;
  124102. /**
  124103. * Creates a new instance of the component for the given scene
  124104. * @param scene Defines the scene to register the component in
  124105. */
  124106. constructor(scene: Scene);
  124107. /**
  124108. * Registers the component in a given scene
  124109. */
  124110. register(): void;
  124111. /**
  124112. * Rebuilds the elements related to this component in case of
  124113. * context lost for instance.
  124114. */
  124115. rebuild(): void;
  124116. /**
  124117. * Serializes the component data to the specified json object
  124118. * @param serializationObject The object to serialize to
  124119. */
  124120. serialize(serializationObject: any): void;
  124121. /**
  124122. * Adds all the elements from the container to the scene
  124123. * @param container the container holding the elements
  124124. */
  124125. addFromContainer(container: AbstractScene): void;
  124126. /**
  124127. * Removes all the elements in the container from the scene
  124128. * @param container contains the elements to remove
  124129. * @param dispose if the removed element should be disposed (default: false)
  124130. */
  124131. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  124132. /**
  124133. * Disposes the component and the associated ressources.
  124134. */
  124135. dispose(): void;
  124136. private _isReadyForMesh;
  124137. private _renderMainTexture;
  124138. private _setStencil;
  124139. private _setStencilBack;
  124140. private _draw;
  124141. private _drawCamera;
  124142. private _drawRenderingGroup;
  124143. }
  124144. }
  124145. declare module BABYLON {
  124146. /** @hidden */
  124147. export var glowMapMergePixelShader: {
  124148. name: string;
  124149. shader: string;
  124150. };
  124151. }
  124152. declare module BABYLON {
  124153. /** @hidden */
  124154. export var glowMapMergeVertexShader: {
  124155. name: string;
  124156. shader: string;
  124157. };
  124158. }
  124159. declare module BABYLON {
  124160. interface AbstractScene {
  124161. /**
  124162. * Return a the first highlight layer of the scene with a given name.
  124163. * @param name The name of the highlight layer to look for.
  124164. * @return The highlight layer if found otherwise null.
  124165. */
  124166. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  124167. }
  124168. /**
  124169. * Glow layer options. This helps customizing the behaviour
  124170. * of the glow layer.
  124171. */
  124172. export interface IGlowLayerOptions {
  124173. /**
  124174. * Multiplication factor apply to the canvas size to compute the render target size
  124175. * used to generated the glowing objects (the smaller the faster).
  124176. */
  124177. mainTextureRatio: number;
  124178. /**
  124179. * Enforces a fixed size texture to ensure resize independant blur.
  124180. */
  124181. mainTextureFixedSize?: number;
  124182. /**
  124183. * How big is the kernel of the blur texture.
  124184. */
  124185. blurKernelSize: number;
  124186. /**
  124187. * The camera attached to the layer.
  124188. */
  124189. camera: Nullable<Camera>;
  124190. /**
  124191. * Enable MSAA by chosing the number of samples.
  124192. */
  124193. mainTextureSamples?: number;
  124194. /**
  124195. * The rendering group to draw the layer in.
  124196. */
  124197. renderingGroupId: number;
  124198. }
  124199. /**
  124200. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  124201. *
  124202. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  124203. *
  124204. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  124205. */
  124206. export class GlowLayer extends EffectLayer {
  124207. /**
  124208. * Effect Name of the layer.
  124209. */
  124210. static readonly EffectName: string;
  124211. /**
  124212. * The default blur kernel size used for the glow.
  124213. */
  124214. static DefaultBlurKernelSize: number;
  124215. /**
  124216. * The default texture size ratio used for the glow.
  124217. */
  124218. static DefaultTextureRatio: number;
  124219. /**
  124220. * Sets the kernel size of the blur.
  124221. */
  124222. set blurKernelSize(value: number);
  124223. /**
  124224. * Gets the kernel size of the blur.
  124225. */
  124226. get blurKernelSize(): number;
  124227. /**
  124228. * Sets the glow intensity.
  124229. */
  124230. set intensity(value: number);
  124231. /**
  124232. * Gets the glow intensity.
  124233. */
  124234. get intensity(): number;
  124235. private _options;
  124236. private _intensity;
  124237. private _horizontalBlurPostprocess1;
  124238. private _verticalBlurPostprocess1;
  124239. private _horizontalBlurPostprocess2;
  124240. private _verticalBlurPostprocess2;
  124241. private _blurTexture1;
  124242. private _blurTexture2;
  124243. private _postProcesses1;
  124244. private _postProcesses2;
  124245. private _includedOnlyMeshes;
  124246. private _excludedMeshes;
  124247. private _meshesUsingTheirOwnMaterials;
  124248. /**
  124249. * Callback used to let the user override the color selection on a per mesh basis
  124250. */
  124251. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  124252. /**
  124253. * Callback used to let the user override the texture selection on a per mesh basis
  124254. */
  124255. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  124256. /**
  124257. * Instantiates a new glow Layer and references it to the scene.
  124258. * @param name The name of the layer
  124259. * @param scene The scene to use the layer in
  124260. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  124261. */
  124262. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  124263. /**
  124264. * Get the effect name of the layer.
  124265. * @return The effect name
  124266. */
  124267. getEffectName(): string;
  124268. /**
  124269. * Create the merge effect. This is the shader use to blit the information back
  124270. * to the main canvas at the end of the scene rendering.
  124271. */
  124272. protected _createMergeEffect(): Effect;
  124273. /**
  124274. * Creates the render target textures and post processes used in the glow layer.
  124275. */
  124276. protected _createTextureAndPostProcesses(): void;
  124277. /**
  124278. * Checks for the readiness of the element composing the layer.
  124279. * @param subMesh the mesh to check for
  124280. * @param useInstances specify wether or not to use instances to render the mesh
  124281. * @param emissiveTexture the associated emissive texture used to generate the glow
  124282. * @return true if ready otherwise, false
  124283. */
  124284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124285. /**
  124286. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  124287. */
  124288. needStencil(): boolean;
  124289. /**
  124290. * Returns true if the mesh can be rendered, otherwise false.
  124291. * @param mesh The mesh to render
  124292. * @param material The material used on the mesh
  124293. * @returns true if it can be rendered otherwise false
  124294. */
  124295. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  124296. /**
  124297. * Implementation specific of rendering the generating effect on the main canvas.
  124298. * @param effect The effect used to render through
  124299. */
  124300. protected _internalRender(effect: Effect): void;
  124301. /**
  124302. * Sets the required values for both the emissive texture and and the main color.
  124303. */
  124304. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  124305. /**
  124306. * Returns true if the mesh should render, otherwise false.
  124307. * @param mesh The mesh to render
  124308. * @returns true if it should render otherwise false
  124309. */
  124310. protected _shouldRenderMesh(mesh: Mesh): boolean;
  124311. /**
  124312. * Adds specific effects defines.
  124313. * @param defines The defines to add specifics to.
  124314. */
  124315. protected _addCustomEffectDefines(defines: string[]): void;
  124316. /**
  124317. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  124318. * @param mesh The mesh to exclude from the glow layer
  124319. */
  124320. addExcludedMesh(mesh: Mesh): void;
  124321. /**
  124322. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  124323. * @param mesh The mesh to remove
  124324. */
  124325. removeExcludedMesh(mesh: Mesh): void;
  124326. /**
  124327. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  124328. * @param mesh The mesh to include in the glow layer
  124329. */
  124330. addIncludedOnlyMesh(mesh: Mesh): void;
  124331. /**
  124332. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  124333. * @param mesh The mesh to remove
  124334. */
  124335. removeIncludedOnlyMesh(mesh: Mesh): void;
  124336. /**
  124337. * Determine if a given mesh will be used in the glow layer
  124338. * @param mesh The mesh to test
  124339. * @returns true if the mesh will be highlighted by the current glow layer
  124340. */
  124341. hasMesh(mesh: AbstractMesh): boolean;
  124342. /**
  124343. * Defines wether the current material of the mesh should be use to render the effect.
  124344. * @param mesh defines the current mesh to render
  124345. */
  124346. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  124347. /**
  124348. * Add a mesh to be rendered through its own material and not with emissive only.
  124349. * @param mesh The mesh for which we need to use its material
  124350. */
  124351. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  124352. /**
  124353. * Remove a mesh from being rendered through its own material and not with emissive only.
  124354. * @param mesh The mesh for which we need to not use its material
  124355. */
  124356. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  124357. /**
  124358. * Free any resources and references associated to a mesh.
  124359. * Internal use
  124360. * @param mesh The mesh to free.
  124361. * @hidden
  124362. */
  124363. _disposeMesh(mesh: Mesh): void;
  124364. /**
  124365. * Gets the class name of the effect layer
  124366. * @returns the string with the class name of the effect layer
  124367. */
  124368. getClassName(): string;
  124369. /**
  124370. * Serializes this glow layer
  124371. * @returns a serialized glow layer object
  124372. */
  124373. serialize(): any;
  124374. /**
  124375. * Creates a Glow Layer from parsed glow layer data
  124376. * @param parsedGlowLayer defines glow layer data
  124377. * @param scene defines the current scene
  124378. * @param rootUrl defines the root URL containing the glow layer information
  124379. * @returns a parsed Glow Layer
  124380. */
  124381. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  124382. }
  124383. }
  124384. declare module BABYLON {
  124385. /** @hidden */
  124386. export var glowBlurPostProcessPixelShader: {
  124387. name: string;
  124388. shader: string;
  124389. };
  124390. }
  124391. declare module BABYLON {
  124392. interface AbstractScene {
  124393. /**
  124394. * Return a the first highlight layer of the scene with a given name.
  124395. * @param name The name of the highlight layer to look for.
  124396. * @return The highlight layer if found otherwise null.
  124397. */
  124398. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  124399. }
  124400. /**
  124401. * Highlight layer options. This helps customizing the behaviour
  124402. * of the highlight layer.
  124403. */
  124404. export interface IHighlightLayerOptions {
  124405. /**
  124406. * Multiplication factor apply to the canvas size to compute the render target size
  124407. * used to generated the glowing objects (the smaller the faster).
  124408. */
  124409. mainTextureRatio: number;
  124410. /**
  124411. * Enforces a fixed size texture to ensure resize independant blur.
  124412. */
  124413. mainTextureFixedSize?: number;
  124414. /**
  124415. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  124416. * of the picture to blur (the smaller the faster).
  124417. */
  124418. blurTextureSizeRatio: number;
  124419. /**
  124420. * How big in texel of the blur texture is the vertical blur.
  124421. */
  124422. blurVerticalSize: number;
  124423. /**
  124424. * How big in texel of the blur texture is the horizontal blur.
  124425. */
  124426. blurHorizontalSize: number;
  124427. /**
  124428. * Alpha blending mode used to apply the blur. Default is combine.
  124429. */
  124430. alphaBlendingMode: number;
  124431. /**
  124432. * The camera attached to the layer.
  124433. */
  124434. camera: Nullable<Camera>;
  124435. /**
  124436. * Should we display highlight as a solid stroke?
  124437. */
  124438. isStroke?: boolean;
  124439. /**
  124440. * The rendering group to draw the layer in.
  124441. */
  124442. renderingGroupId: number;
  124443. }
  124444. /**
  124445. * The highlight layer Helps adding a glow effect around a mesh.
  124446. *
  124447. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  124448. * glowy meshes to your scene.
  124449. *
  124450. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  124451. */
  124452. export class HighlightLayer extends EffectLayer {
  124453. name: string;
  124454. /**
  124455. * Effect Name of the highlight layer.
  124456. */
  124457. static readonly EffectName: string;
  124458. /**
  124459. * The neutral color used during the preparation of the glow effect.
  124460. * This is black by default as the blend operation is a blend operation.
  124461. */
  124462. static NeutralColor: Color4;
  124463. /**
  124464. * Stencil value used for glowing meshes.
  124465. */
  124466. static GlowingMeshStencilReference: number;
  124467. /**
  124468. * Stencil value used for the other meshes in the scene.
  124469. */
  124470. static NormalMeshStencilReference: number;
  124471. /**
  124472. * Specifies whether or not the inner glow is ACTIVE in the layer.
  124473. */
  124474. innerGlow: boolean;
  124475. /**
  124476. * Specifies whether or not the outer glow is ACTIVE in the layer.
  124477. */
  124478. outerGlow: boolean;
  124479. /**
  124480. * Specifies the horizontal size of the blur.
  124481. */
  124482. set blurHorizontalSize(value: number);
  124483. /**
  124484. * Specifies the vertical size of the blur.
  124485. */
  124486. set blurVerticalSize(value: number);
  124487. /**
  124488. * Gets the horizontal size of the blur.
  124489. */
  124490. get blurHorizontalSize(): number;
  124491. /**
  124492. * Gets the vertical size of the blur.
  124493. */
  124494. get blurVerticalSize(): number;
  124495. /**
  124496. * An event triggered when the highlight layer is being blurred.
  124497. */
  124498. onBeforeBlurObservable: Observable<HighlightLayer>;
  124499. /**
  124500. * An event triggered when the highlight layer has been blurred.
  124501. */
  124502. onAfterBlurObservable: Observable<HighlightLayer>;
  124503. private _instanceGlowingMeshStencilReference;
  124504. private _options;
  124505. private _downSamplePostprocess;
  124506. private _horizontalBlurPostprocess;
  124507. private _verticalBlurPostprocess;
  124508. private _blurTexture;
  124509. private _meshes;
  124510. private _excludedMeshes;
  124511. /**
  124512. * Instantiates a new highlight Layer and references it to the scene..
  124513. * @param name The name of the layer
  124514. * @param scene The scene to use the layer in
  124515. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  124516. */
  124517. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  124518. /**
  124519. * Get the effect name of the layer.
  124520. * @return The effect name
  124521. */
  124522. getEffectName(): string;
  124523. /**
  124524. * Create the merge effect. This is the shader use to blit the information back
  124525. * to the main canvas at the end of the scene rendering.
  124526. */
  124527. protected _createMergeEffect(): Effect;
  124528. /**
  124529. * Creates the render target textures and post processes used in the highlight layer.
  124530. */
  124531. protected _createTextureAndPostProcesses(): void;
  124532. /**
  124533. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  124534. */
  124535. needStencil(): boolean;
  124536. /**
  124537. * Checks for the readiness of the element composing the layer.
  124538. * @param subMesh the mesh to check for
  124539. * @param useInstances specify wether or not to use instances to render the mesh
  124540. * @param emissiveTexture the associated emissive texture used to generate the glow
  124541. * @return true if ready otherwise, false
  124542. */
  124543. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124544. /**
  124545. * Implementation specific of rendering the generating effect on the main canvas.
  124546. * @param effect The effect used to render through
  124547. */
  124548. protected _internalRender(effect: Effect): void;
  124549. /**
  124550. * Returns true if the layer contains information to display, otherwise false.
  124551. */
  124552. shouldRender(): boolean;
  124553. /**
  124554. * Returns true if the mesh should render, otherwise false.
  124555. * @param mesh The mesh to render
  124556. * @returns true if it should render otherwise false
  124557. */
  124558. protected _shouldRenderMesh(mesh: Mesh): boolean;
  124559. /**
  124560. * Sets the required values for both the emissive texture and and the main color.
  124561. */
  124562. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  124563. /**
  124564. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  124565. * @param mesh The mesh to exclude from the highlight layer
  124566. */
  124567. addExcludedMesh(mesh: Mesh): void;
  124568. /**
  124569. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  124570. * @param mesh The mesh to highlight
  124571. */
  124572. removeExcludedMesh(mesh: Mesh): void;
  124573. /**
  124574. * Determine if a given mesh will be highlighted by the current HighlightLayer
  124575. * @param mesh mesh to test
  124576. * @returns true if the mesh will be highlighted by the current HighlightLayer
  124577. */
  124578. hasMesh(mesh: AbstractMesh): boolean;
  124579. /**
  124580. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  124581. * @param mesh The mesh to highlight
  124582. * @param color The color of the highlight
  124583. * @param glowEmissiveOnly Extract the glow from the emissive texture
  124584. */
  124585. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  124586. /**
  124587. * Remove a mesh from the highlight layer in order to make it stop glowing.
  124588. * @param mesh The mesh to highlight
  124589. */
  124590. removeMesh(mesh: Mesh): void;
  124591. /**
  124592. * Force the stencil to the normal expected value for none glowing parts
  124593. */
  124594. private _defaultStencilReference;
  124595. /**
  124596. * Free any resources and references associated to a mesh.
  124597. * Internal use
  124598. * @param mesh The mesh to free.
  124599. * @hidden
  124600. */
  124601. _disposeMesh(mesh: Mesh): void;
  124602. /**
  124603. * Dispose the highlight layer and free resources.
  124604. */
  124605. dispose(): void;
  124606. /**
  124607. * Gets the class name of the effect layer
  124608. * @returns the string with the class name of the effect layer
  124609. */
  124610. getClassName(): string;
  124611. /**
  124612. * Serializes this Highlight layer
  124613. * @returns a serialized Highlight layer object
  124614. */
  124615. serialize(): any;
  124616. /**
  124617. * Creates a Highlight layer from parsed Highlight layer data
  124618. * @param parsedHightlightLayer defines the Highlight layer data
  124619. * @param scene defines the current scene
  124620. * @param rootUrl defines the root URL containing the Highlight layer information
  124621. * @returns a parsed Highlight layer
  124622. */
  124623. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  124624. }
  124625. }
  124626. declare module BABYLON {
  124627. interface AbstractScene {
  124628. /**
  124629. * The list of layers (background and foreground) of the scene
  124630. */
  124631. layers: Array<Layer>;
  124632. }
  124633. /**
  124634. * Defines the layer scene component responsible to manage any layers
  124635. * in a given scene.
  124636. */
  124637. export class LayerSceneComponent implements ISceneComponent {
  124638. /**
  124639. * The component name helpfull to identify the component in the list of scene components.
  124640. */
  124641. readonly name: string;
  124642. /**
  124643. * The scene the component belongs to.
  124644. */
  124645. scene: Scene;
  124646. private _engine;
  124647. /**
  124648. * Creates a new instance of the component for the given scene
  124649. * @param scene Defines the scene to register the component in
  124650. */
  124651. constructor(scene: Scene);
  124652. /**
  124653. * Registers the component in a given scene
  124654. */
  124655. register(): void;
  124656. /**
  124657. * Rebuilds the elements related to this component in case of
  124658. * context lost for instance.
  124659. */
  124660. rebuild(): void;
  124661. /**
  124662. * Disposes the component and the associated ressources.
  124663. */
  124664. dispose(): void;
  124665. private _draw;
  124666. private _drawCameraPredicate;
  124667. private _drawCameraBackground;
  124668. private _drawCameraForeground;
  124669. private _drawRenderTargetPredicate;
  124670. private _drawRenderTargetBackground;
  124671. private _drawRenderTargetForeground;
  124672. /**
  124673. * Adds all the elements from the container to the scene
  124674. * @param container the container holding the elements
  124675. */
  124676. addFromContainer(container: AbstractScene): void;
  124677. /**
  124678. * Removes all the elements in the container from the scene
  124679. * @param container contains the elements to remove
  124680. * @param dispose if the removed element should be disposed (default: false)
  124681. */
  124682. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  124683. }
  124684. }
  124685. declare module BABYLON {
  124686. /** @hidden */
  124687. export var layerPixelShader: {
  124688. name: string;
  124689. shader: string;
  124690. };
  124691. }
  124692. declare module BABYLON {
  124693. /** @hidden */
  124694. export var layerVertexShader: {
  124695. name: string;
  124696. shader: string;
  124697. };
  124698. }
  124699. declare module BABYLON {
  124700. /**
  124701. * This represents a full screen 2d layer.
  124702. * This can be useful to display a picture in the background of your scene for instance.
  124703. * @see https://www.babylonjs-playground.com/#08A2BS#1
  124704. */
  124705. export class Layer {
  124706. /**
  124707. * Define the name of the layer.
  124708. */
  124709. name: string;
  124710. /**
  124711. * Define the texture the layer should display.
  124712. */
  124713. texture: Nullable<Texture>;
  124714. /**
  124715. * Is the layer in background or foreground.
  124716. */
  124717. isBackground: boolean;
  124718. /**
  124719. * Define the color of the layer (instead of texture).
  124720. */
  124721. color: Color4;
  124722. /**
  124723. * Define the scale of the layer in order to zoom in out of the texture.
  124724. */
  124725. scale: Vector2;
  124726. /**
  124727. * Define an offset for the layer in order to shift the texture.
  124728. */
  124729. offset: Vector2;
  124730. /**
  124731. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  124732. */
  124733. alphaBlendingMode: number;
  124734. /**
  124735. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  124736. * Alpha test will not mix with the background color in case of transparency.
  124737. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  124738. */
  124739. alphaTest: boolean;
  124740. /**
  124741. * Define a mask to restrict the layer to only some of the scene cameras.
  124742. */
  124743. layerMask: number;
  124744. /**
  124745. * Define the list of render target the layer is visible into.
  124746. */
  124747. renderTargetTextures: RenderTargetTexture[];
  124748. /**
  124749. * Define if the layer is only used in renderTarget or if it also
  124750. * renders in the main frame buffer of the canvas.
  124751. */
  124752. renderOnlyInRenderTargetTextures: boolean;
  124753. private _scene;
  124754. private _vertexBuffers;
  124755. private _indexBuffer;
  124756. private _effect;
  124757. private _previousDefines;
  124758. /**
  124759. * An event triggered when the layer is disposed.
  124760. */
  124761. onDisposeObservable: Observable<Layer>;
  124762. private _onDisposeObserver;
  124763. /**
  124764. * Back compatibility with callback before the onDisposeObservable existed.
  124765. * The set callback will be triggered when the layer has been disposed.
  124766. */
  124767. set onDispose(callback: () => void);
  124768. /**
  124769. * An event triggered before rendering the scene
  124770. */
  124771. onBeforeRenderObservable: Observable<Layer>;
  124772. private _onBeforeRenderObserver;
  124773. /**
  124774. * Back compatibility with callback before the onBeforeRenderObservable existed.
  124775. * The set callback will be triggered just before rendering the layer.
  124776. */
  124777. set onBeforeRender(callback: () => void);
  124778. /**
  124779. * An event triggered after rendering the scene
  124780. */
  124781. onAfterRenderObservable: Observable<Layer>;
  124782. private _onAfterRenderObserver;
  124783. /**
  124784. * Back compatibility with callback before the onAfterRenderObservable existed.
  124785. * The set callback will be triggered just after rendering the layer.
  124786. */
  124787. set onAfterRender(callback: () => void);
  124788. /**
  124789. * Instantiates a new layer.
  124790. * This represents a full screen 2d layer.
  124791. * This can be useful to display a picture in the background of your scene for instance.
  124792. * @see https://www.babylonjs-playground.com/#08A2BS#1
  124793. * @param name Define the name of the layer in the scene
  124794. * @param imgUrl Define the url of the texture to display in the layer
  124795. * @param scene Define the scene the layer belongs to
  124796. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  124797. * @param color Defines a color for the layer
  124798. */
  124799. constructor(
  124800. /**
  124801. * Define the name of the layer.
  124802. */
  124803. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  124804. private _createIndexBuffer;
  124805. /** @hidden */
  124806. _rebuild(): void;
  124807. /**
  124808. * Renders the layer in the scene.
  124809. */
  124810. render(): void;
  124811. /**
  124812. * Disposes and releases the associated ressources.
  124813. */
  124814. dispose(): void;
  124815. }
  124816. }
  124817. declare module BABYLON {
  124818. /** @hidden */
  124819. export var lensFlarePixelShader: {
  124820. name: string;
  124821. shader: string;
  124822. };
  124823. }
  124824. declare module BABYLON {
  124825. /** @hidden */
  124826. export var lensFlareVertexShader: {
  124827. name: string;
  124828. shader: string;
  124829. };
  124830. }
  124831. declare module BABYLON {
  124832. /**
  124833. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  124834. * It is usually composed of several `lensFlare`.
  124835. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124836. */
  124837. export class LensFlareSystem {
  124838. /**
  124839. * Define the name of the lens flare system
  124840. */
  124841. name: string;
  124842. /**
  124843. * List of lens flares used in this system.
  124844. */
  124845. lensFlares: LensFlare[];
  124846. /**
  124847. * Define a limit from the border the lens flare can be visible.
  124848. */
  124849. borderLimit: number;
  124850. /**
  124851. * Define a viewport border we do not want to see the lens flare in.
  124852. */
  124853. viewportBorder: number;
  124854. /**
  124855. * Define a predicate which could limit the list of meshes able to occlude the effect.
  124856. */
  124857. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  124858. /**
  124859. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  124860. */
  124861. layerMask: number;
  124862. /**
  124863. * Define the id of the lens flare system in the scene.
  124864. * (equal to name by default)
  124865. */
  124866. id: string;
  124867. private _scene;
  124868. private _emitter;
  124869. private _vertexBuffers;
  124870. private _indexBuffer;
  124871. private _effect;
  124872. private _positionX;
  124873. private _positionY;
  124874. private _isEnabled;
  124875. /** @hidden */
  124876. static _SceneComponentInitialization: (scene: Scene) => void;
  124877. /**
  124878. * Instantiates a lens flare system.
  124879. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  124880. * It is usually composed of several `lensFlare`.
  124881. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124882. * @param name Define the name of the lens flare system in the scene
  124883. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  124884. * @param scene Define the scene the lens flare system belongs to
  124885. */
  124886. constructor(
  124887. /**
  124888. * Define the name of the lens flare system
  124889. */
  124890. name: string, emitter: any, scene: Scene);
  124891. /**
  124892. * Define if the lens flare system is enabled.
  124893. */
  124894. get isEnabled(): boolean;
  124895. set isEnabled(value: boolean);
  124896. /**
  124897. * Get the scene the effects belongs to.
  124898. * @returns the scene holding the lens flare system
  124899. */
  124900. getScene(): Scene;
  124901. /**
  124902. * Get the emitter of the lens flare system.
  124903. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  124904. * @returns the emitter of the lens flare system
  124905. */
  124906. getEmitter(): any;
  124907. /**
  124908. * Set the emitter of the lens flare system.
  124909. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  124910. * @param newEmitter Define the new emitter of the system
  124911. */
  124912. setEmitter(newEmitter: any): void;
  124913. /**
  124914. * Get the lens flare system emitter position.
  124915. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  124916. * @returns the position
  124917. */
  124918. getEmitterPosition(): Vector3;
  124919. /**
  124920. * @hidden
  124921. */
  124922. computeEffectivePosition(globalViewport: Viewport): boolean;
  124923. /** @hidden */
  124924. _isVisible(): boolean;
  124925. /**
  124926. * @hidden
  124927. */
  124928. render(): boolean;
  124929. /**
  124930. * Dispose and release the lens flare with its associated resources.
  124931. */
  124932. dispose(): void;
  124933. /**
  124934. * Parse a lens flare system from a JSON repressentation
  124935. * @param parsedLensFlareSystem Define the JSON to parse
  124936. * @param scene Define the scene the parsed system should be instantiated in
  124937. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  124938. * @returns the parsed system
  124939. */
  124940. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  124941. /**
  124942. * Serialize the current Lens Flare System into a JSON representation.
  124943. * @returns the serialized JSON
  124944. */
  124945. serialize(): any;
  124946. }
  124947. }
  124948. declare module BABYLON {
  124949. /**
  124950. * This represents one of the lens effect in a `lensFlareSystem`.
  124951. * It controls one of the indiviual texture used in the effect.
  124952. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124953. */
  124954. export class LensFlare {
  124955. /**
  124956. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  124957. */
  124958. size: number;
  124959. /**
  124960. * 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.
  124961. */
  124962. position: number;
  124963. /**
  124964. * Define the lens color.
  124965. */
  124966. color: Color3;
  124967. /**
  124968. * Define the lens texture.
  124969. */
  124970. texture: Nullable<Texture>;
  124971. /**
  124972. * Define the alpha mode to render this particular lens.
  124973. */
  124974. alphaMode: number;
  124975. private _system;
  124976. /**
  124977. * Creates a new Lens Flare.
  124978. * This represents one of the lens effect in a `lensFlareSystem`.
  124979. * It controls one of the indiviual texture used in the effect.
  124980. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124981. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  124982. * @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.
  124983. * @param color Define the lens color
  124984. * @param imgUrl Define the lens texture url
  124985. * @param system Define the `lensFlareSystem` this flare is part of
  124986. * @returns The newly created Lens Flare
  124987. */
  124988. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  124989. /**
  124990. * Instantiates a new Lens Flare.
  124991. * This represents one of the lens effect in a `lensFlareSystem`.
  124992. * It controls one of the indiviual texture used in the effect.
  124993. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124994. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  124995. * @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.
  124996. * @param color Define the lens color
  124997. * @param imgUrl Define the lens texture url
  124998. * @param system Define the `lensFlareSystem` this flare is part of
  124999. */
  125000. constructor(
  125001. /**
  125002. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  125003. */
  125004. size: number,
  125005. /**
  125006. * 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.
  125007. */
  125008. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  125009. /**
  125010. * Dispose and release the lens flare with its associated resources.
  125011. */
  125012. dispose(): void;
  125013. }
  125014. }
  125015. declare module BABYLON {
  125016. interface AbstractScene {
  125017. /**
  125018. * The list of lens flare system added to the scene
  125019. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  125020. */
  125021. lensFlareSystems: Array<LensFlareSystem>;
  125022. /**
  125023. * Removes the given lens flare system from this scene.
  125024. * @param toRemove The lens flare system to remove
  125025. * @returns The index of the removed lens flare system
  125026. */
  125027. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  125028. /**
  125029. * Adds the given lens flare system to this scene
  125030. * @param newLensFlareSystem The lens flare system to add
  125031. */
  125032. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  125033. /**
  125034. * Gets a lens flare system using its name
  125035. * @param name defines the name to look for
  125036. * @returns the lens flare system or null if not found
  125037. */
  125038. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  125039. /**
  125040. * Gets a lens flare system using its id
  125041. * @param id defines the id to look for
  125042. * @returns the lens flare system or null if not found
  125043. */
  125044. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  125045. }
  125046. /**
  125047. * Defines the lens flare scene component responsible to manage any lens flares
  125048. * in a given scene.
  125049. */
  125050. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  125051. /**
  125052. * The component name helpfull to identify the component in the list of scene components.
  125053. */
  125054. readonly name: string;
  125055. /**
  125056. * The scene the component belongs to.
  125057. */
  125058. scene: Scene;
  125059. /**
  125060. * Creates a new instance of the component for the given scene
  125061. * @param scene Defines the scene to register the component in
  125062. */
  125063. constructor(scene: Scene);
  125064. /**
  125065. * Registers the component in a given scene
  125066. */
  125067. register(): void;
  125068. /**
  125069. * Rebuilds the elements related to this component in case of
  125070. * context lost for instance.
  125071. */
  125072. rebuild(): void;
  125073. /**
  125074. * Adds all the elements from the container to the scene
  125075. * @param container the container holding the elements
  125076. */
  125077. addFromContainer(container: AbstractScene): void;
  125078. /**
  125079. * Removes all the elements in the container from the scene
  125080. * @param container contains the elements to remove
  125081. * @param dispose if the removed element should be disposed (default: false)
  125082. */
  125083. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125084. /**
  125085. * Serializes the component data to the specified json object
  125086. * @param serializationObject The object to serialize to
  125087. */
  125088. serialize(serializationObject: any): void;
  125089. /**
  125090. * Disposes the component and the associated ressources.
  125091. */
  125092. dispose(): void;
  125093. private _draw;
  125094. }
  125095. }
  125096. declare module BABYLON {
  125097. /**
  125098. * Defines the shadow generator component responsible to manage any shadow generators
  125099. * in a given scene.
  125100. */
  125101. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  125102. /**
  125103. * The component name helpfull to identify the component in the list of scene components.
  125104. */
  125105. readonly name: string;
  125106. /**
  125107. * The scene the component belongs to.
  125108. */
  125109. scene: Scene;
  125110. /**
  125111. * Creates a new instance of the component for the given scene
  125112. * @param scene Defines the scene to register the component in
  125113. */
  125114. constructor(scene: Scene);
  125115. /**
  125116. * Registers the component in a given scene
  125117. */
  125118. register(): void;
  125119. /**
  125120. * Rebuilds the elements related to this component in case of
  125121. * context lost for instance.
  125122. */
  125123. rebuild(): void;
  125124. /**
  125125. * Serializes the component data to the specified json object
  125126. * @param serializationObject The object to serialize to
  125127. */
  125128. serialize(serializationObject: any): void;
  125129. /**
  125130. * Adds all the elements from the container to the scene
  125131. * @param container the container holding the elements
  125132. */
  125133. addFromContainer(container: AbstractScene): void;
  125134. /**
  125135. * Removes all the elements in the container from the scene
  125136. * @param container contains the elements to remove
  125137. * @param dispose if the removed element should be disposed (default: false)
  125138. */
  125139. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125140. /**
  125141. * Rebuilds the elements related to this component in case of
  125142. * context lost for instance.
  125143. */
  125144. dispose(): void;
  125145. private _gatherRenderTargets;
  125146. }
  125147. }
  125148. declare module BABYLON {
  125149. /**
  125150. * A point light is a light defined by an unique point in world space.
  125151. * The light is emitted in every direction from this point.
  125152. * A good example of a point light is a standard light bulb.
  125153. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125154. */
  125155. export class PointLight extends ShadowLight {
  125156. private _shadowAngle;
  125157. /**
  125158. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  125159. * This specifies what angle the shadow will use to be created.
  125160. *
  125161. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  125162. */
  125163. get shadowAngle(): number;
  125164. /**
  125165. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  125166. * This specifies what angle the shadow will use to be created.
  125167. *
  125168. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  125169. */
  125170. set shadowAngle(value: number);
  125171. /**
  125172. * Gets the direction if it has been set.
  125173. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  125174. */
  125175. get direction(): Vector3;
  125176. /**
  125177. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  125178. */
  125179. set direction(value: Vector3);
  125180. /**
  125181. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  125182. * A PointLight emits the light in every direction.
  125183. * It can cast shadows.
  125184. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  125185. * ```javascript
  125186. * var pointLight = new PointLight("pl", camera.position, scene);
  125187. * ```
  125188. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125189. * @param name The light friendly name
  125190. * @param position The position of the point light in the scene
  125191. * @param scene The scene the lights belongs to
  125192. */
  125193. constructor(name: string, position: Vector3, scene: Scene);
  125194. /**
  125195. * Returns the string "PointLight"
  125196. * @returns the class name
  125197. */
  125198. getClassName(): string;
  125199. /**
  125200. * Returns the integer 0.
  125201. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125202. */
  125203. getTypeID(): number;
  125204. /**
  125205. * Specifies wether or not the shadowmap should be a cube texture.
  125206. * @returns true if the shadowmap needs to be a cube texture.
  125207. */
  125208. needCube(): boolean;
  125209. /**
  125210. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  125211. * @param faceIndex The index of the face we are computed the direction to generate shadow
  125212. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  125213. */
  125214. getShadowDirection(faceIndex?: number): Vector3;
  125215. /**
  125216. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  125217. * - fov = PI / 2
  125218. * - aspect ratio : 1.0
  125219. * - z-near and far equal to the active camera minZ and maxZ.
  125220. * Returns the PointLight.
  125221. */
  125222. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125223. protected _buildUniformLayout(): void;
  125224. /**
  125225. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  125226. * @param effect The effect to update
  125227. * @param lightIndex The index of the light in the effect to update
  125228. * @returns The point light
  125229. */
  125230. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  125231. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  125232. /**
  125233. * Prepares the list of defines specific to the light type.
  125234. * @param defines the list of defines
  125235. * @param lightIndex defines the index of the light for the effect
  125236. */
  125237. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125238. }
  125239. }
  125240. declare module BABYLON {
  125241. /**
  125242. * Header information of HDR texture files.
  125243. */
  125244. export interface HDRInfo {
  125245. /**
  125246. * The height of the texture in pixels.
  125247. */
  125248. height: number;
  125249. /**
  125250. * The width of the texture in pixels.
  125251. */
  125252. width: number;
  125253. /**
  125254. * The index of the beginning of the data in the binary file.
  125255. */
  125256. dataPosition: number;
  125257. }
  125258. /**
  125259. * This groups tools to convert HDR texture to native colors array.
  125260. */
  125261. export class HDRTools {
  125262. private static Ldexp;
  125263. private static Rgbe2float;
  125264. private static readStringLine;
  125265. /**
  125266. * Reads header information from an RGBE texture stored in a native array.
  125267. * More information on this format are available here:
  125268. * https://en.wikipedia.org/wiki/RGBE_image_format
  125269. *
  125270. * @param uint8array The binary file stored in native array.
  125271. * @return The header information.
  125272. */
  125273. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  125274. /**
  125275. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  125276. * This RGBE texture needs to store the information as a panorama.
  125277. *
  125278. * More information on this format are available here:
  125279. * https://en.wikipedia.org/wiki/RGBE_image_format
  125280. *
  125281. * @param buffer The binary file stored in an array buffer.
  125282. * @param size The expected size of the extracted cubemap.
  125283. * @return The Cube Map information.
  125284. */
  125285. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  125286. /**
  125287. * Returns the pixels data extracted from an RGBE texture.
  125288. * This pixels will be stored left to right up to down in the R G B order in one array.
  125289. *
  125290. * More information on this format are available here:
  125291. * https://en.wikipedia.org/wiki/RGBE_image_format
  125292. *
  125293. * @param uint8array The binary file stored in an array buffer.
  125294. * @param hdrInfo The header information of the file.
  125295. * @return The pixels data in RGB right to left up to down order.
  125296. */
  125297. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  125298. private static RGBE_ReadPixels_RLE;
  125299. }
  125300. }
  125301. declare module BABYLON {
  125302. /**
  125303. * This represents a texture coming from an HDR input.
  125304. *
  125305. * The only supported format is currently panorama picture stored in RGBE format.
  125306. * Example of such files can be found on HDRLib: http://hdrlib.com/
  125307. */
  125308. export class HDRCubeTexture extends BaseTexture {
  125309. private static _facesMapping;
  125310. private _generateHarmonics;
  125311. private _noMipmap;
  125312. private _textureMatrix;
  125313. private _size;
  125314. private _onLoad;
  125315. private _onError;
  125316. /**
  125317. * The texture URL.
  125318. */
  125319. url: string;
  125320. /**
  125321. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  125322. */
  125323. coordinatesMode: number;
  125324. protected _isBlocking: boolean;
  125325. /**
  125326. * Sets wether or not the texture is blocking during loading.
  125327. */
  125328. set isBlocking(value: boolean);
  125329. /**
  125330. * Gets wether or not the texture is blocking during loading.
  125331. */
  125332. get isBlocking(): boolean;
  125333. protected _rotationY: number;
  125334. /**
  125335. * Sets texture matrix rotation angle around Y axis in radians.
  125336. */
  125337. set rotationY(value: number);
  125338. /**
  125339. * Gets texture matrix rotation angle around Y axis radians.
  125340. */
  125341. get rotationY(): number;
  125342. /**
  125343. * Gets or sets the center of the bounding box associated with the cube texture
  125344. * It must define where the camera used to render the texture was set
  125345. */
  125346. boundingBoxPosition: Vector3;
  125347. private _boundingBoxSize;
  125348. /**
  125349. * Gets or sets the size of the bounding box associated with the cube texture
  125350. * When defined, the cubemap will switch to local mode
  125351. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  125352. * @example https://www.babylonjs-playground.com/#RNASML
  125353. */
  125354. set boundingBoxSize(value: Vector3);
  125355. get boundingBoxSize(): Vector3;
  125356. /**
  125357. * Instantiates an HDRTexture from the following parameters.
  125358. *
  125359. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  125360. * @param scene The scene the texture will be used in
  125361. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  125362. * @param noMipmap Forces to not generate the mipmap if true
  125363. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  125364. * @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)
  125365. * @param reserved Reserved flag for internal use.
  125366. */
  125367. 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>);
  125368. /**
  125369. * Get the current class name of the texture useful for serialization or dynamic coding.
  125370. * @returns "HDRCubeTexture"
  125371. */
  125372. getClassName(): string;
  125373. /**
  125374. * Occurs when the file is raw .hdr file.
  125375. */
  125376. private loadTexture;
  125377. clone(): HDRCubeTexture;
  125378. delayLoad(): void;
  125379. /**
  125380. * Get the texture reflection matrix used to rotate/transform the reflection.
  125381. * @returns the reflection matrix
  125382. */
  125383. getReflectionTextureMatrix(): Matrix;
  125384. /**
  125385. * Set the texture reflection matrix used to rotate/transform the reflection.
  125386. * @param value Define the reflection matrix to set
  125387. */
  125388. setReflectionTextureMatrix(value: Matrix): void;
  125389. /**
  125390. * Parses a JSON representation of an HDR Texture in order to create the texture
  125391. * @param parsedTexture Define the JSON representation
  125392. * @param scene Define the scene the texture should be created in
  125393. * @param rootUrl Define the root url in case we need to load relative dependencies
  125394. * @returns the newly created texture after parsing
  125395. */
  125396. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  125397. serialize(): any;
  125398. }
  125399. }
  125400. declare module BABYLON {
  125401. /**
  125402. * Class used to control physics engine
  125403. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125404. */
  125405. export class PhysicsEngine implements IPhysicsEngine {
  125406. private _physicsPlugin;
  125407. /**
  125408. * Global value used to control the smallest number supported by the simulation
  125409. */
  125410. static Epsilon: number;
  125411. private _impostors;
  125412. private _joints;
  125413. private _subTimeStep;
  125414. /**
  125415. * Gets the gravity vector used by the simulation
  125416. */
  125417. gravity: Vector3;
  125418. /**
  125419. * Factory used to create the default physics plugin.
  125420. * @returns The default physics plugin
  125421. */
  125422. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  125423. /**
  125424. * Creates a new Physics Engine
  125425. * @param gravity defines the gravity vector used by the simulation
  125426. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  125427. */
  125428. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  125429. /**
  125430. * Sets the gravity vector used by the simulation
  125431. * @param gravity defines the gravity vector to use
  125432. */
  125433. setGravity(gravity: Vector3): void;
  125434. /**
  125435. * Set the time step of the physics engine.
  125436. * Default is 1/60.
  125437. * To slow it down, enter 1/600 for example.
  125438. * To speed it up, 1/30
  125439. * @param newTimeStep defines the new timestep to apply to this world.
  125440. */
  125441. setTimeStep(newTimeStep?: number): void;
  125442. /**
  125443. * Get the time step of the physics engine.
  125444. * @returns the current time step
  125445. */
  125446. getTimeStep(): number;
  125447. /**
  125448. * Set the sub time step of the physics engine.
  125449. * Default is 0 meaning there is no sub steps
  125450. * To increase physics resolution precision, set a small value (like 1 ms)
  125451. * @param subTimeStep defines the new sub timestep used for physics resolution.
  125452. */
  125453. setSubTimeStep(subTimeStep?: number): void;
  125454. /**
  125455. * Get the sub time step of the physics engine.
  125456. * @returns the current sub time step
  125457. */
  125458. getSubTimeStep(): number;
  125459. /**
  125460. * Release all resources
  125461. */
  125462. dispose(): void;
  125463. /**
  125464. * Gets the name of the current physics plugin
  125465. * @returns the name of the plugin
  125466. */
  125467. getPhysicsPluginName(): string;
  125468. /**
  125469. * Adding a new impostor for the impostor tracking.
  125470. * This will be done by the impostor itself.
  125471. * @param impostor the impostor to add
  125472. */
  125473. addImpostor(impostor: PhysicsImpostor): void;
  125474. /**
  125475. * Remove an impostor from the engine.
  125476. * This impostor and its mesh will not longer be updated by the physics engine.
  125477. * @param impostor the impostor to remove
  125478. */
  125479. removeImpostor(impostor: PhysicsImpostor): void;
  125480. /**
  125481. * Add a joint to the physics engine
  125482. * @param mainImpostor defines the main impostor to which the joint is added.
  125483. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  125484. * @param joint defines the joint that will connect both impostors.
  125485. */
  125486. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  125487. /**
  125488. * Removes a joint from the simulation
  125489. * @param mainImpostor defines the impostor used with the joint
  125490. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  125491. * @param joint defines the joint to remove
  125492. */
  125493. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  125494. /**
  125495. * Called by the scene. No need to call it.
  125496. * @param delta defines the timespam between frames
  125497. */
  125498. _step(delta: number): void;
  125499. /**
  125500. * Gets the current plugin used to run the simulation
  125501. * @returns current plugin
  125502. */
  125503. getPhysicsPlugin(): IPhysicsEnginePlugin;
  125504. /**
  125505. * Gets the list of physic impostors
  125506. * @returns an array of PhysicsImpostor
  125507. */
  125508. getImpostors(): Array<PhysicsImpostor>;
  125509. /**
  125510. * Gets the impostor for a physics enabled object
  125511. * @param object defines the object impersonated by the impostor
  125512. * @returns the PhysicsImpostor or null if not found
  125513. */
  125514. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  125515. /**
  125516. * Gets the impostor for a physics body object
  125517. * @param body defines physics body used by the impostor
  125518. * @returns the PhysicsImpostor or null if not found
  125519. */
  125520. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  125521. /**
  125522. * Does a raycast in the physics world
  125523. * @param from when should the ray start?
  125524. * @param to when should the ray end?
  125525. * @returns PhysicsRaycastResult
  125526. */
  125527. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  125528. }
  125529. }
  125530. declare module BABYLON {
  125531. /** @hidden */
  125532. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  125533. private _useDeltaForWorldStep;
  125534. world: any;
  125535. name: string;
  125536. private _physicsMaterials;
  125537. private _fixedTimeStep;
  125538. private _cannonRaycastResult;
  125539. private _raycastResult;
  125540. private _physicsBodysToRemoveAfterStep;
  125541. BJSCANNON: any;
  125542. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  125543. setGravity(gravity: Vector3): void;
  125544. setTimeStep(timeStep: number): void;
  125545. getTimeStep(): number;
  125546. executeStep(delta: number): void;
  125547. private _removeMarkedPhysicsBodiesFromWorld;
  125548. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125549. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125550. generatePhysicsBody(impostor: PhysicsImpostor): void;
  125551. private _processChildMeshes;
  125552. removePhysicsBody(impostor: PhysicsImpostor): void;
  125553. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  125554. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  125555. private _addMaterial;
  125556. private _checkWithEpsilon;
  125557. private _createShape;
  125558. private _createHeightmap;
  125559. private _minus90X;
  125560. private _plus90X;
  125561. private _tmpPosition;
  125562. private _tmpDeltaPosition;
  125563. private _tmpUnityRotation;
  125564. private _updatePhysicsBodyTransformation;
  125565. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  125566. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  125567. isSupported(): boolean;
  125568. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125569. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125570. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125571. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125572. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  125573. getBodyMass(impostor: PhysicsImpostor): number;
  125574. getBodyFriction(impostor: PhysicsImpostor): number;
  125575. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  125576. getBodyRestitution(impostor: PhysicsImpostor): number;
  125577. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  125578. sleepBody(impostor: PhysicsImpostor): void;
  125579. wakeUpBody(impostor: PhysicsImpostor): void;
  125580. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  125581. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  125582. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  125583. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  125584. getRadius(impostor: PhysicsImpostor): number;
  125585. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  125586. dispose(): void;
  125587. private _extendNamespace;
  125588. /**
  125589. * Does a raycast in the physics world
  125590. * @param from when should the ray start?
  125591. * @param to when should the ray end?
  125592. * @returns PhysicsRaycastResult
  125593. */
  125594. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  125595. }
  125596. }
  125597. declare module BABYLON {
  125598. /** @hidden */
  125599. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  125600. world: any;
  125601. name: string;
  125602. BJSOIMO: any;
  125603. private _raycastResult;
  125604. constructor(iterations?: number, oimoInjection?: any);
  125605. setGravity(gravity: Vector3): void;
  125606. setTimeStep(timeStep: number): void;
  125607. getTimeStep(): number;
  125608. private _tmpImpostorsArray;
  125609. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  125610. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125611. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125612. generatePhysicsBody(impostor: PhysicsImpostor): void;
  125613. private _tmpPositionVector;
  125614. removePhysicsBody(impostor: PhysicsImpostor): void;
  125615. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  125616. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  125617. isSupported(): boolean;
  125618. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  125619. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  125620. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125621. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125622. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125623. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125624. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  125625. getBodyMass(impostor: PhysicsImpostor): number;
  125626. getBodyFriction(impostor: PhysicsImpostor): number;
  125627. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  125628. getBodyRestitution(impostor: PhysicsImpostor): number;
  125629. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  125630. sleepBody(impostor: PhysicsImpostor): void;
  125631. wakeUpBody(impostor: PhysicsImpostor): void;
  125632. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  125633. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  125634. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  125635. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  125636. getRadius(impostor: PhysicsImpostor): number;
  125637. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  125638. dispose(): void;
  125639. /**
  125640. * Does a raycast in the physics world
  125641. * @param from when should the ray start?
  125642. * @param to when should the ray end?
  125643. * @returns PhysicsRaycastResult
  125644. */
  125645. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  125646. }
  125647. }
  125648. declare module BABYLON {
  125649. /**
  125650. * Class containing static functions to help procedurally build meshes
  125651. */
  125652. export class RibbonBuilder {
  125653. /**
  125654. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125655. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125656. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125657. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125658. * * 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
  125659. * * 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
  125660. * * 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
  125661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125663. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125664. * * 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
  125665. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125666. * * 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
  125667. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125669. * @param name defines the name of the mesh
  125670. * @param options defines the options used to create the mesh
  125671. * @param scene defines the hosting scene
  125672. * @returns the ribbon mesh
  125673. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125674. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125675. */
  125676. static CreateRibbon(name: string, options: {
  125677. pathArray: Vector3[][];
  125678. closeArray?: boolean;
  125679. closePath?: boolean;
  125680. offset?: number;
  125681. updatable?: boolean;
  125682. sideOrientation?: number;
  125683. frontUVs?: Vector4;
  125684. backUVs?: Vector4;
  125685. instance?: Mesh;
  125686. invertUV?: boolean;
  125687. uvs?: Vector2[];
  125688. colors?: Color4[];
  125689. }, scene?: Nullable<Scene>): Mesh;
  125690. }
  125691. }
  125692. declare module BABYLON {
  125693. /**
  125694. * Class containing static functions to help procedurally build meshes
  125695. */
  125696. export class ShapeBuilder {
  125697. /**
  125698. * 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.
  125699. * * 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.
  125700. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125701. * * 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.
  125702. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125703. * * 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
  125704. * * 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
  125705. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125708. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125710. * @param name defines the name of the mesh
  125711. * @param options defines the options used to create the mesh
  125712. * @param scene defines the hosting scene
  125713. * @returns the extruded shape mesh
  125714. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125715. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125716. */
  125717. static ExtrudeShape(name: string, options: {
  125718. shape: Vector3[];
  125719. path: Vector3[];
  125720. scale?: number;
  125721. rotation?: number;
  125722. cap?: number;
  125723. updatable?: boolean;
  125724. sideOrientation?: number;
  125725. frontUVs?: Vector4;
  125726. backUVs?: Vector4;
  125727. instance?: Mesh;
  125728. invertUV?: boolean;
  125729. }, scene?: Nullable<Scene>): Mesh;
  125730. /**
  125731. * Creates an custom extruded shape mesh.
  125732. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125733. * * 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.
  125734. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125735. * * 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
  125736. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125737. * * 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
  125738. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125739. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125740. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125741. * * 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
  125742. * * 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
  125743. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125746. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125748. * @param name defines the name of the mesh
  125749. * @param options defines the options used to create the mesh
  125750. * @param scene defines the hosting scene
  125751. * @returns the custom extruded shape mesh
  125752. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  125753. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125755. */
  125756. static ExtrudeShapeCustom(name: string, options: {
  125757. shape: Vector3[];
  125758. path: Vector3[];
  125759. scaleFunction?: any;
  125760. rotationFunction?: any;
  125761. ribbonCloseArray?: boolean;
  125762. ribbonClosePath?: boolean;
  125763. cap?: number;
  125764. updatable?: boolean;
  125765. sideOrientation?: number;
  125766. frontUVs?: Vector4;
  125767. backUVs?: Vector4;
  125768. instance?: Mesh;
  125769. invertUV?: boolean;
  125770. }, scene?: Nullable<Scene>): Mesh;
  125771. private static _ExtrudeShapeGeneric;
  125772. }
  125773. }
  125774. declare module BABYLON {
  125775. /**
  125776. * AmmoJS Physics plugin
  125777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  125778. * @see https://github.com/kripken/ammo.js/
  125779. */
  125780. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  125781. private _useDeltaForWorldStep;
  125782. /**
  125783. * Reference to the Ammo library
  125784. */
  125785. bjsAMMO: any;
  125786. /**
  125787. * Created ammoJS world which physics bodies are added to
  125788. */
  125789. world: any;
  125790. /**
  125791. * Name of the plugin
  125792. */
  125793. name: string;
  125794. private _timeStep;
  125795. private _fixedTimeStep;
  125796. private _maxSteps;
  125797. private _tmpQuaternion;
  125798. private _tmpAmmoTransform;
  125799. private _tmpAmmoQuaternion;
  125800. private _tmpAmmoConcreteContactResultCallback;
  125801. private _collisionConfiguration;
  125802. private _dispatcher;
  125803. private _overlappingPairCache;
  125804. private _solver;
  125805. private _softBodySolver;
  125806. private _tmpAmmoVectorA;
  125807. private _tmpAmmoVectorB;
  125808. private _tmpAmmoVectorC;
  125809. private _tmpAmmoVectorD;
  125810. private _tmpContactCallbackResult;
  125811. private _tmpAmmoVectorRCA;
  125812. private _tmpAmmoVectorRCB;
  125813. private _raycastResult;
  125814. private static readonly DISABLE_COLLISION_FLAG;
  125815. private static readonly KINEMATIC_FLAG;
  125816. private static readonly DISABLE_DEACTIVATION_FLAG;
  125817. /**
  125818. * Initializes the ammoJS plugin
  125819. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  125820. * @param ammoInjection can be used to inject your own ammo reference
  125821. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  125822. */
  125823. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  125824. /**
  125825. * Sets the gravity of the physics world (m/(s^2))
  125826. * @param gravity Gravity to set
  125827. */
  125828. setGravity(gravity: Vector3): void;
  125829. /**
  125830. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  125831. * @param timeStep timestep to use in seconds
  125832. */
  125833. setTimeStep(timeStep: number): void;
  125834. /**
  125835. * 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)
  125836. * @param fixedTimeStep fixedTimeStep to use in seconds
  125837. */
  125838. setFixedTimeStep(fixedTimeStep: number): void;
  125839. /**
  125840. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  125841. * @param maxSteps the maximum number of steps by the physics engine per frame
  125842. */
  125843. setMaxSteps(maxSteps: number): void;
  125844. /**
  125845. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  125846. * @returns the current timestep in seconds
  125847. */
  125848. getTimeStep(): number;
  125849. /**
  125850. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  125851. */
  125852. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  125853. private _isImpostorInContact;
  125854. private _isImpostorPairInContact;
  125855. private _stepSimulation;
  125856. /**
  125857. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  125858. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  125859. * After the step the babylon meshes are set to the position of the physics imposters
  125860. * @param delta amount of time to step forward
  125861. * @param impostors array of imposters to update before/after the step
  125862. */
  125863. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  125864. /**
  125865. * Update babylon mesh to match physics world object
  125866. * @param impostor imposter to match
  125867. */
  125868. private _afterSoftStep;
  125869. /**
  125870. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  125871. * @param impostor imposter to match
  125872. */
  125873. private _ropeStep;
  125874. /**
  125875. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  125876. * @param impostor imposter to match
  125877. */
  125878. private _softbodyOrClothStep;
  125879. private _tmpVector;
  125880. private _tmpMatrix;
  125881. /**
  125882. * Applies an impulse on the imposter
  125883. * @param impostor imposter to apply impulse to
  125884. * @param force amount of force to be applied to the imposter
  125885. * @param contactPoint the location to apply the impulse on the imposter
  125886. */
  125887. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125888. /**
  125889. * Applies a force on the imposter
  125890. * @param impostor imposter to apply force
  125891. * @param force amount of force to be applied to the imposter
  125892. * @param contactPoint the location to apply the force on the imposter
  125893. */
  125894. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125895. /**
  125896. * Creates a physics body using the plugin
  125897. * @param impostor the imposter to create the physics body on
  125898. */
  125899. generatePhysicsBody(impostor: PhysicsImpostor): void;
  125900. /**
  125901. * Removes the physics body from the imposter and disposes of the body's memory
  125902. * @param impostor imposter to remove the physics body from
  125903. */
  125904. removePhysicsBody(impostor: PhysicsImpostor): void;
  125905. /**
  125906. * Generates a joint
  125907. * @param impostorJoint the imposter joint to create the joint with
  125908. */
  125909. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  125910. /**
  125911. * Removes a joint
  125912. * @param impostorJoint the imposter joint to remove the joint from
  125913. */
  125914. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  125915. private _addMeshVerts;
  125916. /**
  125917. * Initialise the soft body vertices to match its object's (mesh) vertices
  125918. * Softbody vertices (nodes) are in world space and to match this
  125919. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  125920. * @param impostor to create the softbody for
  125921. */
  125922. private _softVertexData;
  125923. /**
  125924. * Create an impostor's soft body
  125925. * @param impostor to create the softbody for
  125926. */
  125927. private _createSoftbody;
  125928. /**
  125929. * Create cloth for an impostor
  125930. * @param impostor to create the softbody for
  125931. */
  125932. private _createCloth;
  125933. /**
  125934. * Create rope for an impostor
  125935. * @param impostor to create the softbody for
  125936. */
  125937. private _createRope;
  125938. /**
  125939. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  125940. * @param impostor to create the custom physics shape for
  125941. */
  125942. private _createCustom;
  125943. private _addHullVerts;
  125944. private _createShape;
  125945. /**
  125946. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  125947. * @param impostor imposter containing the physics body and babylon object
  125948. */
  125949. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  125950. /**
  125951. * Sets the babylon object's position/rotation from the physics body's position/rotation
  125952. * @param impostor imposter containing the physics body and babylon object
  125953. * @param newPosition new position
  125954. * @param newRotation new rotation
  125955. */
  125956. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  125957. /**
  125958. * If this plugin is supported
  125959. * @returns true if its supported
  125960. */
  125961. isSupported(): boolean;
  125962. /**
  125963. * Sets the linear velocity of the physics body
  125964. * @param impostor imposter to set the velocity on
  125965. * @param velocity velocity to set
  125966. */
  125967. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125968. /**
  125969. * Sets the angular velocity of the physics body
  125970. * @param impostor imposter to set the velocity on
  125971. * @param velocity velocity to set
  125972. */
  125973. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125974. /**
  125975. * gets the linear velocity
  125976. * @param impostor imposter to get linear velocity from
  125977. * @returns linear velocity
  125978. */
  125979. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125980. /**
  125981. * gets the angular velocity
  125982. * @param impostor imposter to get angular velocity from
  125983. * @returns angular velocity
  125984. */
  125985. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125986. /**
  125987. * Sets the mass of physics body
  125988. * @param impostor imposter to set the mass on
  125989. * @param mass mass to set
  125990. */
  125991. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  125992. /**
  125993. * Gets the mass of the physics body
  125994. * @param impostor imposter to get the mass from
  125995. * @returns mass
  125996. */
  125997. getBodyMass(impostor: PhysicsImpostor): number;
  125998. /**
  125999. * Gets friction of the impostor
  126000. * @param impostor impostor to get friction from
  126001. * @returns friction value
  126002. */
  126003. getBodyFriction(impostor: PhysicsImpostor): number;
  126004. /**
  126005. * Sets friction of the impostor
  126006. * @param impostor impostor to set friction on
  126007. * @param friction friction value
  126008. */
  126009. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  126010. /**
  126011. * Gets restitution of the impostor
  126012. * @param impostor impostor to get restitution from
  126013. * @returns restitution value
  126014. */
  126015. getBodyRestitution(impostor: PhysicsImpostor): number;
  126016. /**
  126017. * Sets resitution of the impostor
  126018. * @param impostor impostor to set resitution on
  126019. * @param restitution resitution value
  126020. */
  126021. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  126022. /**
  126023. * Gets pressure inside the impostor
  126024. * @param impostor impostor to get pressure from
  126025. * @returns pressure value
  126026. */
  126027. getBodyPressure(impostor: PhysicsImpostor): number;
  126028. /**
  126029. * Sets pressure inside a soft body impostor
  126030. * Cloth and rope must remain 0 pressure
  126031. * @param impostor impostor to set pressure on
  126032. * @param pressure pressure value
  126033. */
  126034. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  126035. /**
  126036. * Gets stiffness of the impostor
  126037. * @param impostor impostor to get stiffness from
  126038. * @returns pressure value
  126039. */
  126040. getBodyStiffness(impostor: PhysicsImpostor): number;
  126041. /**
  126042. * Sets stiffness of the impostor
  126043. * @param impostor impostor to set stiffness on
  126044. * @param stiffness stiffness value from 0 to 1
  126045. */
  126046. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  126047. /**
  126048. * Gets velocityIterations of the impostor
  126049. * @param impostor impostor to get velocity iterations from
  126050. * @returns velocityIterations value
  126051. */
  126052. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  126053. /**
  126054. * Sets velocityIterations of the impostor
  126055. * @param impostor impostor to set velocity iterations on
  126056. * @param velocityIterations velocityIterations value
  126057. */
  126058. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  126059. /**
  126060. * Gets positionIterations of the impostor
  126061. * @param impostor impostor to get position iterations from
  126062. * @returns positionIterations value
  126063. */
  126064. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  126065. /**
  126066. * Sets positionIterations of the impostor
  126067. * @param impostor impostor to set position on
  126068. * @param positionIterations positionIterations value
  126069. */
  126070. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  126071. /**
  126072. * Append an anchor to a cloth object
  126073. * @param impostor is the cloth impostor to add anchor to
  126074. * @param otherImpostor is the rigid impostor to anchor to
  126075. * @param width ratio across width from 0 to 1
  126076. * @param height ratio up height from 0 to 1
  126077. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  126078. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  126079. */
  126080. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  126081. /**
  126082. * Append an hook to a rope object
  126083. * @param impostor is the rope impostor to add hook to
  126084. * @param otherImpostor is the rigid impostor to hook to
  126085. * @param length ratio along the rope from 0 to 1
  126086. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  126087. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  126088. */
  126089. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  126090. /**
  126091. * Sleeps the physics body and stops it from being active
  126092. * @param impostor impostor to sleep
  126093. */
  126094. sleepBody(impostor: PhysicsImpostor): void;
  126095. /**
  126096. * Activates the physics body
  126097. * @param impostor impostor to activate
  126098. */
  126099. wakeUpBody(impostor: PhysicsImpostor): void;
  126100. /**
  126101. * Updates the distance parameters of the joint
  126102. * @param joint joint to update
  126103. * @param maxDistance maximum distance of the joint
  126104. * @param minDistance minimum distance of the joint
  126105. */
  126106. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  126107. /**
  126108. * Sets a motor on the joint
  126109. * @param joint joint to set motor on
  126110. * @param speed speed of the motor
  126111. * @param maxForce maximum force of the motor
  126112. * @param motorIndex index of the motor
  126113. */
  126114. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  126115. /**
  126116. * Sets the motors limit
  126117. * @param joint joint to set limit on
  126118. * @param upperLimit upper limit
  126119. * @param lowerLimit lower limit
  126120. */
  126121. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  126122. /**
  126123. * Syncs the position and rotation of a mesh with the impostor
  126124. * @param mesh mesh to sync
  126125. * @param impostor impostor to update the mesh with
  126126. */
  126127. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  126128. /**
  126129. * Gets the radius of the impostor
  126130. * @param impostor impostor to get radius from
  126131. * @returns the radius
  126132. */
  126133. getRadius(impostor: PhysicsImpostor): number;
  126134. /**
  126135. * Gets the box size of the impostor
  126136. * @param impostor impostor to get box size from
  126137. * @param result the resulting box size
  126138. */
  126139. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  126140. /**
  126141. * Disposes of the impostor
  126142. */
  126143. dispose(): void;
  126144. /**
  126145. * Does a raycast in the physics world
  126146. * @param from when should the ray start?
  126147. * @param to when should the ray end?
  126148. * @returns PhysicsRaycastResult
  126149. */
  126150. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  126151. }
  126152. }
  126153. declare module BABYLON {
  126154. interface AbstractScene {
  126155. /**
  126156. * The list of reflection probes added to the scene
  126157. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  126158. */
  126159. reflectionProbes: Array<ReflectionProbe>;
  126160. /**
  126161. * Removes the given reflection probe from this scene.
  126162. * @param toRemove The reflection probe to remove
  126163. * @returns The index of the removed reflection probe
  126164. */
  126165. removeReflectionProbe(toRemove: ReflectionProbe): number;
  126166. /**
  126167. * Adds the given reflection probe to this scene.
  126168. * @param newReflectionProbe The reflection probe to add
  126169. */
  126170. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  126171. }
  126172. /**
  126173. * Class used to generate realtime reflection / refraction cube textures
  126174. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  126175. */
  126176. export class ReflectionProbe {
  126177. /** defines the name of the probe */
  126178. name: string;
  126179. private _scene;
  126180. private _renderTargetTexture;
  126181. private _projectionMatrix;
  126182. private _viewMatrix;
  126183. private _target;
  126184. private _add;
  126185. private _attachedMesh;
  126186. private _invertYAxis;
  126187. /** Gets or sets probe position (center of the cube map) */
  126188. position: Vector3;
  126189. /**
  126190. * Creates a new reflection probe
  126191. * @param name defines the name of the probe
  126192. * @param size defines the texture resolution (for each face)
  126193. * @param scene defines the hosting scene
  126194. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  126195. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  126196. */
  126197. constructor(
  126198. /** defines the name of the probe */
  126199. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  126200. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  126201. get samples(): number;
  126202. set samples(value: number);
  126203. /** Gets or sets the refresh rate to use (on every frame by default) */
  126204. get refreshRate(): number;
  126205. set refreshRate(value: number);
  126206. /**
  126207. * Gets the hosting scene
  126208. * @returns a Scene
  126209. */
  126210. getScene(): Scene;
  126211. /** Gets the internal CubeTexture used to render to */
  126212. get cubeTexture(): RenderTargetTexture;
  126213. /** Gets the list of meshes to render */
  126214. get renderList(): Nullable<AbstractMesh[]>;
  126215. /**
  126216. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  126217. * @param mesh defines the mesh to attach to
  126218. */
  126219. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  126220. /**
  126221. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  126222. * @param renderingGroupId The rendering group id corresponding to its index
  126223. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126224. */
  126225. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  126226. /**
  126227. * Clean all associated resources
  126228. */
  126229. dispose(): void;
  126230. /**
  126231. * Converts the reflection probe information to a readable string for debug purpose.
  126232. * @param fullDetails Supports for multiple levels of logging within scene loading
  126233. * @returns the human readable reflection probe info
  126234. */
  126235. toString(fullDetails?: boolean): string;
  126236. /**
  126237. * Get the class name of the relfection probe.
  126238. * @returns "ReflectionProbe"
  126239. */
  126240. getClassName(): string;
  126241. /**
  126242. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  126243. * @returns The JSON representation of the texture
  126244. */
  126245. serialize(): any;
  126246. /**
  126247. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  126248. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  126249. * @param scene Define the scene the parsed reflection probe should be instantiated in
  126250. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  126251. * @returns The parsed reflection probe if successful
  126252. */
  126253. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  126254. }
  126255. }
  126256. declare module BABYLON {
  126257. /** @hidden */
  126258. export var _BabylonLoaderRegistered: boolean;
  126259. /**
  126260. * Helps setting up some configuration for the babylon file loader.
  126261. */
  126262. export class BabylonFileLoaderConfiguration {
  126263. /**
  126264. * The loader does not allow injecting custom physix engine into the plugins.
  126265. * Unfortunately in ES6, we need to manually inject them into the plugin.
  126266. * So you could set this variable to your engine import to make it work.
  126267. */
  126268. static LoaderInjectedPhysicsEngine: any;
  126269. }
  126270. }
  126271. declare module BABYLON {
  126272. /**
  126273. * The Physically based simple base material of BJS.
  126274. *
  126275. * This enables better naming and convention enforcements on top of the pbrMaterial.
  126276. * It is used as the base class for both the specGloss and metalRough conventions.
  126277. */
  126278. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  126279. /**
  126280. * Number of Simultaneous lights allowed on the material.
  126281. */
  126282. maxSimultaneousLights: number;
  126283. /**
  126284. * If sets to true, disables all the lights affecting the material.
  126285. */
  126286. disableLighting: boolean;
  126287. /**
  126288. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  126289. */
  126290. environmentTexture: BaseTexture;
  126291. /**
  126292. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  126293. */
  126294. invertNormalMapX: boolean;
  126295. /**
  126296. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  126297. */
  126298. invertNormalMapY: boolean;
  126299. /**
  126300. * Normal map used in the model.
  126301. */
  126302. normalTexture: BaseTexture;
  126303. /**
  126304. * Emissivie color used to self-illuminate the model.
  126305. */
  126306. emissiveColor: Color3;
  126307. /**
  126308. * Emissivie texture used to self-illuminate the model.
  126309. */
  126310. emissiveTexture: BaseTexture;
  126311. /**
  126312. * Occlusion Channel Strenght.
  126313. */
  126314. occlusionStrength: number;
  126315. /**
  126316. * Occlusion Texture of the material (adding extra occlusion effects).
  126317. */
  126318. occlusionTexture: BaseTexture;
  126319. /**
  126320. * Defines the alpha limits in alpha test mode.
  126321. */
  126322. alphaCutOff: number;
  126323. /**
  126324. * Gets the current double sided mode.
  126325. */
  126326. get doubleSided(): boolean;
  126327. /**
  126328. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126329. */
  126330. set doubleSided(value: boolean);
  126331. /**
  126332. * Stores the pre-calculated light information of a mesh in a texture.
  126333. */
  126334. lightmapTexture: BaseTexture;
  126335. /**
  126336. * If true, the light map contains occlusion information instead of lighting info.
  126337. */
  126338. useLightmapAsShadowmap: boolean;
  126339. /**
  126340. * Instantiates a new PBRMaterial instance.
  126341. *
  126342. * @param name The material name
  126343. * @param scene The scene the material will be use in.
  126344. */
  126345. constructor(name: string, scene: Scene);
  126346. getClassName(): string;
  126347. }
  126348. }
  126349. declare module BABYLON {
  126350. /**
  126351. * The PBR material of BJS following the metal roughness convention.
  126352. *
  126353. * This fits to the PBR convention in the GLTF definition:
  126354. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  126355. */
  126356. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  126357. /**
  126358. * The base color has two different interpretations depending on the value of metalness.
  126359. * When the material is a metal, the base color is the specific measured reflectance value
  126360. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  126361. * of the material.
  126362. */
  126363. baseColor: Color3;
  126364. /**
  126365. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  126366. * well as opacity information in the alpha channel.
  126367. */
  126368. baseTexture: BaseTexture;
  126369. /**
  126370. * Specifies the metallic scalar value of the material.
  126371. * Can also be used to scale the metalness values of the metallic texture.
  126372. */
  126373. metallic: number;
  126374. /**
  126375. * Specifies the roughness scalar value of the material.
  126376. * Can also be used to scale the roughness values of the metallic texture.
  126377. */
  126378. roughness: number;
  126379. /**
  126380. * Texture containing both the metallic value in the B channel and the
  126381. * roughness value in the G channel to keep better precision.
  126382. */
  126383. metallicRoughnessTexture: BaseTexture;
  126384. /**
  126385. * Instantiates a new PBRMetalRoughnessMaterial instance.
  126386. *
  126387. * @param name The material name
  126388. * @param scene The scene the material will be use in.
  126389. */
  126390. constructor(name: string, scene: Scene);
  126391. /**
  126392. * Return the currrent class name of the material.
  126393. */
  126394. getClassName(): string;
  126395. /**
  126396. * Makes a duplicate of the current material.
  126397. * @param name - name to use for the new material.
  126398. */
  126399. clone(name: string): PBRMetallicRoughnessMaterial;
  126400. /**
  126401. * Serialize the material to a parsable JSON object.
  126402. */
  126403. serialize(): any;
  126404. /**
  126405. * Parses a JSON object correponding to the serialize function.
  126406. */
  126407. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  126408. }
  126409. }
  126410. declare module BABYLON {
  126411. /**
  126412. * The PBR material of BJS following the specular glossiness convention.
  126413. *
  126414. * This fits to the PBR convention in the GLTF definition:
  126415. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  126416. */
  126417. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  126418. /**
  126419. * Specifies the diffuse color of the material.
  126420. */
  126421. diffuseColor: Color3;
  126422. /**
  126423. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  126424. * channel.
  126425. */
  126426. diffuseTexture: BaseTexture;
  126427. /**
  126428. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  126429. */
  126430. specularColor: Color3;
  126431. /**
  126432. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  126433. */
  126434. glossiness: number;
  126435. /**
  126436. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  126437. */
  126438. specularGlossinessTexture: BaseTexture;
  126439. /**
  126440. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  126441. *
  126442. * @param name The material name
  126443. * @param scene The scene the material will be use in.
  126444. */
  126445. constructor(name: string, scene: Scene);
  126446. /**
  126447. * Return the currrent class name of the material.
  126448. */
  126449. getClassName(): string;
  126450. /**
  126451. * Makes a duplicate of the current material.
  126452. * @param name - name to use for the new material.
  126453. */
  126454. clone(name: string): PBRSpecularGlossinessMaterial;
  126455. /**
  126456. * Serialize the material to a parsable JSON object.
  126457. */
  126458. serialize(): any;
  126459. /**
  126460. * Parses a JSON object correponding to the serialize function.
  126461. */
  126462. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  126463. }
  126464. }
  126465. declare module BABYLON {
  126466. /**
  126467. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  126468. * It can help converting any input color in a desired output one. This can then be used to create effects
  126469. * from sepia, black and white to sixties or futuristic rendering...
  126470. *
  126471. * The only supported format is currently 3dl.
  126472. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  126473. */
  126474. export class ColorGradingTexture extends BaseTexture {
  126475. /**
  126476. * The current texture matrix. (will always be identity in color grading texture)
  126477. */
  126478. private _textureMatrix;
  126479. /**
  126480. * The texture URL.
  126481. */
  126482. url: string;
  126483. /**
  126484. * Empty line regex stored for GC.
  126485. */
  126486. private static _noneEmptyLineRegex;
  126487. private _engine;
  126488. /**
  126489. * Instantiates a ColorGradingTexture from the following parameters.
  126490. *
  126491. * @param url The location of the color gradind data (currently only supporting 3dl)
  126492. * @param scene The scene the texture will be used in
  126493. */
  126494. constructor(url: string, scene: Scene);
  126495. /**
  126496. * Returns the texture matrix used in most of the material.
  126497. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  126498. */
  126499. getTextureMatrix(): Matrix;
  126500. /**
  126501. * Occurs when the file being loaded is a .3dl LUT file.
  126502. */
  126503. private load3dlTexture;
  126504. /**
  126505. * Starts the loading process of the texture.
  126506. */
  126507. private loadTexture;
  126508. /**
  126509. * Clones the color gradind texture.
  126510. */
  126511. clone(): ColorGradingTexture;
  126512. /**
  126513. * Called during delayed load for textures.
  126514. */
  126515. delayLoad(): void;
  126516. /**
  126517. * Parses a color grading texture serialized by Babylon.
  126518. * @param parsedTexture The texture information being parsedTexture
  126519. * @param scene The scene to load the texture in
  126520. * @param rootUrl The root url of the data assets to load
  126521. * @return A color gradind texture
  126522. */
  126523. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  126524. /**
  126525. * Serializes the LUT texture to json format.
  126526. */
  126527. serialize(): any;
  126528. }
  126529. }
  126530. declare module BABYLON {
  126531. /**
  126532. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  126533. */
  126534. export class EquiRectangularCubeTexture extends BaseTexture {
  126535. /** The six faces of the cube. */
  126536. private static _FacesMapping;
  126537. private _noMipmap;
  126538. private _onLoad;
  126539. private _onError;
  126540. /** The size of the cubemap. */
  126541. private _size;
  126542. /** The buffer of the image. */
  126543. private _buffer;
  126544. /** The width of the input image. */
  126545. private _width;
  126546. /** The height of the input image. */
  126547. private _height;
  126548. /** The URL to the image. */
  126549. url: string;
  126550. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  126551. coordinatesMode: number;
  126552. /**
  126553. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  126554. * @param url The location of the image
  126555. * @param scene The scene the texture will be used in
  126556. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  126557. * @param noMipmap Forces to not generate the mipmap if true
  126558. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  126559. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  126560. * @param onLoad — defines a callback called when texture is loaded
  126561. * @param onError — defines a callback called if there is an error
  126562. */
  126563. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  126564. /**
  126565. * Load the image data, by putting the image on a canvas and extracting its buffer.
  126566. */
  126567. private loadImage;
  126568. /**
  126569. * Convert the image buffer into a cubemap and create a CubeTexture.
  126570. */
  126571. private loadTexture;
  126572. /**
  126573. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  126574. * @param buffer The ArrayBuffer that should be converted.
  126575. * @returns The buffer as Float32Array.
  126576. */
  126577. private getFloat32ArrayFromArrayBuffer;
  126578. /**
  126579. * Get the current class name of the texture useful for serialization or dynamic coding.
  126580. * @returns "EquiRectangularCubeTexture"
  126581. */
  126582. getClassName(): string;
  126583. /**
  126584. * Create a clone of the current EquiRectangularCubeTexture and return it.
  126585. * @returns A clone of the current EquiRectangularCubeTexture.
  126586. */
  126587. clone(): EquiRectangularCubeTexture;
  126588. }
  126589. }
  126590. declare module BABYLON {
  126591. /**
  126592. * Based on jsTGALoader - Javascript loader for TGA file
  126593. * By Vincent Thibault
  126594. * @see http://blog.robrowser.com/javascript-tga-loader.html
  126595. */
  126596. export class TGATools {
  126597. private static _TYPE_INDEXED;
  126598. private static _TYPE_RGB;
  126599. private static _TYPE_GREY;
  126600. private static _TYPE_RLE_INDEXED;
  126601. private static _TYPE_RLE_RGB;
  126602. private static _TYPE_RLE_GREY;
  126603. private static _ORIGIN_MASK;
  126604. private static _ORIGIN_SHIFT;
  126605. private static _ORIGIN_BL;
  126606. private static _ORIGIN_BR;
  126607. private static _ORIGIN_UL;
  126608. private static _ORIGIN_UR;
  126609. /**
  126610. * Gets the header of a TGA file
  126611. * @param data defines the TGA data
  126612. * @returns the header
  126613. */
  126614. static GetTGAHeader(data: Uint8Array): any;
  126615. /**
  126616. * Uploads TGA content to a Babylon Texture
  126617. * @hidden
  126618. */
  126619. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  126620. /** @hidden */
  126621. 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;
  126622. /** @hidden */
  126623. 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;
  126624. /** @hidden */
  126625. 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;
  126626. /** @hidden */
  126627. 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;
  126628. /** @hidden */
  126629. 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;
  126630. /** @hidden */
  126631. 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;
  126632. }
  126633. }
  126634. declare module BABYLON {
  126635. /**
  126636. * Implementation of the TGA Texture Loader.
  126637. * @hidden
  126638. */
  126639. export class _TGATextureLoader implements IInternalTextureLoader {
  126640. /**
  126641. * Defines wether the loader supports cascade loading the different faces.
  126642. */
  126643. readonly supportCascades: boolean;
  126644. /**
  126645. * This returns if the loader support the current file information.
  126646. * @param extension defines the file extension of the file being loaded
  126647. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126648. * @param fallback defines the fallback internal texture if any
  126649. * @param isBase64 defines whether the texture is encoded as a base64
  126650. * @param isBuffer defines whether the texture data are stored as a buffer
  126651. * @returns true if the loader can load the specified file
  126652. */
  126653. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  126654. /**
  126655. * Transform the url before loading if required.
  126656. * @param rootUrl the url of the texture
  126657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126658. * @returns the transformed texture
  126659. */
  126660. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  126661. /**
  126662. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  126663. * @param rootUrl the url of the texture
  126664. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126665. * @returns the fallback texture
  126666. */
  126667. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  126668. /**
  126669. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  126670. * @param data contains the texture data
  126671. * @param texture defines the BabylonJS internal texture
  126672. * @param createPolynomials will be true if polynomials have been requested
  126673. * @param onLoad defines the callback to trigger once the texture is ready
  126674. * @param onError defines the callback to trigger in case of error
  126675. */
  126676. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126677. /**
  126678. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  126679. * @param data contains the texture data
  126680. * @param texture defines the BabylonJS internal texture
  126681. * @param callback defines the method to call once ready to upload
  126682. */
  126683. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126684. }
  126685. }
  126686. declare module BABYLON {
  126687. /**
  126688. * Info about the .basis files
  126689. */
  126690. class BasisFileInfo {
  126691. /**
  126692. * If the file has alpha
  126693. */
  126694. hasAlpha: boolean;
  126695. /**
  126696. * Info about each image of the basis file
  126697. */
  126698. images: Array<{
  126699. levels: Array<{
  126700. width: number;
  126701. height: number;
  126702. transcodedPixels: ArrayBufferView;
  126703. }>;
  126704. }>;
  126705. }
  126706. /**
  126707. * Result of transcoding a basis file
  126708. */
  126709. class TranscodeResult {
  126710. /**
  126711. * Info about the .basis file
  126712. */
  126713. fileInfo: BasisFileInfo;
  126714. /**
  126715. * Format to use when loading the file
  126716. */
  126717. format: number;
  126718. }
  126719. /**
  126720. * Configuration options for the Basis transcoder
  126721. */
  126722. export class BasisTranscodeConfiguration {
  126723. /**
  126724. * Supported compression formats used to determine the supported output format of the transcoder
  126725. */
  126726. supportedCompressionFormats?: {
  126727. /**
  126728. * etc1 compression format
  126729. */
  126730. etc1?: boolean;
  126731. /**
  126732. * s3tc compression format
  126733. */
  126734. s3tc?: boolean;
  126735. /**
  126736. * pvrtc compression format
  126737. */
  126738. pvrtc?: boolean;
  126739. /**
  126740. * etc2 compression format
  126741. */
  126742. etc2?: boolean;
  126743. };
  126744. /**
  126745. * If mipmap levels should be loaded for transcoded images (Default: true)
  126746. */
  126747. loadMipmapLevels?: boolean;
  126748. /**
  126749. * Index of a single image to load (Default: all images)
  126750. */
  126751. loadSingleImage?: number;
  126752. }
  126753. /**
  126754. * Used to load .Basis files
  126755. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  126756. */
  126757. export class BasisTools {
  126758. private static _IgnoreSupportedFormats;
  126759. /**
  126760. * URL to use when loading the basis transcoder
  126761. */
  126762. static JSModuleURL: string;
  126763. /**
  126764. * URL to use when loading the wasm module for the transcoder
  126765. */
  126766. static WasmModuleURL: string;
  126767. /**
  126768. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  126769. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  126770. * @returns internal format corresponding to the Basis format
  126771. */
  126772. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  126773. private static _WorkerPromise;
  126774. private static _Worker;
  126775. private static _actionId;
  126776. private static _CreateWorkerAsync;
  126777. /**
  126778. * Transcodes a loaded image file to compressed pixel data
  126779. * @param imageData image data to transcode
  126780. * @param config configuration options for the transcoding
  126781. * @returns a promise resulting in the transcoded image
  126782. */
  126783. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  126784. /**
  126785. * Loads a texture from the transcode result
  126786. * @param texture texture load to
  126787. * @param transcodeResult the result of transcoding the basis file to load from
  126788. */
  126789. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  126790. }
  126791. }
  126792. declare module BABYLON {
  126793. /**
  126794. * Loader for .basis file format
  126795. */
  126796. export class _BasisTextureLoader implements IInternalTextureLoader {
  126797. /**
  126798. * Defines whether the loader supports cascade loading the different faces.
  126799. */
  126800. readonly supportCascades: boolean;
  126801. /**
  126802. * This returns if the loader support the current file information.
  126803. * @param extension defines the file extension of the file being loaded
  126804. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126805. * @param fallback defines the fallback internal texture if any
  126806. * @param isBase64 defines whether the texture is encoded as a base64
  126807. * @param isBuffer defines whether the texture data are stored as a buffer
  126808. * @returns true if the loader can load the specified file
  126809. */
  126810. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  126811. /**
  126812. * Transform the url before loading if required.
  126813. * @param rootUrl the url of the texture
  126814. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126815. * @returns the transformed texture
  126816. */
  126817. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  126818. /**
  126819. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  126820. * @param rootUrl the url of the texture
  126821. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126822. * @returns the fallback texture
  126823. */
  126824. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  126825. /**
  126826. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  126827. * @param data contains the texture data
  126828. * @param texture defines the BabylonJS internal texture
  126829. * @param createPolynomials will be true if polynomials have been requested
  126830. * @param onLoad defines the callback to trigger once the texture is ready
  126831. * @param onError defines the callback to trigger in case of error
  126832. */
  126833. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126834. /**
  126835. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  126836. * @param data contains the texture data
  126837. * @param texture defines the BabylonJS internal texture
  126838. * @param callback defines the method to call once ready to upload
  126839. */
  126840. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126841. }
  126842. }
  126843. declare module BABYLON {
  126844. /**
  126845. * 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.
  126846. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  126847. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  126848. */
  126849. export class CustomProceduralTexture extends ProceduralTexture {
  126850. private _animate;
  126851. private _time;
  126852. private _config;
  126853. private _texturePath;
  126854. /**
  126855. * Instantiates a new Custom Procedural Texture.
  126856. * 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.
  126857. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  126858. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  126859. * @param name Define the name of the texture
  126860. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  126861. * @param size Define the size of the texture to create
  126862. * @param scene Define the scene the texture belongs to
  126863. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  126864. * @param generateMipMaps Define if the texture should creates mip maps or not
  126865. */
  126866. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  126867. private _loadJson;
  126868. /**
  126869. * Is the texture ready to be used ? (rendered at least once)
  126870. * @returns true if ready, otherwise, false.
  126871. */
  126872. isReady(): boolean;
  126873. /**
  126874. * Render the texture to its associated render target.
  126875. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  126876. */
  126877. render(useCameraPostProcess?: boolean): void;
  126878. /**
  126879. * Update the list of dependant textures samplers in the shader.
  126880. */
  126881. updateTextures(): void;
  126882. /**
  126883. * Update the uniform values of the procedural texture in the shader.
  126884. */
  126885. updateShaderUniforms(): void;
  126886. /**
  126887. * Define if the texture animates or not.
  126888. */
  126889. get animate(): boolean;
  126890. set animate(value: boolean);
  126891. }
  126892. }
  126893. declare module BABYLON {
  126894. /** @hidden */
  126895. export var noisePixelShader: {
  126896. name: string;
  126897. shader: string;
  126898. };
  126899. }
  126900. declare module BABYLON {
  126901. /**
  126902. * Class used to generate noise procedural textures
  126903. */
  126904. export class NoiseProceduralTexture extends ProceduralTexture {
  126905. private _time;
  126906. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  126907. brightness: number;
  126908. /** Defines the number of octaves to process */
  126909. octaves: number;
  126910. /** Defines the level of persistence (0.8 by default) */
  126911. persistence: number;
  126912. /** Gets or sets animation speed factor (default is 1) */
  126913. animationSpeedFactor: number;
  126914. /**
  126915. * Creates a new NoiseProceduralTexture
  126916. * @param name defines the name fo the texture
  126917. * @param size defines the size of the texture (default is 256)
  126918. * @param scene defines the hosting scene
  126919. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  126920. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  126921. */
  126922. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  126923. private _updateShaderUniforms;
  126924. protected _getDefines(): string;
  126925. /** Generate the current state of the procedural texture */
  126926. render(useCameraPostProcess?: boolean): void;
  126927. /**
  126928. * Serializes this noise procedural texture
  126929. * @returns a serialized noise procedural texture object
  126930. */
  126931. serialize(): any;
  126932. /**
  126933. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  126934. * @param parsedTexture defines parsed texture data
  126935. * @param scene defines the current scene
  126936. * @param rootUrl defines the root URL containing noise procedural texture information
  126937. * @returns a parsed NoiseProceduralTexture
  126938. */
  126939. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  126940. }
  126941. }
  126942. declare module BABYLON {
  126943. /**
  126944. * Raw cube texture where the raw buffers are passed in
  126945. */
  126946. export class RawCubeTexture extends CubeTexture {
  126947. /**
  126948. * Creates a cube texture where the raw buffers are passed in.
  126949. * @param scene defines the scene the texture is attached to
  126950. * @param data defines the array of data to use to create each face
  126951. * @param size defines the size of the textures
  126952. * @param format defines the format of the data
  126953. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  126954. * @param generateMipMaps defines if the engine should generate the mip levels
  126955. * @param invertY defines if data must be stored with Y axis inverted
  126956. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  126957. * @param compression defines the compression used (null by default)
  126958. */
  126959. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  126960. /**
  126961. * Updates the raw cube texture.
  126962. * @param data defines the data to store
  126963. * @param format defines the data format
  126964. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  126965. * @param invertY defines if data must be stored with Y axis inverted
  126966. * @param compression defines the compression used (null by default)
  126967. * @param level defines which level of the texture to update
  126968. */
  126969. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  126970. /**
  126971. * Updates a raw cube texture with RGBD encoded data.
  126972. * @param data defines the array of data [mipmap][face] to use to create each face
  126973. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  126974. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  126975. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  126976. * @returns a promsie that resolves when the operation is complete
  126977. */
  126978. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  126979. /**
  126980. * Clones the raw cube texture.
  126981. * @return a new cube texture
  126982. */
  126983. clone(): CubeTexture;
  126984. /** @hidden */
  126985. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  126986. }
  126987. }
  126988. declare module BABYLON {
  126989. /**
  126990. * Class used to store 3D textures containing user data
  126991. */
  126992. export class RawTexture3D extends Texture {
  126993. /** Gets or sets the texture format to use */
  126994. format: number;
  126995. private _engine;
  126996. /**
  126997. * Create a new RawTexture3D
  126998. * @param data defines the data of the texture
  126999. * @param width defines the width of the texture
  127000. * @param height defines the height of the texture
  127001. * @param depth defines the depth of the texture
  127002. * @param format defines the texture format to use
  127003. * @param scene defines the hosting scene
  127004. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  127005. * @param invertY defines if texture must be stored with Y axis inverted
  127006. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127007. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  127008. */
  127009. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  127010. /** Gets or sets the texture format to use */
  127011. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  127012. /**
  127013. * Update the texture with new data
  127014. * @param data defines the data to store in the texture
  127015. */
  127016. update(data: ArrayBufferView): void;
  127017. }
  127018. }
  127019. declare module BABYLON {
  127020. /**
  127021. * Class used to store 2D array textures containing user data
  127022. */
  127023. export class RawTexture2DArray extends Texture {
  127024. /** Gets or sets the texture format to use */
  127025. format: number;
  127026. private _engine;
  127027. /**
  127028. * Create a new RawTexture2DArray
  127029. * @param data defines the data of the texture
  127030. * @param width defines the width of the texture
  127031. * @param height defines the height of the texture
  127032. * @param depth defines the number of layers of the texture
  127033. * @param format defines the texture format to use
  127034. * @param scene defines the hosting scene
  127035. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  127036. * @param invertY defines if texture must be stored with Y axis inverted
  127037. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127038. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  127039. */
  127040. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  127041. /** Gets or sets the texture format to use */
  127042. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  127043. /**
  127044. * Update the texture with new data
  127045. * @param data defines the data to store in the texture
  127046. */
  127047. update(data: ArrayBufferView): void;
  127048. }
  127049. }
  127050. declare module BABYLON {
  127051. /**
  127052. * Creates a refraction texture used by refraction channel of the standard material.
  127053. * It is like a mirror but to see through a material.
  127054. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  127055. */
  127056. export class RefractionTexture extends RenderTargetTexture {
  127057. /**
  127058. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  127059. * 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.
  127060. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  127061. */
  127062. refractionPlane: Plane;
  127063. /**
  127064. * Define how deep under the surface we should see.
  127065. */
  127066. depth: number;
  127067. /**
  127068. * Creates a refraction texture used by refraction channel of the standard material.
  127069. * It is like a mirror but to see through a material.
  127070. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  127071. * @param name Define the texture name
  127072. * @param size Define the size of the underlying texture
  127073. * @param scene Define the scene the refraction belongs to
  127074. * @param generateMipMaps Define if we need to generate mips level for the refraction
  127075. */
  127076. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  127077. /**
  127078. * Clone the refraction texture.
  127079. * @returns the cloned texture
  127080. */
  127081. clone(): RefractionTexture;
  127082. /**
  127083. * Serialize the texture to a JSON representation you could use in Parse later on
  127084. * @returns the serialized JSON representation
  127085. */
  127086. serialize(): any;
  127087. }
  127088. }
  127089. declare module BABYLON {
  127090. /**
  127091. * Defines the options related to the creation of an HtmlElementTexture
  127092. */
  127093. export interface IHtmlElementTextureOptions {
  127094. /**
  127095. * Defines wether mip maps should be created or not.
  127096. */
  127097. generateMipMaps?: boolean;
  127098. /**
  127099. * Defines the sampling mode of the texture.
  127100. */
  127101. samplingMode?: number;
  127102. /**
  127103. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  127104. */
  127105. engine: Nullable<ThinEngine>;
  127106. /**
  127107. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  127108. */
  127109. scene: Nullable<Scene>;
  127110. }
  127111. /**
  127112. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  127113. * To be as efficient as possible depending on your constraints nothing aside the first upload
  127114. * is automatically managed.
  127115. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  127116. * in your application.
  127117. *
  127118. * As the update is not automatic, you need to call them manually.
  127119. */
  127120. export class HtmlElementTexture extends BaseTexture {
  127121. /**
  127122. * The texture URL.
  127123. */
  127124. element: HTMLVideoElement | HTMLCanvasElement;
  127125. private static readonly DefaultOptions;
  127126. private _textureMatrix;
  127127. private _engine;
  127128. private _isVideo;
  127129. private _generateMipMaps;
  127130. private _samplingMode;
  127131. /**
  127132. * Instantiates a HtmlElementTexture from the following parameters.
  127133. *
  127134. * @param name Defines the name of the texture
  127135. * @param element Defines the video or canvas the texture is filled with
  127136. * @param options Defines the other none mandatory texture creation options
  127137. */
  127138. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  127139. private _createInternalTexture;
  127140. /**
  127141. * Returns the texture matrix used in most of the material.
  127142. */
  127143. getTextureMatrix(): Matrix;
  127144. /**
  127145. * Updates the content of the texture.
  127146. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  127147. */
  127148. update(invertY?: Nullable<boolean>): void;
  127149. }
  127150. }
  127151. declare module BABYLON {
  127152. /**
  127153. * Enum used to define the target of a block
  127154. */
  127155. export enum NodeMaterialBlockTargets {
  127156. /** Vertex shader */
  127157. Vertex = 1,
  127158. /** Fragment shader */
  127159. Fragment = 2,
  127160. /** Neutral */
  127161. Neutral = 4,
  127162. /** Vertex and Fragment */
  127163. VertexAndFragment = 3
  127164. }
  127165. }
  127166. declare module BABYLON {
  127167. /**
  127168. * Defines the kind of connection point for node based material
  127169. */
  127170. export enum NodeMaterialBlockConnectionPointTypes {
  127171. /** Float */
  127172. Float = 1,
  127173. /** Int */
  127174. Int = 2,
  127175. /** Vector2 */
  127176. Vector2 = 4,
  127177. /** Vector3 */
  127178. Vector3 = 8,
  127179. /** Vector4 */
  127180. Vector4 = 16,
  127181. /** Color3 */
  127182. Color3 = 32,
  127183. /** Color4 */
  127184. Color4 = 64,
  127185. /** Matrix */
  127186. Matrix = 128,
  127187. /** Detect type based on connection */
  127188. AutoDetect = 1024,
  127189. /** Output type that will be defined by input type */
  127190. BasedOnInput = 2048
  127191. }
  127192. }
  127193. declare module BABYLON {
  127194. /**
  127195. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  127196. */
  127197. export enum NodeMaterialBlockConnectionPointMode {
  127198. /** Value is an uniform */
  127199. Uniform = 0,
  127200. /** Value is a mesh attribute */
  127201. Attribute = 1,
  127202. /** Value is a varying between vertex and fragment shaders */
  127203. Varying = 2,
  127204. /** Mode is undefined */
  127205. Undefined = 3
  127206. }
  127207. }
  127208. declare module BABYLON {
  127209. /**
  127210. * Enum used to define system values e.g. values automatically provided by the system
  127211. */
  127212. export enum NodeMaterialSystemValues {
  127213. /** World */
  127214. World = 1,
  127215. /** View */
  127216. View = 2,
  127217. /** Projection */
  127218. Projection = 3,
  127219. /** ViewProjection */
  127220. ViewProjection = 4,
  127221. /** WorldView */
  127222. WorldView = 5,
  127223. /** WorldViewProjection */
  127224. WorldViewProjection = 6,
  127225. /** CameraPosition */
  127226. CameraPosition = 7,
  127227. /** Fog Color */
  127228. FogColor = 8,
  127229. /** Delta time */
  127230. DeltaTime = 9
  127231. }
  127232. }
  127233. declare module BABYLON {
  127234. /**
  127235. * Root class for all node material optimizers
  127236. */
  127237. export class NodeMaterialOptimizer {
  127238. /**
  127239. * Function used to optimize a NodeMaterial graph
  127240. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  127241. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  127242. */
  127243. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  127244. }
  127245. }
  127246. declare module BABYLON {
  127247. /**
  127248. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  127249. */
  127250. export class TransformBlock extends NodeMaterialBlock {
  127251. /**
  127252. * Defines the value to use to complement W value to transform it to a Vector4
  127253. */
  127254. complementW: number;
  127255. /**
  127256. * Defines the value to use to complement z value to transform it to a Vector4
  127257. */
  127258. complementZ: number;
  127259. /**
  127260. * Creates a new TransformBlock
  127261. * @param name defines the block name
  127262. */
  127263. constructor(name: string);
  127264. /**
  127265. * Gets the current class name
  127266. * @returns the class name
  127267. */
  127268. getClassName(): string;
  127269. /**
  127270. * Gets the vector input
  127271. */
  127272. get vector(): NodeMaterialConnectionPoint;
  127273. /**
  127274. * Gets the output component
  127275. */
  127276. get output(): NodeMaterialConnectionPoint;
  127277. /**
  127278. * Gets the matrix transform input
  127279. */
  127280. get transform(): NodeMaterialConnectionPoint;
  127281. protected _buildBlock(state: NodeMaterialBuildState): this;
  127282. serialize(): any;
  127283. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127284. protected _dumpPropertiesCode(): string;
  127285. }
  127286. }
  127287. declare module BABYLON {
  127288. /**
  127289. * Block used to output the vertex position
  127290. */
  127291. export class VertexOutputBlock extends NodeMaterialBlock {
  127292. /**
  127293. * Creates a new VertexOutputBlock
  127294. * @param name defines the block name
  127295. */
  127296. constructor(name: string);
  127297. /**
  127298. * Gets the current class name
  127299. * @returns the class name
  127300. */
  127301. getClassName(): string;
  127302. /**
  127303. * Gets the vector input component
  127304. */
  127305. get vector(): NodeMaterialConnectionPoint;
  127306. protected _buildBlock(state: NodeMaterialBuildState): this;
  127307. }
  127308. }
  127309. declare module BABYLON {
  127310. /**
  127311. * Block used to output the final color
  127312. */
  127313. export class FragmentOutputBlock extends NodeMaterialBlock {
  127314. /**
  127315. * Create a new FragmentOutputBlock
  127316. * @param name defines the block name
  127317. */
  127318. constructor(name: string);
  127319. /**
  127320. * Gets the current class name
  127321. * @returns the class name
  127322. */
  127323. getClassName(): string;
  127324. /**
  127325. * Gets the rgba input component
  127326. */
  127327. get rgba(): NodeMaterialConnectionPoint;
  127328. /**
  127329. * Gets the rgb input component
  127330. */
  127331. get rgb(): NodeMaterialConnectionPoint;
  127332. /**
  127333. * Gets the a input component
  127334. */
  127335. get a(): NodeMaterialConnectionPoint;
  127336. protected _buildBlock(state: NodeMaterialBuildState): this;
  127337. }
  127338. }
  127339. declare module BABYLON {
  127340. /**
  127341. * Block used to read a reflection texture from a sampler
  127342. */
  127343. export class ReflectionTextureBlock extends NodeMaterialBlock {
  127344. private _define3DName;
  127345. private _defineCubicName;
  127346. private _defineExplicitName;
  127347. private _defineProjectionName;
  127348. private _defineLocalCubicName;
  127349. private _defineSphericalName;
  127350. private _definePlanarName;
  127351. private _defineEquirectangularName;
  127352. private _defineMirroredEquirectangularFixedName;
  127353. private _defineEquirectangularFixedName;
  127354. private _defineSkyboxName;
  127355. private _cubeSamplerName;
  127356. private _2DSamplerName;
  127357. private _positionUVWName;
  127358. private _directionWName;
  127359. private _reflectionCoordsName;
  127360. private _reflection2DCoordsName;
  127361. private _reflectionColorName;
  127362. private _reflectionMatrixName;
  127363. /**
  127364. * Gets or sets the texture associated with the node
  127365. */
  127366. texture: Nullable<BaseTexture>;
  127367. /**
  127368. * Create a new TextureBlock
  127369. * @param name defines the block name
  127370. */
  127371. constructor(name: string);
  127372. /**
  127373. * Gets the current class name
  127374. * @returns the class name
  127375. */
  127376. getClassName(): string;
  127377. /**
  127378. * Gets the world position input component
  127379. */
  127380. get position(): NodeMaterialConnectionPoint;
  127381. /**
  127382. * Gets the world position input component
  127383. */
  127384. get worldPosition(): NodeMaterialConnectionPoint;
  127385. /**
  127386. * Gets the world normal input component
  127387. */
  127388. get worldNormal(): NodeMaterialConnectionPoint;
  127389. /**
  127390. * Gets the world input component
  127391. */
  127392. get world(): NodeMaterialConnectionPoint;
  127393. /**
  127394. * Gets the camera (or eye) position component
  127395. */
  127396. get cameraPosition(): NodeMaterialConnectionPoint;
  127397. /**
  127398. * Gets the view input component
  127399. */
  127400. get view(): NodeMaterialConnectionPoint;
  127401. /**
  127402. * Gets the rgb output component
  127403. */
  127404. get rgb(): NodeMaterialConnectionPoint;
  127405. /**
  127406. * Gets the r output component
  127407. */
  127408. get r(): NodeMaterialConnectionPoint;
  127409. /**
  127410. * Gets the g output component
  127411. */
  127412. get g(): NodeMaterialConnectionPoint;
  127413. /**
  127414. * Gets the b output component
  127415. */
  127416. get b(): NodeMaterialConnectionPoint;
  127417. autoConfigure(material: NodeMaterial): void;
  127418. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127419. isReady(): boolean;
  127420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127421. private _injectVertexCode;
  127422. private _writeOutput;
  127423. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127424. protected _dumpPropertiesCode(): string;
  127425. serialize(): any;
  127426. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127427. }
  127428. }
  127429. declare module BABYLON {
  127430. /**
  127431. * Interface used to configure the node material editor
  127432. */
  127433. export interface INodeMaterialEditorOptions {
  127434. /** Define the URl to load node editor script */
  127435. editorURL?: string;
  127436. }
  127437. /** @hidden */
  127438. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  127439. /** BONES */
  127440. NUM_BONE_INFLUENCERS: number;
  127441. BonesPerMesh: number;
  127442. BONETEXTURE: boolean;
  127443. /** MORPH TARGETS */
  127444. MORPHTARGETS: boolean;
  127445. MORPHTARGETS_NORMAL: boolean;
  127446. MORPHTARGETS_TANGENT: boolean;
  127447. MORPHTARGETS_UV: boolean;
  127448. NUM_MORPH_INFLUENCERS: number;
  127449. /** IMAGE PROCESSING */
  127450. IMAGEPROCESSING: boolean;
  127451. VIGNETTE: boolean;
  127452. VIGNETTEBLENDMODEMULTIPLY: boolean;
  127453. VIGNETTEBLENDMODEOPAQUE: boolean;
  127454. TONEMAPPING: boolean;
  127455. TONEMAPPING_ACES: boolean;
  127456. CONTRAST: boolean;
  127457. EXPOSURE: boolean;
  127458. COLORCURVES: boolean;
  127459. COLORGRADING: boolean;
  127460. COLORGRADING3D: boolean;
  127461. SAMPLER3DGREENDEPTH: boolean;
  127462. SAMPLER3DBGRMAP: boolean;
  127463. IMAGEPROCESSINGPOSTPROCESS: boolean;
  127464. /** MISC. */
  127465. BUMPDIRECTUV: number;
  127466. constructor();
  127467. setValue(name: string, value: boolean): void;
  127468. }
  127469. /**
  127470. * Class used to configure NodeMaterial
  127471. */
  127472. export interface INodeMaterialOptions {
  127473. /**
  127474. * Defines if blocks should emit comments
  127475. */
  127476. emitComments: boolean;
  127477. }
  127478. /**
  127479. * Class used to create a node based material built by assembling shader blocks
  127480. */
  127481. export class NodeMaterial extends PushMaterial {
  127482. private static _BuildIdGenerator;
  127483. private _options;
  127484. private _vertexCompilationState;
  127485. private _fragmentCompilationState;
  127486. private _sharedData;
  127487. private _buildId;
  127488. private _buildWasSuccessful;
  127489. private _cachedWorldViewMatrix;
  127490. private _cachedWorldViewProjectionMatrix;
  127491. private _optimizers;
  127492. private _animationFrame;
  127493. /** Define the URl to load node editor script */
  127494. static EditorURL: string;
  127495. private BJSNODEMATERIALEDITOR;
  127496. /** Get the inspector from bundle or global */
  127497. private _getGlobalNodeMaterialEditor;
  127498. /**
  127499. * Gets or sets data used by visual editor
  127500. * @see https://nme.babylonjs.com
  127501. */
  127502. editorData: any;
  127503. /**
  127504. * 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)
  127505. */
  127506. ignoreAlpha: boolean;
  127507. /**
  127508. * Defines the maximum number of lights that can be used in the material
  127509. */
  127510. maxSimultaneousLights: number;
  127511. /**
  127512. * Observable raised when the material is built
  127513. */
  127514. onBuildObservable: Observable<NodeMaterial>;
  127515. /**
  127516. * Gets or sets the root nodes of the material vertex shader
  127517. */
  127518. _vertexOutputNodes: NodeMaterialBlock[];
  127519. /**
  127520. * Gets or sets the root nodes of the material fragment (pixel) shader
  127521. */
  127522. _fragmentOutputNodes: NodeMaterialBlock[];
  127523. /** Gets or sets options to control the node material overall behavior */
  127524. get options(): INodeMaterialOptions;
  127525. set options(options: INodeMaterialOptions);
  127526. /**
  127527. * Default configuration related to image processing available in the standard Material.
  127528. */
  127529. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  127530. /**
  127531. * Gets the image processing configuration used either in this material.
  127532. */
  127533. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  127534. /**
  127535. * Sets the Default image processing configuration used either in the this material.
  127536. *
  127537. * If sets to null, the scene one is in use.
  127538. */
  127539. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  127540. /**
  127541. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  127542. */
  127543. attachedBlocks: NodeMaterialBlock[];
  127544. /**
  127545. * Create a new node based material
  127546. * @param name defines the material name
  127547. * @param scene defines the hosting scene
  127548. * @param options defines creation option
  127549. */
  127550. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  127551. /**
  127552. * Gets the current class name of the material e.g. "NodeMaterial"
  127553. * @returns the class name
  127554. */
  127555. getClassName(): string;
  127556. /**
  127557. * Keep track of the image processing observer to allow dispose and replace.
  127558. */
  127559. private _imageProcessingObserver;
  127560. /**
  127561. * Attaches a new image processing configuration to the Standard Material.
  127562. * @param configuration
  127563. */
  127564. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  127565. /**
  127566. * Get a block by its name
  127567. * @param name defines the name of the block to retrieve
  127568. * @returns the required block or null if not found
  127569. */
  127570. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  127571. /**
  127572. * Get a block by its name
  127573. * @param predicate defines the predicate used to find the good candidate
  127574. * @returns the required block or null if not found
  127575. */
  127576. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  127577. /**
  127578. * Get an input block by its name
  127579. * @param predicate defines the predicate used to find the good candidate
  127580. * @returns the required input block or null if not found
  127581. */
  127582. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  127583. /**
  127584. * Gets the list of input blocks attached to this material
  127585. * @returns an array of InputBlocks
  127586. */
  127587. getInputBlocks(): InputBlock[];
  127588. /**
  127589. * Adds a new optimizer to the list of optimizers
  127590. * @param optimizer defines the optimizers to add
  127591. * @returns the current material
  127592. */
  127593. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  127594. /**
  127595. * Remove an optimizer from the list of optimizers
  127596. * @param optimizer defines the optimizers to remove
  127597. * @returns the current material
  127598. */
  127599. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  127600. /**
  127601. * Add a new block to the list of output nodes
  127602. * @param node defines the node to add
  127603. * @returns the current material
  127604. */
  127605. addOutputNode(node: NodeMaterialBlock): this;
  127606. /**
  127607. * Remove a block from the list of root nodes
  127608. * @param node defines the node to remove
  127609. * @returns the current material
  127610. */
  127611. removeOutputNode(node: NodeMaterialBlock): this;
  127612. private _addVertexOutputNode;
  127613. private _removeVertexOutputNode;
  127614. private _addFragmentOutputNode;
  127615. private _removeFragmentOutputNode;
  127616. /**
  127617. * Specifies if the material will require alpha blending
  127618. * @returns a boolean specifying if alpha blending is needed
  127619. */
  127620. needAlphaBlending(): boolean;
  127621. /**
  127622. * Specifies if this material should be rendered in alpha test mode
  127623. * @returns a boolean specifying if an alpha test is needed.
  127624. */
  127625. needAlphaTesting(): boolean;
  127626. private _initializeBlock;
  127627. private _resetDualBlocks;
  127628. /**
  127629. * Remove a block from the current node material
  127630. * @param block defines the block to remove
  127631. */
  127632. removeBlock(block: NodeMaterialBlock): void;
  127633. /**
  127634. * Build the material and generates the inner effect
  127635. * @param verbose defines if the build should log activity
  127636. */
  127637. build(verbose?: boolean): void;
  127638. /**
  127639. * Runs an otpimization phase to try to improve the shader code
  127640. */
  127641. optimize(): void;
  127642. private _prepareDefinesForAttributes;
  127643. /**
  127644. * Get if the submesh is ready to be used and all its information available.
  127645. * Child classes can use it to update shaders
  127646. * @param mesh defines the mesh to check
  127647. * @param subMesh defines which submesh to check
  127648. * @param useInstances specifies that instances should be used
  127649. * @returns a boolean indicating that the submesh is ready or not
  127650. */
  127651. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  127652. /**
  127653. * Get a string representing the shaders built by the current node graph
  127654. */
  127655. get compiledShaders(): string;
  127656. /**
  127657. * Binds the world matrix to the material
  127658. * @param world defines the world transformation matrix
  127659. */
  127660. bindOnlyWorldMatrix(world: Matrix): void;
  127661. /**
  127662. * Binds the submesh to this material by preparing the effect and shader to draw
  127663. * @param world defines the world transformation matrix
  127664. * @param mesh defines the mesh containing the submesh
  127665. * @param subMesh defines the submesh to bind the material to
  127666. */
  127667. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  127668. /**
  127669. * Gets the active textures from the material
  127670. * @returns an array of textures
  127671. */
  127672. getActiveTextures(): BaseTexture[];
  127673. /**
  127674. * Gets the list of texture blocks
  127675. * @returns an array of texture blocks
  127676. */
  127677. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  127678. /**
  127679. * Specifies if the material uses a texture
  127680. * @param texture defines the texture to check against the material
  127681. * @returns a boolean specifying if the material uses the texture
  127682. */
  127683. hasTexture(texture: BaseTexture): boolean;
  127684. /**
  127685. * Disposes the material
  127686. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  127687. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  127688. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  127689. */
  127690. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  127691. /** Creates the node editor window. */
  127692. private _createNodeEditor;
  127693. /**
  127694. * Launch the node material editor
  127695. * @param config Define the configuration of the editor
  127696. * @return a promise fulfilled when the node editor is visible
  127697. */
  127698. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  127699. /**
  127700. * Clear the current material
  127701. */
  127702. clear(): void;
  127703. /**
  127704. * Clear the current material and set it to a default state
  127705. */
  127706. setToDefault(): void;
  127707. /**
  127708. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  127709. * @param url defines the url to load from
  127710. * @returns a promise that will fullfil when the material is fully loaded
  127711. */
  127712. loadAsync(url: string): Promise<void>;
  127713. private _gatherBlocks;
  127714. /**
  127715. * Generate a string containing the code declaration required to create an equivalent of this material
  127716. * @returns a string
  127717. */
  127718. generateCode(): string;
  127719. /**
  127720. * Serializes this material in a JSON representation
  127721. * @returns the serialized material object
  127722. */
  127723. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  127724. private _restoreConnections;
  127725. /**
  127726. * Clear the current graph and load a new one from a serialization object
  127727. * @param source defines the JSON representation of the material
  127728. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  127729. */
  127730. loadFromSerialization(source: any, rootUrl?: string): void;
  127731. /**
  127732. * Creates a node material from parsed material data
  127733. * @param source defines the JSON representation of the material
  127734. * @param scene defines the hosting scene
  127735. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  127736. * @returns a new node material
  127737. */
  127738. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  127739. /**
  127740. * Creates a new node material set to default basic configuration
  127741. * @param name defines the name of the material
  127742. * @param scene defines the hosting scene
  127743. * @returns a new NodeMaterial
  127744. */
  127745. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  127746. }
  127747. }
  127748. declare module BABYLON {
  127749. /**
  127750. * Block used to read a texture from a sampler
  127751. */
  127752. export class TextureBlock extends NodeMaterialBlock {
  127753. private _defineName;
  127754. private _linearDefineName;
  127755. private _tempTextureRead;
  127756. private _samplerName;
  127757. private _transformedUVName;
  127758. private _textureTransformName;
  127759. private _textureInfoName;
  127760. private _mainUVName;
  127761. private _mainUVDefineName;
  127762. /**
  127763. * Gets or sets the texture associated with the node
  127764. */
  127765. texture: Nullable<Texture>;
  127766. /**
  127767. * Create a new TextureBlock
  127768. * @param name defines the block name
  127769. */
  127770. constructor(name: string);
  127771. /**
  127772. * Gets the current class name
  127773. * @returns the class name
  127774. */
  127775. getClassName(): string;
  127776. /**
  127777. * Gets the uv input component
  127778. */
  127779. get uv(): NodeMaterialConnectionPoint;
  127780. /**
  127781. * Gets the rgba output component
  127782. */
  127783. get rgba(): NodeMaterialConnectionPoint;
  127784. /**
  127785. * Gets the rgb output component
  127786. */
  127787. get rgb(): NodeMaterialConnectionPoint;
  127788. /**
  127789. * Gets the r output component
  127790. */
  127791. get r(): NodeMaterialConnectionPoint;
  127792. /**
  127793. * Gets the g output component
  127794. */
  127795. get g(): NodeMaterialConnectionPoint;
  127796. /**
  127797. * Gets the b output component
  127798. */
  127799. get b(): NodeMaterialConnectionPoint;
  127800. /**
  127801. * Gets the a output component
  127802. */
  127803. get a(): NodeMaterialConnectionPoint;
  127804. get target(): NodeMaterialBlockTargets;
  127805. autoConfigure(material: NodeMaterial): void;
  127806. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  127807. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127808. private _getTextureBase;
  127809. isReady(): boolean;
  127810. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127811. private get _isMixed();
  127812. private _injectVertexCode;
  127813. private _writeTextureRead;
  127814. private _writeOutput;
  127815. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127816. protected _dumpPropertiesCode(): string;
  127817. serialize(): any;
  127818. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127819. }
  127820. }
  127821. declare module BABYLON {
  127822. /**
  127823. * Class used to store shared data between 2 NodeMaterialBuildState
  127824. */
  127825. export class NodeMaterialBuildStateSharedData {
  127826. /**
  127827. * Gets the list of emitted varyings
  127828. */
  127829. temps: string[];
  127830. /**
  127831. * Gets the list of emitted varyings
  127832. */
  127833. varyings: string[];
  127834. /**
  127835. * Gets the varying declaration string
  127836. */
  127837. varyingDeclaration: string;
  127838. /**
  127839. * Input blocks
  127840. */
  127841. inputBlocks: InputBlock[];
  127842. /**
  127843. * Input blocks
  127844. */
  127845. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  127846. /**
  127847. * Bindable blocks (Blocks that need to set data to the effect)
  127848. */
  127849. bindableBlocks: NodeMaterialBlock[];
  127850. /**
  127851. * List of blocks that can provide a compilation fallback
  127852. */
  127853. blocksWithFallbacks: NodeMaterialBlock[];
  127854. /**
  127855. * List of blocks that can provide a define update
  127856. */
  127857. blocksWithDefines: NodeMaterialBlock[];
  127858. /**
  127859. * List of blocks that can provide a repeatable content
  127860. */
  127861. repeatableContentBlocks: NodeMaterialBlock[];
  127862. /**
  127863. * List of blocks that can provide a dynamic list of uniforms
  127864. */
  127865. dynamicUniformBlocks: NodeMaterialBlock[];
  127866. /**
  127867. * List of blocks that can block the isReady function for the material
  127868. */
  127869. blockingBlocks: NodeMaterialBlock[];
  127870. /**
  127871. * Gets the list of animated inputs
  127872. */
  127873. animatedInputs: InputBlock[];
  127874. /**
  127875. * Build Id used to avoid multiple recompilations
  127876. */
  127877. buildId: number;
  127878. /** List of emitted variables */
  127879. variableNames: {
  127880. [key: string]: number;
  127881. };
  127882. /** List of emitted defines */
  127883. defineNames: {
  127884. [key: string]: number;
  127885. };
  127886. /** Should emit comments? */
  127887. emitComments: boolean;
  127888. /** Emit build activity */
  127889. verbose: boolean;
  127890. /** Gets or sets the hosting scene */
  127891. scene: Scene;
  127892. /**
  127893. * Gets the compilation hints emitted at compilation time
  127894. */
  127895. hints: {
  127896. needWorldViewMatrix: boolean;
  127897. needWorldViewProjectionMatrix: boolean;
  127898. needAlphaBlending: boolean;
  127899. needAlphaTesting: boolean;
  127900. };
  127901. /**
  127902. * List of compilation checks
  127903. */
  127904. checks: {
  127905. emitVertex: boolean;
  127906. emitFragment: boolean;
  127907. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  127908. };
  127909. /** Creates a new shared data */
  127910. constructor();
  127911. /**
  127912. * Emits console errors and exceptions if there is a failing check
  127913. */
  127914. emitErrors(): void;
  127915. }
  127916. }
  127917. declare module BABYLON {
  127918. /**
  127919. * Class used to store node based material build state
  127920. */
  127921. export class NodeMaterialBuildState {
  127922. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  127923. supportUniformBuffers: boolean;
  127924. /**
  127925. * Gets the list of emitted attributes
  127926. */
  127927. attributes: string[];
  127928. /**
  127929. * Gets the list of emitted uniforms
  127930. */
  127931. uniforms: string[];
  127932. /**
  127933. * Gets the list of emitted constants
  127934. */
  127935. constants: string[];
  127936. /**
  127937. * Gets the list of emitted samplers
  127938. */
  127939. samplers: string[];
  127940. /**
  127941. * Gets the list of emitted functions
  127942. */
  127943. functions: {
  127944. [key: string]: string;
  127945. };
  127946. /**
  127947. * Gets the list of emitted extensions
  127948. */
  127949. extensions: {
  127950. [key: string]: string;
  127951. };
  127952. /**
  127953. * Gets the target of the compilation state
  127954. */
  127955. target: NodeMaterialBlockTargets;
  127956. /**
  127957. * Gets the list of emitted counters
  127958. */
  127959. counters: {
  127960. [key: string]: number;
  127961. };
  127962. /**
  127963. * Shared data between multiple NodeMaterialBuildState instances
  127964. */
  127965. sharedData: NodeMaterialBuildStateSharedData;
  127966. /** @hidden */
  127967. _vertexState: NodeMaterialBuildState;
  127968. /** @hidden */
  127969. _attributeDeclaration: string;
  127970. /** @hidden */
  127971. _uniformDeclaration: string;
  127972. /** @hidden */
  127973. _constantDeclaration: string;
  127974. /** @hidden */
  127975. _samplerDeclaration: string;
  127976. /** @hidden */
  127977. _varyingTransfer: string;
  127978. private _repeatableContentAnchorIndex;
  127979. /** @hidden */
  127980. _builtCompilationString: string;
  127981. /**
  127982. * Gets the emitted compilation strings
  127983. */
  127984. compilationString: string;
  127985. /**
  127986. * Finalize the compilation strings
  127987. * @param state defines the current compilation state
  127988. */
  127989. finalize(state: NodeMaterialBuildState): void;
  127990. /** @hidden */
  127991. get _repeatableContentAnchor(): string;
  127992. /** @hidden */
  127993. _getFreeVariableName(prefix: string): string;
  127994. /** @hidden */
  127995. _getFreeDefineName(prefix: string): string;
  127996. /** @hidden */
  127997. _excludeVariableName(name: string): void;
  127998. /** @hidden */
  127999. _emit2DSampler(name: string): void;
  128000. /** @hidden */
  128001. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  128002. /** @hidden */
  128003. _emitExtension(name: string, extension: string): void;
  128004. /** @hidden */
  128005. _emitFunction(name: string, code: string, comments: string): void;
  128006. /** @hidden */
  128007. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  128008. replaceStrings?: {
  128009. search: RegExp;
  128010. replace: string;
  128011. }[];
  128012. repeatKey?: string;
  128013. }): string;
  128014. /** @hidden */
  128015. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  128016. repeatKey?: string;
  128017. removeAttributes?: boolean;
  128018. removeUniforms?: boolean;
  128019. removeVaryings?: boolean;
  128020. removeIfDef?: boolean;
  128021. replaceStrings?: {
  128022. search: RegExp;
  128023. replace: string;
  128024. }[];
  128025. }, storeKey?: string): void;
  128026. /** @hidden */
  128027. _registerTempVariable(name: string): boolean;
  128028. /** @hidden */
  128029. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  128030. /** @hidden */
  128031. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  128032. /** @hidden */
  128033. _emitFloat(value: number): string;
  128034. }
  128035. }
  128036. declare module BABYLON {
  128037. /**
  128038. * Defines a block that can be used inside a node based material
  128039. */
  128040. export class NodeMaterialBlock {
  128041. private _buildId;
  128042. private _buildTarget;
  128043. private _target;
  128044. private _isFinalMerger;
  128045. private _isInput;
  128046. protected _isUnique: boolean;
  128047. /** @hidden */
  128048. _codeVariableName: string;
  128049. /** @hidden */
  128050. _inputs: NodeMaterialConnectionPoint[];
  128051. /** @hidden */
  128052. _outputs: NodeMaterialConnectionPoint[];
  128053. /** @hidden */
  128054. _preparationId: number;
  128055. /**
  128056. * Gets or sets the name of the block
  128057. */
  128058. name: string;
  128059. /**
  128060. * Gets or sets the unique id of the node
  128061. */
  128062. uniqueId: number;
  128063. /**
  128064. * Gets or sets the comments associated with this block
  128065. */
  128066. comments: string;
  128067. /**
  128068. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  128069. */
  128070. get isUnique(): boolean;
  128071. /**
  128072. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  128073. */
  128074. get isFinalMerger(): boolean;
  128075. /**
  128076. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  128077. */
  128078. get isInput(): boolean;
  128079. /**
  128080. * Gets or sets the build Id
  128081. */
  128082. get buildId(): number;
  128083. set buildId(value: number);
  128084. /**
  128085. * Gets or sets the target of the block
  128086. */
  128087. get target(): NodeMaterialBlockTargets;
  128088. set target(value: NodeMaterialBlockTargets);
  128089. /**
  128090. * Gets the list of input points
  128091. */
  128092. get inputs(): NodeMaterialConnectionPoint[];
  128093. /** Gets the list of output points */
  128094. get outputs(): NodeMaterialConnectionPoint[];
  128095. /**
  128096. * Find an input by its name
  128097. * @param name defines the name of the input to look for
  128098. * @returns the input or null if not found
  128099. */
  128100. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  128101. /**
  128102. * Find an output by its name
  128103. * @param name defines the name of the outputto look for
  128104. * @returns the output or null if not found
  128105. */
  128106. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  128107. /**
  128108. * Creates a new NodeMaterialBlock
  128109. * @param name defines the block name
  128110. * @param target defines the target of that block (Vertex by default)
  128111. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  128112. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  128113. */
  128114. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  128115. /**
  128116. * Initialize the block and prepare the context for build
  128117. * @param state defines the state that will be used for the build
  128118. */
  128119. initialize(state: NodeMaterialBuildState): void;
  128120. /**
  128121. * Bind data to effect. Will only be called for blocks with isBindable === true
  128122. * @param effect defines the effect to bind data to
  128123. * @param nodeMaterial defines the hosting NodeMaterial
  128124. * @param mesh defines the mesh that will be rendered
  128125. */
  128126. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128127. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  128128. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  128129. protected _writeFloat(value: number): string;
  128130. /**
  128131. * Gets the current class name e.g. "NodeMaterialBlock"
  128132. * @returns the class name
  128133. */
  128134. getClassName(): string;
  128135. /**
  128136. * Register a new input. Must be called inside a block constructor
  128137. * @param name defines the connection point name
  128138. * @param type defines the connection point type
  128139. * @param isOptional defines a boolean indicating that this input can be omitted
  128140. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  128141. * @returns the current block
  128142. */
  128143. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  128144. /**
  128145. * Register a new output. Must be called inside a block constructor
  128146. * @param name defines the connection point name
  128147. * @param type defines the connection point type
  128148. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  128149. * @returns the current block
  128150. */
  128151. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  128152. /**
  128153. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  128154. * @param forOutput defines an optional connection point to check compatibility with
  128155. * @returns the first available input or null
  128156. */
  128157. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  128158. /**
  128159. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  128160. * @param forBlock defines an optional block to check compatibility with
  128161. * @returns the first available input or null
  128162. */
  128163. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  128164. /**
  128165. * Gets the sibling of the given output
  128166. * @param current defines the current output
  128167. * @returns the next output in the list or null
  128168. */
  128169. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  128170. /**
  128171. * Connect current block with another block
  128172. * @param other defines the block to connect with
  128173. * @param options define the various options to help pick the right connections
  128174. * @returns the current block
  128175. */
  128176. connectTo(other: NodeMaterialBlock, options?: {
  128177. input?: string;
  128178. output?: string;
  128179. outputSwizzle?: string;
  128180. }): this | undefined;
  128181. protected _buildBlock(state: NodeMaterialBuildState): void;
  128182. /**
  128183. * Add uniforms, samplers and uniform buffers at compilation time
  128184. * @param state defines the state to update
  128185. * @param nodeMaterial defines the node material requesting the update
  128186. * @param defines defines the material defines to update
  128187. * @param uniformBuffers defines the list of uniform buffer names
  128188. */
  128189. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  128190. /**
  128191. * Add potential fallbacks if shader compilation fails
  128192. * @param mesh defines the mesh to be rendered
  128193. * @param fallbacks defines the current prioritized list of fallbacks
  128194. */
  128195. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  128196. /**
  128197. * Initialize defines for shader compilation
  128198. * @param mesh defines the mesh to be rendered
  128199. * @param nodeMaterial defines the node material requesting the update
  128200. * @param defines defines the material defines to update
  128201. * @param useInstances specifies that instances should be used
  128202. */
  128203. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  128204. /**
  128205. * Update defines for shader compilation
  128206. * @param mesh defines the mesh to be rendered
  128207. * @param nodeMaterial defines the node material requesting the update
  128208. * @param defines defines the material defines to update
  128209. * @param useInstances specifies that instances should be used
  128210. */
  128211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  128212. /**
  128213. * Lets the block try to connect some inputs automatically
  128214. * @param material defines the hosting NodeMaterial
  128215. */
  128216. autoConfigure(material: NodeMaterial): void;
  128217. /**
  128218. * Function called when a block is declared as repeatable content generator
  128219. * @param vertexShaderState defines the current compilation state for the vertex shader
  128220. * @param fragmentShaderState defines the current compilation state for the fragment shader
  128221. * @param mesh defines the mesh to be rendered
  128222. * @param defines defines the material defines to update
  128223. */
  128224. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  128225. /**
  128226. * Checks if the block is ready
  128227. * @param mesh defines the mesh to be rendered
  128228. * @param nodeMaterial defines the node material requesting the update
  128229. * @param defines defines the material defines to update
  128230. * @param useInstances specifies that instances should be used
  128231. * @returns true if the block is ready
  128232. */
  128233. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  128234. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  128235. private _processBuild;
  128236. /**
  128237. * Compile the current node and generate the shader code
  128238. * @param state defines the current compilation state (uniforms, samplers, current string)
  128239. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  128240. * @returns true if already built
  128241. */
  128242. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  128243. protected _inputRename(name: string): string;
  128244. protected _outputRename(name: string): string;
  128245. protected _dumpPropertiesCode(): string;
  128246. /** @hidden */
  128247. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  128248. /** @hidden */
  128249. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  128250. /**
  128251. * Clone the current block to a new identical block
  128252. * @param scene defines the hosting scene
  128253. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  128254. * @returns a copy of the current block
  128255. */
  128256. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  128257. /**
  128258. * Serializes this block in a JSON representation
  128259. * @returns the serialized block object
  128260. */
  128261. serialize(): any;
  128262. /** @hidden */
  128263. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128264. /**
  128265. * Release resources
  128266. */
  128267. dispose(): void;
  128268. }
  128269. }
  128270. declare module BABYLON {
  128271. /**
  128272. * Enum defining the type of animations supported by InputBlock
  128273. */
  128274. export enum AnimatedInputBlockTypes {
  128275. /** No animation */
  128276. None = 0,
  128277. /** Time based animation. Will only work for floats */
  128278. Time = 1
  128279. }
  128280. }
  128281. declare module BABYLON {
  128282. /**
  128283. * Block used to expose an input value
  128284. */
  128285. export class InputBlock extends NodeMaterialBlock {
  128286. private _mode;
  128287. private _associatedVariableName;
  128288. private _storedValue;
  128289. private _valueCallback;
  128290. private _type;
  128291. private _animationType;
  128292. /** Gets or set a value used to limit the range of float values */
  128293. min: number;
  128294. /** Gets or set a value used to limit the range of float values */
  128295. max: number;
  128296. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  128297. matrixMode: number;
  128298. /** @hidden */
  128299. _systemValue: Nullable<NodeMaterialSystemValues>;
  128300. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  128301. visibleInInspector: boolean;
  128302. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  128303. isConstant: boolean;
  128304. /** Gets or sets the group to use to display this block in the Inspector */
  128305. groupInInspector: string;
  128306. /**
  128307. * Gets or sets the connection point type (default is float)
  128308. */
  128309. get type(): NodeMaterialBlockConnectionPointTypes;
  128310. /**
  128311. * Creates a new InputBlock
  128312. * @param name defines the block name
  128313. * @param target defines the target of that block (Vertex by default)
  128314. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  128315. */
  128316. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  128317. /**
  128318. * Gets the output component
  128319. */
  128320. get output(): NodeMaterialConnectionPoint;
  128321. /**
  128322. * Set the source of this connection point to a vertex attribute
  128323. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  128324. * @returns the current connection point
  128325. */
  128326. setAsAttribute(attributeName?: string): InputBlock;
  128327. /**
  128328. * Set the source of this connection point to a system value
  128329. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  128330. * @returns the current connection point
  128331. */
  128332. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  128333. /**
  128334. * Gets or sets the value of that point.
  128335. * Please note that this value will be ignored if valueCallback is defined
  128336. */
  128337. get value(): any;
  128338. set value(value: any);
  128339. /**
  128340. * Gets or sets a callback used to get the value of that point.
  128341. * Please note that setting this value will force the connection point to ignore the value property
  128342. */
  128343. get valueCallback(): () => any;
  128344. set valueCallback(value: () => any);
  128345. /**
  128346. * Gets or sets the associated variable name in the shader
  128347. */
  128348. get associatedVariableName(): string;
  128349. set associatedVariableName(value: string);
  128350. /** Gets or sets the type of animation applied to the input */
  128351. get animationType(): AnimatedInputBlockTypes;
  128352. set animationType(value: AnimatedInputBlockTypes);
  128353. /**
  128354. * Gets a boolean indicating that this connection point not defined yet
  128355. */
  128356. get isUndefined(): boolean;
  128357. /**
  128358. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  128359. * In this case the connection point name must be the name of the uniform to use.
  128360. * Can only be set on inputs
  128361. */
  128362. get isUniform(): boolean;
  128363. set isUniform(value: boolean);
  128364. /**
  128365. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  128366. * In this case the connection point name must be the name of the attribute to use
  128367. * Can only be set on inputs
  128368. */
  128369. get isAttribute(): boolean;
  128370. set isAttribute(value: boolean);
  128371. /**
  128372. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  128373. * Can only be set on exit points
  128374. */
  128375. get isVarying(): boolean;
  128376. set isVarying(value: boolean);
  128377. /**
  128378. * Gets a boolean indicating that the current connection point is a system value
  128379. */
  128380. get isSystemValue(): boolean;
  128381. /**
  128382. * Gets or sets the current well known value or null if not defined as a system value
  128383. */
  128384. get systemValue(): Nullable<NodeMaterialSystemValues>;
  128385. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  128386. /**
  128387. * Gets the current class name
  128388. * @returns the class name
  128389. */
  128390. getClassName(): string;
  128391. /**
  128392. * Animate the input if animationType !== None
  128393. * @param scene defines the rendering scene
  128394. */
  128395. animate(scene: Scene): void;
  128396. private _emitDefine;
  128397. initialize(state: NodeMaterialBuildState): void;
  128398. /**
  128399. * Set the input block to its default value (based on its type)
  128400. */
  128401. setDefaultValue(): void;
  128402. private _emitConstant;
  128403. private _emit;
  128404. /** @hidden */
  128405. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  128406. /** @hidden */
  128407. _transmit(effect: Effect, scene: Scene): void;
  128408. protected _buildBlock(state: NodeMaterialBuildState): void;
  128409. protected _dumpPropertiesCode(): string;
  128410. serialize(): any;
  128411. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128412. }
  128413. }
  128414. declare module BABYLON {
  128415. /**
  128416. * Enum used to define the compatibility state between two connection points
  128417. */
  128418. export enum NodeMaterialConnectionPointCompatibilityStates {
  128419. /** Points are compatibles */
  128420. Compatible = 0,
  128421. /** Points are incompatible because of their types */
  128422. TypeIncompatible = 1,
  128423. /** Points are incompatible because of their targets (vertex vs fragment) */
  128424. TargetIncompatible = 2
  128425. }
  128426. /**
  128427. * Defines the direction of a connection point
  128428. */
  128429. export enum NodeMaterialConnectionPointDirection {
  128430. /** Input */
  128431. Input = 0,
  128432. /** Output */
  128433. Output = 1
  128434. }
  128435. /**
  128436. * Defines a connection point for a block
  128437. */
  128438. export class NodeMaterialConnectionPoint {
  128439. /** @hidden */
  128440. _ownerBlock: NodeMaterialBlock;
  128441. /** @hidden */
  128442. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  128443. private _endpoints;
  128444. private _associatedVariableName;
  128445. private _direction;
  128446. /** @hidden */
  128447. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  128448. /** @hidden */
  128449. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  128450. private _type;
  128451. /** @hidden */
  128452. _enforceAssociatedVariableName: boolean;
  128453. /** Gets the direction of the point */
  128454. get direction(): NodeMaterialConnectionPointDirection;
  128455. /**
  128456. * Gets or sets the additional types supported by this connection point
  128457. */
  128458. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  128459. /**
  128460. * Gets or sets the additional types excluded by this connection point
  128461. */
  128462. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  128463. /**
  128464. * Observable triggered when this point is connected
  128465. */
  128466. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  128467. /**
  128468. * Gets or sets the associated variable name in the shader
  128469. */
  128470. get associatedVariableName(): string;
  128471. set associatedVariableName(value: string);
  128472. /**
  128473. * Gets or sets the connection point type (default is float)
  128474. */
  128475. get type(): NodeMaterialBlockConnectionPointTypes;
  128476. set type(value: NodeMaterialBlockConnectionPointTypes);
  128477. /**
  128478. * Gets or sets the connection point name
  128479. */
  128480. name: string;
  128481. /**
  128482. * Gets or sets a boolean indicating that this connection point can be omitted
  128483. */
  128484. isOptional: boolean;
  128485. /**
  128486. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  128487. */
  128488. define: string;
  128489. /** @hidden */
  128490. _prioritizeVertex: boolean;
  128491. private _target;
  128492. /** Gets or sets the target of that connection point */
  128493. get target(): NodeMaterialBlockTargets;
  128494. set target(value: NodeMaterialBlockTargets);
  128495. /**
  128496. * Gets a boolean indicating that the current point is connected
  128497. */
  128498. get isConnected(): boolean;
  128499. /**
  128500. * Gets a boolean indicating that the current point is connected to an input block
  128501. */
  128502. get isConnectedToInputBlock(): boolean;
  128503. /**
  128504. * Gets a the connected input block (if any)
  128505. */
  128506. get connectInputBlock(): Nullable<InputBlock>;
  128507. /** Get the other side of the connection (if any) */
  128508. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  128509. /** Get the block that owns this connection point */
  128510. get ownerBlock(): NodeMaterialBlock;
  128511. /** Get the block connected on the other side of this connection (if any) */
  128512. get sourceBlock(): Nullable<NodeMaterialBlock>;
  128513. /** Get the block connected on the endpoints of this connection (if any) */
  128514. get connectedBlocks(): Array<NodeMaterialBlock>;
  128515. /** Gets the list of connected endpoints */
  128516. get endpoints(): NodeMaterialConnectionPoint[];
  128517. /** Gets a boolean indicating if that output point is connected to at least one input */
  128518. get hasEndpoints(): boolean;
  128519. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  128520. get isConnectedInVertexShader(): boolean;
  128521. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  128522. get isConnectedInFragmentShader(): boolean;
  128523. /**
  128524. * Creates a new connection point
  128525. * @param name defines the connection point name
  128526. * @param ownerBlock defines the block hosting this connection point
  128527. * @param direction defines the direction of the connection point
  128528. */
  128529. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  128530. /**
  128531. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  128532. * @returns the class name
  128533. */
  128534. getClassName(): string;
  128535. /**
  128536. * Gets a boolean indicating if the current point can be connected to another point
  128537. * @param connectionPoint defines the other connection point
  128538. * @returns a boolean
  128539. */
  128540. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  128541. /**
  128542. * Gets a number indicating if the current point can be connected to another point
  128543. * @param connectionPoint defines the other connection point
  128544. * @returns a number defining the compatibility state
  128545. */
  128546. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  128547. /**
  128548. * Connect this point to another connection point
  128549. * @param connectionPoint defines the other connection point
  128550. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  128551. * @returns the current connection point
  128552. */
  128553. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  128554. /**
  128555. * Disconnect this point from one of his endpoint
  128556. * @param endpoint defines the other connection point
  128557. * @returns the current connection point
  128558. */
  128559. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  128560. /**
  128561. * Serializes this point in a JSON representation
  128562. * @returns the serialized point object
  128563. */
  128564. serialize(): any;
  128565. /**
  128566. * Release resources
  128567. */
  128568. dispose(): void;
  128569. }
  128570. }
  128571. declare module BABYLON {
  128572. /**
  128573. * Block used to add support for vertex skinning (bones)
  128574. */
  128575. export class BonesBlock extends NodeMaterialBlock {
  128576. /**
  128577. * Creates a new BonesBlock
  128578. * @param name defines the block name
  128579. */
  128580. constructor(name: string);
  128581. /**
  128582. * Initialize the block and prepare the context for build
  128583. * @param state defines the state that will be used for the build
  128584. */
  128585. initialize(state: NodeMaterialBuildState): void;
  128586. /**
  128587. * Gets the current class name
  128588. * @returns the class name
  128589. */
  128590. getClassName(): string;
  128591. /**
  128592. * Gets the matrix indices input component
  128593. */
  128594. get matricesIndices(): NodeMaterialConnectionPoint;
  128595. /**
  128596. * Gets the matrix weights input component
  128597. */
  128598. get matricesWeights(): NodeMaterialConnectionPoint;
  128599. /**
  128600. * Gets the extra matrix indices input component
  128601. */
  128602. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  128603. /**
  128604. * Gets the extra matrix weights input component
  128605. */
  128606. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  128607. /**
  128608. * Gets the world input component
  128609. */
  128610. get world(): NodeMaterialConnectionPoint;
  128611. /**
  128612. * Gets the output component
  128613. */
  128614. get output(): NodeMaterialConnectionPoint;
  128615. autoConfigure(material: NodeMaterial): void;
  128616. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  128617. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128618. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128619. protected _buildBlock(state: NodeMaterialBuildState): this;
  128620. }
  128621. }
  128622. declare module BABYLON {
  128623. /**
  128624. * Block used to add support for instances
  128625. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  128626. */
  128627. export class InstancesBlock extends NodeMaterialBlock {
  128628. /**
  128629. * Creates a new InstancesBlock
  128630. * @param name defines the block name
  128631. */
  128632. constructor(name: string);
  128633. /**
  128634. * Gets the current class name
  128635. * @returns the class name
  128636. */
  128637. getClassName(): string;
  128638. /**
  128639. * Gets the first world row input component
  128640. */
  128641. get world0(): NodeMaterialConnectionPoint;
  128642. /**
  128643. * Gets the second world row input component
  128644. */
  128645. get world1(): NodeMaterialConnectionPoint;
  128646. /**
  128647. * Gets the third world row input component
  128648. */
  128649. get world2(): NodeMaterialConnectionPoint;
  128650. /**
  128651. * Gets the forth world row input component
  128652. */
  128653. get world3(): NodeMaterialConnectionPoint;
  128654. /**
  128655. * Gets the world input component
  128656. */
  128657. get world(): NodeMaterialConnectionPoint;
  128658. /**
  128659. * Gets the output component
  128660. */
  128661. get output(): NodeMaterialConnectionPoint;
  128662. autoConfigure(material: NodeMaterial): void;
  128663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  128664. protected _buildBlock(state: NodeMaterialBuildState): this;
  128665. }
  128666. }
  128667. declare module BABYLON {
  128668. /**
  128669. * Block used to add morph targets support to vertex shader
  128670. */
  128671. export class MorphTargetsBlock extends NodeMaterialBlock {
  128672. private _repeatableContentAnchor;
  128673. private _repeatebleContentGenerated;
  128674. /**
  128675. * Create a new MorphTargetsBlock
  128676. * @param name defines the block name
  128677. */
  128678. constructor(name: string);
  128679. /**
  128680. * Gets the current class name
  128681. * @returns the class name
  128682. */
  128683. getClassName(): string;
  128684. /**
  128685. * Gets the position input component
  128686. */
  128687. get position(): NodeMaterialConnectionPoint;
  128688. /**
  128689. * Gets the normal input component
  128690. */
  128691. get normal(): NodeMaterialConnectionPoint;
  128692. /**
  128693. * Gets the tangent input component
  128694. */
  128695. get tangent(): NodeMaterialConnectionPoint;
  128696. /**
  128697. * Gets the tangent input component
  128698. */
  128699. get uv(): NodeMaterialConnectionPoint;
  128700. /**
  128701. * Gets the position output component
  128702. */
  128703. get positionOutput(): NodeMaterialConnectionPoint;
  128704. /**
  128705. * Gets the normal output component
  128706. */
  128707. get normalOutput(): NodeMaterialConnectionPoint;
  128708. /**
  128709. * Gets the tangent output component
  128710. */
  128711. get tangentOutput(): NodeMaterialConnectionPoint;
  128712. /**
  128713. * Gets the tangent output component
  128714. */
  128715. get uvOutput(): NodeMaterialConnectionPoint;
  128716. initialize(state: NodeMaterialBuildState): void;
  128717. autoConfigure(material: NodeMaterial): void;
  128718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128720. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  128721. protected _buildBlock(state: NodeMaterialBuildState): this;
  128722. }
  128723. }
  128724. declare module BABYLON {
  128725. /**
  128726. * Block used to get data information from a light
  128727. */
  128728. export class LightInformationBlock extends NodeMaterialBlock {
  128729. private _lightDataUniformName;
  128730. private _lightColorUniformName;
  128731. private _lightTypeDefineName;
  128732. /**
  128733. * Gets or sets the light associated with this block
  128734. */
  128735. light: Nullable<Light>;
  128736. /**
  128737. * Creates a new LightInformationBlock
  128738. * @param name defines the block name
  128739. */
  128740. constructor(name: string);
  128741. /**
  128742. * Gets the current class name
  128743. * @returns the class name
  128744. */
  128745. getClassName(): string;
  128746. /**
  128747. * Gets the world position input component
  128748. */
  128749. get worldPosition(): NodeMaterialConnectionPoint;
  128750. /**
  128751. * Gets the direction output component
  128752. */
  128753. get direction(): NodeMaterialConnectionPoint;
  128754. /**
  128755. * Gets the direction output component
  128756. */
  128757. get color(): NodeMaterialConnectionPoint;
  128758. /**
  128759. * Gets the direction output component
  128760. */
  128761. get intensity(): NodeMaterialConnectionPoint;
  128762. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128764. protected _buildBlock(state: NodeMaterialBuildState): this;
  128765. serialize(): any;
  128766. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128767. }
  128768. }
  128769. declare module BABYLON {
  128770. /**
  128771. * Block used to add image processing support to fragment shader
  128772. */
  128773. export class ImageProcessingBlock extends NodeMaterialBlock {
  128774. /**
  128775. * Create a new ImageProcessingBlock
  128776. * @param name defines the block name
  128777. */
  128778. constructor(name: string);
  128779. /**
  128780. * Gets the current class name
  128781. * @returns the class name
  128782. */
  128783. getClassName(): string;
  128784. /**
  128785. * Gets the color input component
  128786. */
  128787. get color(): NodeMaterialConnectionPoint;
  128788. /**
  128789. * Gets the output component
  128790. */
  128791. get output(): NodeMaterialConnectionPoint;
  128792. /**
  128793. * Initialize the block and prepare the context for build
  128794. * @param state defines the state that will be used for the build
  128795. */
  128796. initialize(state: NodeMaterialBuildState): void;
  128797. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  128798. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128799. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128800. protected _buildBlock(state: NodeMaterialBuildState): this;
  128801. }
  128802. }
  128803. declare module BABYLON {
  128804. /**
  128805. * Block used to pertub normals based on a normal map
  128806. */
  128807. export class PerturbNormalBlock extends NodeMaterialBlock {
  128808. private _tangentSpaceParameterName;
  128809. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  128810. invertX: boolean;
  128811. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  128812. invertY: boolean;
  128813. /**
  128814. * Create a new PerturbNormalBlock
  128815. * @param name defines the block name
  128816. */
  128817. constructor(name: string);
  128818. /**
  128819. * Gets the current class name
  128820. * @returns the class name
  128821. */
  128822. getClassName(): string;
  128823. /**
  128824. * Gets the world position input component
  128825. */
  128826. get worldPosition(): NodeMaterialConnectionPoint;
  128827. /**
  128828. * Gets the world normal input component
  128829. */
  128830. get worldNormal(): NodeMaterialConnectionPoint;
  128831. /**
  128832. * Gets the uv input component
  128833. */
  128834. get uv(): NodeMaterialConnectionPoint;
  128835. /**
  128836. * Gets the normal map color input component
  128837. */
  128838. get normalMapColor(): NodeMaterialConnectionPoint;
  128839. /**
  128840. * Gets the strength input component
  128841. */
  128842. get strength(): NodeMaterialConnectionPoint;
  128843. /**
  128844. * Gets the output component
  128845. */
  128846. get output(): NodeMaterialConnectionPoint;
  128847. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128848. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128849. autoConfigure(material: NodeMaterial): void;
  128850. protected _buildBlock(state: NodeMaterialBuildState): this;
  128851. protected _dumpPropertiesCode(): string;
  128852. serialize(): any;
  128853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128854. }
  128855. }
  128856. declare module BABYLON {
  128857. /**
  128858. * Block used to discard a pixel if a value is smaller than a cutoff
  128859. */
  128860. export class DiscardBlock extends NodeMaterialBlock {
  128861. /**
  128862. * Create a new DiscardBlock
  128863. * @param name defines the block name
  128864. */
  128865. constructor(name: string);
  128866. /**
  128867. * Gets the current class name
  128868. * @returns the class name
  128869. */
  128870. getClassName(): string;
  128871. /**
  128872. * Gets the color input component
  128873. */
  128874. get value(): NodeMaterialConnectionPoint;
  128875. /**
  128876. * Gets the cutoff input component
  128877. */
  128878. get cutoff(): NodeMaterialConnectionPoint;
  128879. protected _buildBlock(state: NodeMaterialBuildState): this;
  128880. }
  128881. }
  128882. declare module BABYLON {
  128883. /**
  128884. * Block used to test if the fragment shader is front facing
  128885. */
  128886. export class FrontFacingBlock extends NodeMaterialBlock {
  128887. /**
  128888. * Creates a new FrontFacingBlock
  128889. * @param name defines the block name
  128890. */
  128891. constructor(name: string);
  128892. /**
  128893. * Gets the current class name
  128894. * @returns the class name
  128895. */
  128896. getClassName(): string;
  128897. /**
  128898. * Gets the output component
  128899. */
  128900. get output(): NodeMaterialConnectionPoint;
  128901. protected _buildBlock(state: NodeMaterialBuildState): this;
  128902. }
  128903. }
  128904. declare module BABYLON {
  128905. /**
  128906. * Block used to get the derivative value on x and y of a given input
  128907. */
  128908. export class DerivativeBlock extends NodeMaterialBlock {
  128909. /**
  128910. * Create a new DerivativeBlock
  128911. * @param name defines the block name
  128912. */
  128913. constructor(name: string);
  128914. /**
  128915. * Gets the current class name
  128916. * @returns the class name
  128917. */
  128918. getClassName(): string;
  128919. /**
  128920. * Gets the input component
  128921. */
  128922. get input(): NodeMaterialConnectionPoint;
  128923. /**
  128924. * Gets the derivative output on x
  128925. */
  128926. get dx(): NodeMaterialConnectionPoint;
  128927. /**
  128928. * Gets the derivative output on y
  128929. */
  128930. get dy(): NodeMaterialConnectionPoint;
  128931. protected _buildBlock(state: NodeMaterialBuildState): this;
  128932. }
  128933. }
  128934. declare module BABYLON {
  128935. /**
  128936. * Block used to add support for scene fog
  128937. */
  128938. export class FogBlock extends NodeMaterialBlock {
  128939. private _fogDistanceName;
  128940. private _fogParameters;
  128941. /**
  128942. * Create a new FogBlock
  128943. * @param name defines the block name
  128944. */
  128945. constructor(name: string);
  128946. /**
  128947. * Gets the current class name
  128948. * @returns the class name
  128949. */
  128950. getClassName(): string;
  128951. /**
  128952. * Gets the world position input component
  128953. */
  128954. get worldPosition(): NodeMaterialConnectionPoint;
  128955. /**
  128956. * Gets the view input component
  128957. */
  128958. get view(): NodeMaterialConnectionPoint;
  128959. /**
  128960. * Gets the color input component
  128961. */
  128962. get input(): NodeMaterialConnectionPoint;
  128963. /**
  128964. * Gets the fog color input component
  128965. */
  128966. get fogColor(): NodeMaterialConnectionPoint;
  128967. /**
  128968. * Gets the output component
  128969. */
  128970. get output(): NodeMaterialConnectionPoint;
  128971. autoConfigure(material: NodeMaterial): void;
  128972. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128973. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128974. protected _buildBlock(state: NodeMaterialBuildState): this;
  128975. }
  128976. }
  128977. declare module BABYLON {
  128978. /**
  128979. * Block used to add light in the fragment shader
  128980. */
  128981. export class LightBlock extends NodeMaterialBlock {
  128982. private _lightId;
  128983. /**
  128984. * Gets or sets the light associated with this block
  128985. */
  128986. light: Nullable<Light>;
  128987. /**
  128988. * Create a new LightBlock
  128989. * @param name defines the block name
  128990. */
  128991. constructor(name: string);
  128992. /**
  128993. * Gets the current class name
  128994. * @returns the class name
  128995. */
  128996. getClassName(): string;
  128997. /**
  128998. * Gets the world position input component
  128999. */
  129000. get worldPosition(): NodeMaterialConnectionPoint;
  129001. /**
  129002. * Gets the world normal input component
  129003. */
  129004. get worldNormal(): NodeMaterialConnectionPoint;
  129005. /**
  129006. * Gets the camera (or eye) position component
  129007. */
  129008. get cameraPosition(): NodeMaterialConnectionPoint;
  129009. /**
  129010. * Gets the glossiness component
  129011. */
  129012. get glossiness(): NodeMaterialConnectionPoint;
  129013. /**
  129014. * Gets the glossinness power component
  129015. */
  129016. get glossPower(): NodeMaterialConnectionPoint;
  129017. /**
  129018. * Gets the diffuse color component
  129019. */
  129020. get diffuseColor(): NodeMaterialConnectionPoint;
  129021. /**
  129022. * Gets the specular color component
  129023. */
  129024. get specularColor(): NodeMaterialConnectionPoint;
  129025. /**
  129026. * Gets the diffuse output component
  129027. */
  129028. get diffuseOutput(): NodeMaterialConnectionPoint;
  129029. /**
  129030. * Gets the specular output component
  129031. */
  129032. get specularOutput(): NodeMaterialConnectionPoint;
  129033. /**
  129034. * Gets the shadow output component
  129035. */
  129036. get shadow(): NodeMaterialConnectionPoint;
  129037. autoConfigure(material: NodeMaterial): void;
  129038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129039. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  129040. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129041. private _injectVertexCode;
  129042. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129043. serialize(): any;
  129044. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129045. }
  129046. }
  129047. declare module BABYLON {
  129048. /**
  129049. * Block used to multiply 2 values
  129050. */
  129051. export class MultiplyBlock extends NodeMaterialBlock {
  129052. /**
  129053. * Creates a new MultiplyBlock
  129054. * @param name defines the block name
  129055. */
  129056. constructor(name: string);
  129057. /**
  129058. * Gets the current class name
  129059. * @returns the class name
  129060. */
  129061. getClassName(): string;
  129062. /**
  129063. * Gets the left operand input component
  129064. */
  129065. get left(): NodeMaterialConnectionPoint;
  129066. /**
  129067. * Gets the right operand input component
  129068. */
  129069. get right(): NodeMaterialConnectionPoint;
  129070. /**
  129071. * Gets the output component
  129072. */
  129073. get output(): NodeMaterialConnectionPoint;
  129074. protected _buildBlock(state: NodeMaterialBuildState): this;
  129075. }
  129076. }
  129077. declare module BABYLON {
  129078. /**
  129079. * Block used to add 2 vectors
  129080. */
  129081. export class AddBlock extends NodeMaterialBlock {
  129082. /**
  129083. * Creates a new AddBlock
  129084. * @param name defines the block name
  129085. */
  129086. constructor(name: string);
  129087. /**
  129088. * Gets the current class name
  129089. * @returns the class name
  129090. */
  129091. getClassName(): string;
  129092. /**
  129093. * Gets the left operand input component
  129094. */
  129095. get left(): NodeMaterialConnectionPoint;
  129096. /**
  129097. * Gets the right operand input component
  129098. */
  129099. get right(): NodeMaterialConnectionPoint;
  129100. /**
  129101. * Gets the output component
  129102. */
  129103. get output(): NodeMaterialConnectionPoint;
  129104. protected _buildBlock(state: NodeMaterialBuildState): this;
  129105. }
  129106. }
  129107. declare module BABYLON {
  129108. /**
  129109. * Block used to scale a vector by a float
  129110. */
  129111. export class ScaleBlock extends NodeMaterialBlock {
  129112. /**
  129113. * Creates a new ScaleBlock
  129114. * @param name defines the block name
  129115. */
  129116. constructor(name: string);
  129117. /**
  129118. * Gets the current class name
  129119. * @returns the class name
  129120. */
  129121. getClassName(): string;
  129122. /**
  129123. * Gets the input component
  129124. */
  129125. get input(): NodeMaterialConnectionPoint;
  129126. /**
  129127. * Gets the factor input component
  129128. */
  129129. get factor(): NodeMaterialConnectionPoint;
  129130. /**
  129131. * Gets the output component
  129132. */
  129133. get output(): NodeMaterialConnectionPoint;
  129134. protected _buildBlock(state: NodeMaterialBuildState): this;
  129135. }
  129136. }
  129137. declare module BABYLON {
  129138. /**
  129139. * Block used to clamp a float
  129140. */
  129141. export class ClampBlock extends NodeMaterialBlock {
  129142. /** Gets or sets the minimum range */
  129143. minimum: number;
  129144. /** Gets or sets the maximum range */
  129145. maximum: number;
  129146. /**
  129147. * Creates a new ClampBlock
  129148. * @param name defines the block name
  129149. */
  129150. constructor(name: string);
  129151. /**
  129152. * Gets the current class name
  129153. * @returns the class name
  129154. */
  129155. getClassName(): string;
  129156. /**
  129157. * Gets the value input component
  129158. */
  129159. get value(): NodeMaterialConnectionPoint;
  129160. /**
  129161. * Gets the output component
  129162. */
  129163. get output(): NodeMaterialConnectionPoint;
  129164. protected _buildBlock(state: NodeMaterialBuildState): this;
  129165. protected _dumpPropertiesCode(): string;
  129166. serialize(): any;
  129167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129168. }
  129169. }
  129170. declare module BABYLON {
  129171. /**
  129172. * Block used to apply a cross product between 2 vectors
  129173. */
  129174. export class CrossBlock extends NodeMaterialBlock {
  129175. /**
  129176. * Creates a new CrossBlock
  129177. * @param name defines the block name
  129178. */
  129179. constructor(name: string);
  129180. /**
  129181. * Gets the current class name
  129182. * @returns the class name
  129183. */
  129184. getClassName(): string;
  129185. /**
  129186. * Gets the left operand input component
  129187. */
  129188. get left(): NodeMaterialConnectionPoint;
  129189. /**
  129190. * Gets the right operand input component
  129191. */
  129192. get right(): NodeMaterialConnectionPoint;
  129193. /**
  129194. * Gets the output component
  129195. */
  129196. get output(): NodeMaterialConnectionPoint;
  129197. protected _buildBlock(state: NodeMaterialBuildState): this;
  129198. }
  129199. }
  129200. declare module BABYLON {
  129201. /**
  129202. * Block used to apply a dot product between 2 vectors
  129203. */
  129204. export class DotBlock extends NodeMaterialBlock {
  129205. /**
  129206. * Creates a new DotBlock
  129207. * @param name defines the block name
  129208. */
  129209. constructor(name: string);
  129210. /**
  129211. * Gets the current class name
  129212. * @returns the class name
  129213. */
  129214. getClassName(): string;
  129215. /**
  129216. * Gets the left operand input component
  129217. */
  129218. get left(): NodeMaterialConnectionPoint;
  129219. /**
  129220. * Gets the right operand input component
  129221. */
  129222. get right(): NodeMaterialConnectionPoint;
  129223. /**
  129224. * Gets the output component
  129225. */
  129226. get output(): NodeMaterialConnectionPoint;
  129227. protected _buildBlock(state: NodeMaterialBuildState): this;
  129228. }
  129229. }
  129230. declare module BABYLON {
  129231. /**
  129232. * Block used to remap a float from a range to a new one
  129233. */
  129234. export class RemapBlock extends NodeMaterialBlock {
  129235. /**
  129236. * Gets or sets the source range
  129237. */
  129238. sourceRange: Vector2;
  129239. /**
  129240. * Gets or sets the target range
  129241. */
  129242. targetRange: Vector2;
  129243. /**
  129244. * Creates a new RemapBlock
  129245. * @param name defines the block name
  129246. */
  129247. constructor(name: string);
  129248. /**
  129249. * Gets the current class name
  129250. * @returns the class name
  129251. */
  129252. getClassName(): string;
  129253. /**
  129254. * Gets the input component
  129255. */
  129256. get input(): NodeMaterialConnectionPoint;
  129257. /**
  129258. * Gets the source min input component
  129259. */
  129260. get sourceMin(): NodeMaterialConnectionPoint;
  129261. /**
  129262. * Gets the source max input component
  129263. */
  129264. get sourceMax(): NodeMaterialConnectionPoint;
  129265. /**
  129266. * Gets the target min input component
  129267. */
  129268. get targetMin(): NodeMaterialConnectionPoint;
  129269. /**
  129270. * Gets the target max input component
  129271. */
  129272. get targetMax(): NodeMaterialConnectionPoint;
  129273. /**
  129274. * Gets the output component
  129275. */
  129276. get output(): NodeMaterialConnectionPoint;
  129277. protected _buildBlock(state: NodeMaterialBuildState): this;
  129278. protected _dumpPropertiesCode(): string;
  129279. serialize(): any;
  129280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129281. }
  129282. }
  129283. declare module BABYLON {
  129284. /**
  129285. * Block used to normalize a vector
  129286. */
  129287. export class NormalizeBlock extends NodeMaterialBlock {
  129288. /**
  129289. * Creates a new NormalizeBlock
  129290. * @param name defines the block name
  129291. */
  129292. constructor(name: string);
  129293. /**
  129294. * Gets the current class name
  129295. * @returns the class name
  129296. */
  129297. getClassName(): string;
  129298. /**
  129299. * Gets the input component
  129300. */
  129301. get input(): NodeMaterialConnectionPoint;
  129302. /**
  129303. * Gets the output component
  129304. */
  129305. get output(): NodeMaterialConnectionPoint;
  129306. protected _buildBlock(state: NodeMaterialBuildState): this;
  129307. }
  129308. }
  129309. declare module BABYLON {
  129310. /**
  129311. * Operations supported by the Trigonometry block
  129312. */
  129313. export enum TrigonometryBlockOperations {
  129314. /** Cos */
  129315. Cos = 0,
  129316. /** Sin */
  129317. Sin = 1,
  129318. /** Abs */
  129319. Abs = 2,
  129320. /** Exp */
  129321. Exp = 3,
  129322. /** Exp2 */
  129323. Exp2 = 4,
  129324. /** Round */
  129325. Round = 5,
  129326. /** Floor */
  129327. Floor = 6,
  129328. /** Ceiling */
  129329. Ceiling = 7,
  129330. /** Square root */
  129331. Sqrt = 8,
  129332. /** Log */
  129333. Log = 9,
  129334. /** Tangent */
  129335. Tan = 10,
  129336. /** Arc tangent */
  129337. ArcTan = 11,
  129338. /** Arc cosinus */
  129339. ArcCos = 12,
  129340. /** Arc sinus */
  129341. ArcSin = 13,
  129342. /** Fraction */
  129343. Fract = 14,
  129344. /** Sign */
  129345. Sign = 15,
  129346. /** To radians (from degrees) */
  129347. Radians = 16,
  129348. /** To degrees (from radians) */
  129349. Degrees = 17
  129350. }
  129351. /**
  129352. * Block used to apply trigonometry operation to floats
  129353. */
  129354. export class TrigonometryBlock extends NodeMaterialBlock {
  129355. /**
  129356. * Gets or sets the operation applied by the block
  129357. */
  129358. operation: TrigonometryBlockOperations;
  129359. /**
  129360. * Creates a new TrigonometryBlock
  129361. * @param name defines the block name
  129362. */
  129363. constructor(name: string);
  129364. /**
  129365. * Gets the current class name
  129366. * @returns the class name
  129367. */
  129368. getClassName(): string;
  129369. /**
  129370. * Gets the input component
  129371. */
  129372. get input(): NodeMaterialConnectionPoint;
  129373. /**
  129374. * Gets the output component
  129375. */
  129376. get output(): NodeMaterialConnectionPoint;
  129377. protected _buildBlock(state: NodeMaterialBuildState): this;
  129378. serialize(): any;
  129379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129380. protected _dumpPropertiesCode(): string;
  129381. }
  129382. }
  129383. declare module BABYLON {
  129384. /**
  129385. * Block used to create a Color3/4 out of individual inputs (one for each component)
  129386. */
  129387. export class ColorMergerBlock extends NodeMaterialBlock {
  129388. /**
  129389. * Create a new ColorMergerBlock
  129390. * @param name defines the block name
  129391. */
  129392. constructor(name: string);
  129393. /**
  129394. * Gets the current class name
  129395. * @returns the class name
  129396. */
  129397. getClassName(): string;
  129398. /**
  129399. * Gets the rgb component (input)
  129400. */
  129401. get rgbIn(): NodeMaterialConnectionPoint;
  129402. /**
  129403. * Gets the r component (input)
  129404. */
  129405. get r(): NodeMaterialConnectionPoint;
  129406. /**
  129407. * Gets the g component (input)
  129408. */
  129409. get g(): NodeMaterialConnectionPoint;
  129410. /**
  129411. * Gets the b component (input)
  129412. */
  129413. get b(): NodeMaterialConnectionPoint;
  129414. /**
  129415. * Gets the a component (input)
  129416. */
  129417. get a(): NodeMaterialConnectionPoint;
  129418. /**
  129419. * Gets the rgba component (output)
  129420. */
  129421. get rgba(): NodeMaterialConnectionPoint;
  129422. /**
  129423. * Gets the rgb component (output)
  129424. */
  129425. get rgbOut(): NodeMaterialConnectionPoint;
  129426. /**
  129427. * Gets the rgb component (output)
  129428. * @deprecated Please use rgbOut instead.
  129429. */
  129430. get rgb(): NodeMaterialConnectionPoint;
  129431. protected _buildBlock(state: NodeMaterialBuildState): this;
  129432. }
  129433. }
  129434. declare module BABYLON {
  129435. /**
  129436. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  129437. */
  129438. export class VectorMergerBlock extends NodeMaterialBlock {
  129439. /**
  129440. * Create a new VectorMergerBlock
  129441. * @param name defines the block name
  129442. */
  129443. constructor(name: string);
  129444. /**
  129445. * Gets the current class name
  129446. * @returns the class name
  129447. */
  129448. getClassName(): string;
  129449. /**
  129450. * Gets the xyz component (input)
  129451. */
  129452. get xyzIn(): NodeMaterialConnectionPoint;
  129453. /**
  129454. * Gets the xy component (input)
  129455. */
  129456. get xyIn(): NodeMaterialConnectionPoint;
  129457. /**
  129458. * Gets the x component (input)
  129459. */
  129460. get x(): NodeMaterialConnectionPoint;
  129461. /**
  129462. * Gets the y component (input)
  129463. */
  129464. get y(): NodeMaterialConnectionPoint;
  129465. /**
  129466. * Gets the z component (input)
  129467. */
  129468. get z(): NodeMaterialConnectionPoint;
  129469. /**
  129470. * Gets the w component (input)
  129471. */
  129472. get w(): NodeMaterialConnectionPoint;
  129473. /**
  129474. * Gets the xyzw component (output)
  129475. */
  129476. get xyzw(): NodeMaterialConnectionPoint;
  129477. /**
  129478. * Gets the xyz component (output)
  129479. */
  129480. get xyzOut(): NodeMaterialConnectionPoint;
  129481. /**
  129482. * Gets the xy component (output)
  129483. */
  129484. get xyOut(): NodeMaterialConnectionPoint;
  129485. /**
  129486. * Gets the xy component (output)
  129487. * @deprecated Please use xyOut instead.
  129488. */
  129489. get xy(): NodeMaterialConnectionPoint;
  129490. /**
  129491. * Gets the xyz component (output)
  129492. * @deprecated Please use xyzOut instead.
  129493. */
  129494. get xyz(): NodeMaterialConnectionPoint;
  129495. protected _buildBlock(state: NodeMaterialBuildState): this;
  129496. }
  129497. }
  129498. declare module BABYLON {
  129499. /**
  129500. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  129501. */
  129502. export class ColorSplitterBlock extends NodeMaterialBlock {
  129503. /**
  129504. * Create a new ColorSplitterBlock
  129505. * @param name defines the block name
  129506. */
  129507. constructor(name: string);
  129508. /**
  129509. * Gets the current class name
  129510. * @returns the class name
  129511. */
  129512. getClassName(): string;
  129513. /**
  129514. * Gets the rgba component (input)
  129515. */
  129516. get rgba(): NodeMaterialConnectionPoint;
  129517. /**
  129518. * Gets the rgb component (input)
  129519. */
  129520. get rgbIn(): NodeMaterialConnectionPoint;
  129521. /**
  129522. * Gets the rgb component (output)
  129523. */
  129524. get rgbOut(): NodeMaterialConnectionPoint;
  129525. /**
  129526. * Gets the r component (output)
  129527. */
  129528. get r(): NodeMaterialConnectionPoint;
  129529. /**
  129530. * Gets the g component (output)
  129531. */
  129532. get g(): NodeMaterialConnectionPoint;
  129533. /**
  129534. * Gets the b component (output)
  129535. */
  129536. get b(): NodeMaterialConnectionPoint;
  129537. /**
  129538. * Gets the a component (output)
  129539. */
  129540. get a(): NodeMaterialConnectionPoint;
  129541. protected _inputRename(name: string): string;
  129542. protected _outputRename(name: string): string;
  129543. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129544. }
  129545. }
  129546. declare module BABYLON {
  129547. /**
  129548. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  129549. */
  129550. export class VectorSplitterBlock extends NodeMaterialBlock {
  129551. /**
  129552. * Create a new VectorSplitterBlock
  129553. * @param name defines the block name
  129554. */
  129555. constructor(name: string);
  129556. /**
  129557. * Gets the current class name
  129558. * @returns the class name
  129559. */
  129560. getClassName(): string;
  129561. /**
  129562. * Gets the xyzw component (input)
  129563. */
  129564. get xyzw(): NodeMaterialConnectionPoint;
  129565. /**
  129566. * Gets the xyz component (input)
  129567. */
  129568. get xyzIn(): NodeMaterialConnectionPoint;
  129569. /**
  129570. * Gets the xy component (input)
  129571. */
  129572. get xyIn(): NodeMaterialConnectionPoint;
  129573. /**
  129574. * Gets the xyz component (output)
  129575. */
  129576. get xyzOut(): NodeMaterialConnectionPoint;
  129577. /**
  129578. * Gets the xy component (output)
  129579. */
  129580. get xyOut(): NodeMaterialConnectionPoint;
  129581. /**
  129582. * Gets the x component (output)
  129583. */
  129584. get x(): NodeMaterialConnectionPoint;
  129585. /**
  129586. * Gets the y component (output)
  129587. */
  129588. get y(): NodeMaterialConnectionPoint;
  129589. /**
  129590. * Gets the z component (output)
  129591. */
  129592. get z(): NodeMaterialConnectionPoint;
  129593. /**
  129594. * Gets the w component (output)
  129595. */
  129596. get w(): NodeMaterialConnectionPoint;
  129597. protected _inputRename(name: string): string;
  129598. protected _outputRename(name: string): string;
  129599. protected _buildBlock(state: NodeMaterialBuildState): this;
  129600. }
  129601. }
  129602. declare module BABYLON {
  129603. /**
  129604. * Block used to lerp between 2 values
  129605. */
  129606. export class LerpBlock extends NodeMaterialBlock {
  129607. /**
  129608. * Creates a new LerpBlock
  129609. * @param name defines the block name
  129610. */
  129611. constructor(name: string);
  129612. /**
  129613. * Gets the current class name
  129614. * @returns the class name
  129615. */
  129616. getClassName(): string;
  129617. /**
  129618. * Gets the left operand input component
  129619. */
  129620. get left(): NodeMaterialConnectionPoint;
  129621. /**
  129622. * Gets the right operand input component
  129623. */
  129624. get right(): NodeMaterialConnectionPoint;
  129625. /**
  129626. * Gets the gradient operand input component
  129627. */
  129628. get gradient(): NodeMaterialConnectionPoint;
  129629. /**
  129630. * Gets the output component
  129631. */
  129632. get output(): NodeMaterialConnectionPoint;
  129633. protected _buildBlock(state: NodeMaterialBuildState): this;
  129634. }
  129635. }
  129636. declare module BABYLON {
  129637. /**
  129638. * Block used to divide 2 vectors
  129639. */
  129640. export class DivideBlock extends NodeMaterialBlock {
  129641. /**
  129642. * Creates a new DivideBlock
  129643. * @param name defines the block name
  129644. */
  129645. constructor(name: string);
  129646. /**
  129647. * Gets the current class name
  129648. * @returns the class name
  129649. */
  129650. getClassName(): string;
  129651. /**
  129652. * Gets the left operand input component
  129653. */
  129654. get left(): NodeMaterialConnectionPoint;
  129655. /**
  129656. * Gets the right operand input component
  129657. */
  129658. get right(): NodeMaterialConnectionPoint;
  129659. /**
  129660. * Gets the output component
  129661. */
  129662. get output(): NodeMaterialConnectionPoint;
  129663. protected _buildBlock(state: NodeMaterialBuildState): this;
  129664. }
  129665. }
  129666. declare module BABYLON {
  129667. /**
  129668. * Block used to subtract 2 vectors
  129669. */
  129670. export class SubtractBlock extends NodeMaterialBlock {
  129671. /**
  129672. * Creates a new SubtractBlock
  129673. * @param name defines the block name
  129674. */
  129675. constructor(name: string);
  129676. /**
  129677. * Gets the current class name
  129678. * @returns the class name
  129679. */
  129680. getClassName(): string;
  129681. /**
  129682. * Gets the left operand input component
  129683. */
  129684. get left(): NodeMaterialConnectionPoint;
  129685. /**
  129686. * Gets the right operand input component
  129687. */
  129688. get right(): NodeMaterialConnectionPoint;
  129689. /**
  129690. * Gets the output component
  129691. */
  129692. get output(): NodeMaterialConnectionPoint;
  129693. protected _buildBlock(state: NodeMaterialBuildState): this;
  129694. }
  129695. }
  129696. declare module BABYLON {
  129697. /**
  129698. * Block used to step a value
  129699. */
  129700. export class StepBlock extends NodeMaterialBlock {
  129701. /**
  129702. * Creates a new StepBlock
  129703. * @param name defines the block name
  129704. */
  129705. constructor(name: string);
  129706. /**
  129707. * Gets the current class name
  129708. * @returns the class name
  129709. */
  129710. getClassName(): string;
  129711. /**
  129712. * Gets the value operand input component
  129713. */
  129714. get value(): NodeMaterialConnectionPoint;
  129715. /**
  129716. * Gets the edge operand input component
  129717. */
  129718. get edge(): NodeMaterialConnectionPoint;
  129719. /**
  129720. * Gets the output component
  129721. */
  129722. get output(): NodeMaterialConnectionPoint;
  129723. protected _buildBlock(state: NodeMaterialBuildState): this;
  129724. }
  129725. }
  129726. declare module BABYLON {
  129727. /**
  129728. * Block used to get the opposite (1 - x) of a value
  129729. */
  129730. export class OneMinusBlock extends NodeMaterialBlock {
  129731. /**
  129732. * Creates a new OneMinusBlock
  129733. * @param name defines the block name
  129734. */
  129735. constructor(name: string);
  129736. /**
  129737. * Gets the current class name
  129738. * @returns the class name
  129739. */
  129740. getClassName(): string;
  129741. /**
  129742. * Gets the input component
  129743. */
  129744. get input(): NodeMaterialConnectionPoint;
  129745. /**
  129746. * Gets the output component
  129747. */
  129748. get output(): NodeMaterialConnectionPoint;
  129749. protected _buildBlock(state: NodeMaterialBuildState): this;
  129750. }
  129751. }
  129752. declare module BABYLON {
  129753. /**
  129754. * Block used to get the view direction
  129755. */
  129756. export class ViewDirectionBlock extends NodeMaterialBlock {
  129757. /**
  129758. * Creates a new ViewDirectionBlock
  129759. * @param name defines the block name
  129760. */
  129761. constructor(name: string);
  129762. /**
  129763. * Gets the current class name
  129764. * @returns the class name
  129765. */
  129766. getClassName(): string;
  129767. /**
  129768. * Gets the world position component
  129769. */
  129770. get worldPosition(): NodeMaterialConnectionPoint;
  129771. /**
  129772. * Gets the camera position component
  129773. */
  129774. get cameraPosition(): NodeMaterialConnectionPoint;
  129775. /**
  129776. * Gets the output component
  129777. */
  129778. get output(): NodeMaterialConnectionPoint;
  129779. autoConfigure(material: NodeMaterial): void;
  129780. protected _buildBlock(state: NodeMaterialBuildState): this;
  129781. }
  129782. }
  129783. declare module BABYLON {
  129784. /**
  129785. * Block used to compute fresnel value
  129786. */
  129787. export class FresnelBlock extends NodeMaterialBlock {
  129788. /**
  129789. * Create a new FresnelBlock
  129790. * @param name defines the block name
  129791. */
  129792. constructor(name: string);
  129793. /**
  129794. * Gets the current class name
  129795. * @returns the class name
  129796. */
  129797. getClassName(): string;
  129798. /**
  129799. * Gets the world normal input component
  129800. */
  129801. get worldNormal(): NodeMaterialConnectionPoint;
  129802. /**
  129803. * Gets the view direction input component
  129804. */
  129805. get viewDirection(): NodeMaterialConnectionPoint;
  129806. /**
  129807. * Gets the bias input component
  129808. */
  129809. get bias(): NodeMaterialConnectionPoint;
  129810. /**
  129811. * Gets the camera (or eye) position component
  129812. */
  129813. get power(): NodeMaterialConnectionPoint;
  129814. /**
  129815. * Gets the fresnel output component
  129816. */
  129817. get fresnel(): NodeMaterialConnectionPoint;
  129818. autoConfigure(material: NodeMaterial): void;
  129819. protected _buildBlock(state: NodeMaterialBuildState): this;
  129820. }
  129821. }
  129822. declare module BABYLON {
  129823. /**
  129824. * Block used to get the max of 2 values
  129825. */
  129826. export class MaxBlock extends NodeMaterialBlock {
  129827. /**
  129828. * Creates a new MaxBlock
  129829. * @param name defines the block name
  129830. */
  129831. constructor(name: string);
  129832. /**
  129833. * Gets the current class name
  129834. * @returns the class name
  129835. */
  129836. getClassName(): string;
  129837. /**
  129838. * Gets the left operand input component
  129839. */
  129840. get left(): NodeMaterialConnectionPoint;
  129841. /**
  129842. * Gets the right operand input component
  129843. */
  129844. get right(): NodeMaterialConnectionPoint;
  129845. /**
  129846. * Gets the output component
  129847. */
  129848. get output(): NodeMaterialConnectionPoint;
  129849. protected _buildBlock(state: NodeMaterialBuildState): this;
  129850. }
  129851. }
  129852. declare module BABYLON {
  129853. /**
  129854. * Block used to get the min of 2 values
  129855. */
  129856. export class MinBlock extends NodeMaterialBlock {
  129857. /**
  129858. * Creates a new MinBlock
  129859. * @param name defines the block name
  129860. */
  129861. constructor(name: string);
  129862. /**
  129863. * Gets the current class name
  129864. * @returns the class name
  129865. */
  129866. getClassName(): string;
  129867. /**
  129868. * Gets the left operand input component
  129869. */
  129870. get left(): NodeMaterialConnectionPoint;
  129871. /**
  129872. * Gets the right operand input component
  129873. */
  129874. get right(): NodeMaterialConnectionPoint;
  129875. /**
  129876. * Gets the output component
  129877. */
  129878. get output(): NodeMaterialConnectionPoint;
  129879. protected _buildBlock(state: NodeMaterialBuildState): this;
  129880. }
  129881. }
  129882. declare module BABYLON {
  129883. /**
  129884. * Block used to get the distance between 2 values
  129885. */
  129886. export class DistanceBlock extends NodeMaterialBlock {
  129887. /**
  129888. * Creates a new DistanceBlock
  129889. * @param name defines the block name
  129890. */
  129891. constructor(name: string);
  129892. /**
  129893. * Gets the current class name
  129894. * @returns the class name
  129895. */
  129896. getClassName(): string;
  129897. /**
  129898. * Gets the left operand input component
  129899. */
  129900. get left(): NodeMaterialConnectionPoint;
  129901. /**
  129902. * Gets the right operand input component
  129903. */
  129904. get right(): NodeMaterialConnectionPoint;
  129905. /**
  129906. * Gets the output component
  129907. */
  129908. get output(): NodeMaterialConnectionPoint;
  129909. protected _buildBlock(state: NodeMaterialBuildState): this;
  129910. }
  129911. }
  129912. declare module BABYLON {
  129913. /**
  129914. * Block used to get the length of a vector
  129915. */
  129916. export class LengthBlock extends NodeMaterialBlock {
  129917. /**
  129918. * Creates a new LengthBlock
  129919. * @param name defines the block name
  129920. */
  129921. constructor(name: string);
  129922. /**
  129923. * Gets the current class name
  129924. * @returns the class name
  129925. */
  129926. getClassName(): string;
  129927. /**
  129928. * Gets the value input component
  129929. */
  129930. get value(): NodeMaterialConnectionPoint;
  129931. /**
  129932. * Gets the output component
  129933. */
  129934. get output(): NodeMaterialConnectionPoint;
  129935. protected _buildBlock(state: NodeMaterialBuildState): this;
  129936. }
  129937. }
  129938. declare module BABYLON {
  129939. /**
  129940. * Block used to get negative version of a value (i.e. x * -1)
  129941. */
  129942. export class NegateBlock extends NodeMaterialBlock {
  129943. /**
  129944. * Creates a new NegateBlock
  129945. * @param name defines the block name
  129946. */
  129947. constructor(name: string);
  129948. /**
  129949. * Gets the current class name
  129950. * @returns the class name
  129951. */
  129952. getClassName(): string;
  129953. /**
  129954. * Gets the value input component
  129955. */
  129956. get value(): NodeMaterialConnectionPoint;
  129957. /**
  129958. * Gets the output component
  129959. */
  129960. get output(): NodeMaterialConnectionPoint;
  129961. protected _buildBlock(state: NodeMaterialBuildState): this;
  129962. }
  129963. }
  129964. declare module BABYLON {
  129965. /**
  129966. * Block used to get the value of the first parameter raised to the power of the second
  129967. */
  129968. export class PowBlock extends NodeMaterialBlock {
  129969. /**
  129970. * Creates a new PowBlock
  129971. * @param name defines the block name
  129972. */
  129973. constructor(name: string);
  129974. /**
  129975. * Gets the current class name
  129976. * @returns the class name
  129977. */
  129978. getClassName(): string;
  129979. /**
  129980. * Gets the value operand input component
  129981. */
  129982. get value(): NodeMaterialConnectionPoint;
  129983. /**
  129984. * Gets the power operand input component
  129985. */
  129986. get power(): NodeMaterialConnectionPoint;
  129987. /**
  129988. * Gets the output component
  129989. */
  129990. get output(): NodeMaterialConnectionPoint;
  129991. protected _buildBlock(state: NodeMaterialBuildState): this;
  129992. }
  129993. }
  129994. declare module BABYLON {
  129995. /**
  129996. * Block used to get a random number
  129997. */
  129998. export class RandomNumberBlock extends NodeMaterialBlock {
  129999. /**
  130000. * Creates a new RandomNumberBlock
  130001. * @param name defines the block name
  130002. */
  130003. constructor(name: string);
  130004. /**
  130005. * Gets the current class name
  130006. * @returns the class name
  130007. */
  130008. getClassName(): string;
  130009. /**
  130010. * Gets the seed input component
  130011. */
  130012. get seed(): NodeMaterialConnectionPoint;
  130013. /**
  130014. * Gets the output component
  130015. */
  130016. get output(): NodeMaterialConnectionPoint;
  130017. protected _buildBlock(state: NodeMaterialBuildState): this;
  130018. }
  130019. }
  130020. declare module BABYLON {
  130021. /**
  130022. * Block used to compute arc tangent of 2 values
  130023. */
  130024. export class ArcTan2Block extends NodeMaterialBlock {
  130025. /**
  130026. * Creates a new ArcTan2Block
  130027. * @param name defines the block name
  130028. */
  130029. constructor(name: string);
  130030. /**
  130031. * Gets the current class name
  130032. * @returns the class name
  130033. */
  130034. getClassName(): string;
  130035. /**
  130036. * Gets the x operand input component
  130037. */
  130038. get x(): NodeMaterialConnectionPoint;
  130039. /**
  130040. * Gets the y operand input component
  130041. */
  130042. get y(): NodeMaterialConnectionPoint;
  130043. /**
  130044. * Gets the output component
  130045. */
  130046. get output(): NodeMaterialConnectionPoint;
  130047. protected _buildBlock(state: NodeMaterialBuildState): this;
  130048. }
  130049. }
  130050. declare module BABYLON {
  130051. /**
  130052. * Block used to smooth step a value
  130053. */
  130054. export class SmoothStepBlock extends NodeMaterialBlock {
  130055. /**
  130056. * Creates a new SmoothStepBlock
  130057. * @param name defines the block name
  130058. */
  130059. constructor(name: string);
  130060. /**
  130061. * Gets the current class name
  130062. * @returns the class name
  130063. */
  130064. getClassName(): string;
  130065. /**
  130066. * Gets the value operand input component
  130067. */
  130068. get value(): NodeMaterialConnectionPoint;
  130069. /**
  130070. * Gets the first edge operand input component
  130071. */
  130072. get edge0(): NodeMaterialConnectionPoint;
  130073. /**
  130074. * Gets the second edge operand input component
  130075. */
  130076. get edge1(): NodeMaterialConnectionPoint;
  130077. /**
  130078. * Gets the output component
  130079. */
  130080. get output(): NodeMaterialConnectionPoint;
  130081. protected _buildBlock(state: NodeMaterialBuildState): this;
  130082. }
  130083. }
  130084. declare module BABYLON {
  130085. /**
  130086. * Block used to get the reciprocal (1 / x) of a value
  130087. */
  130088. export class ReciprocalBlock extends NodeMaterialBlock {
  130089. /**
  130090. * Creates a new ReciprocalBlock
  130091. * @param name defines the block name
  130092. */
  130093. constructor(name: string);
  130094. /**
  130095. * Gets the current class name
  130096. * @returns the class name
  130097. */
  130098. getClassName(): string;
  130099. /**
  130100. * Gets the input component
  130101. */
  130102. get input(): NodeMaterialConnectionPoint;
  130103. /**
  130104. * Gets the output component
  130105. */
  130106. get output(): NodeMaterialConnectionPoint;
  130107. protected _buildBlock(state: NodeMaterialBuildState): this;
  130108. }
  130109. }
  130110. declare module BABYLON {
  130111. /**
  130112. * Block used to replace a color by another one
  130113. */
  130114. export class ReplaceColorBlock extends NodeMaterialBlock {
  130115. /**
  130116. * Creates a new ReplaceColorBlock
  130117. * @param name defines the block name
  130118. */
  130119. constructor(name: string);
  130120. /**
  130121. * Gets the current class name
  130122. * @returns the class name
  130123. */
  130124. getClassName(): string;
  130125. /**
  130126. * Gets the value input component
  130127. */
  130128. get value(): NodeMaterialConnectionPoint;
  130129. /**
  130130. * Gets the reference input component
  130131. */
  130132. get reference(): NodeMaterialConnectionPoint;
  130133. /**
  130134. * Gets the distance input component
  130135. */
  130136. get distance(): NodeMaterialConnectionPoint;
  130137. /**
  130138. * Gets the replacement input component
  130139. */
  130140. get replacement(): NodeMaterialConnectionPoint;
  130141. /**
  130142. * Gets the output component
  130143. */
  130144. get output(): NodeMaterialConnectionPoint;
  130145. protected _buildBlock(state: NodeMaterialBuildState): this;
  130146. }
  130147. }
  130148. declare module BABYLON {
  130149. /**
  130150. * Block used to posterize a value
  130151. * @see https://en.wikipedia.org/wiki/Posterization
  130152. */
  130153. export class PosterizeBlock extends NodeMaterialBlock {
  130154. /**
  130155. * Creates a new PosterizeBlock
  130156. * @param name defines the block name
  130157. */
  130158. constructor(name: string);
  130159. /**
  130160. * Gets the current class name
  130161. * @returns the class name
  130162. */
  130163. getClassName(): string;
  130164. /**
  130165. * Gets the value input component
  130166. */
  130167. get value(): NodeMaterialConnectionPoint;
  130168. /**
  130169. * Gets the steps input component
  130170. */
  130171. get steps(): NodeMaterialConnectionPoint;
  130172. /**
  130173. * Gets the output component
  130174. */
  130175. get output(): NodeMaterialConnectionPoint;
  130176. protected _buildBlock(state: NodeMaterialBuildState): this;
  130177. }
  130178. }
  130179. declare module BABYLON {
  130180. /**
  130181. * Operations supported by the Wave block
  130182. */
  130183. export enum WaveBlockKind {
  130184. /** SawTooth */
  130185. SawTooth = 0,
  130186. /** Square */
  130187. Square = 1,
  130188. /** Triangle */
  130189. Triangle = 2
  130190. }
  130191. /**
  130192. * Block used to apply wave operation to floats
  130193. */
  130194. export class WaveBlock extends NodeMaterialBlock {
  130195. /**
  130196. * Gets or sets the kibnd of wave to be applied by the block
  130197. */
  130198. kind: WaveBlockKind;
  130199. /**
  130200. * Creates a new WaveBlock
  130201. * @param name defines the block name
  130202. */
  130203. constructor(name: string);
  130204. /**
  130205. * Gets the current class name
  130206. * @returns the class name
  130207. */
  130208. getClassName(): string;
  130209. /**
  130210. * Gets the input component
  130211. */
  130212. get input(): NodeMaterialConnectionPoint;
  130213. /**
  130214. * Gets the output component
  130215. */
  130216. get output(): NodeMaterialConnectionPoint;
  130217. protected _buildBlock(state: NodeMaterialBuildState): this;
  130218. serialize(): any;
  130219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130220. }
  130221. }
  130222. declare module BABYLON {
  130223. /**
  130224. * Class used to store a color step for the GradientBlock
  130225. */
  130226. export class GradientBlockColorStep {
  130227. /**
  130228. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  130229. */
  130230. step: number;
  130231. /**
  130232. * Gets or sets the color associated with this step
  130233. */
  130234. color: Color3;
  130235. /**
  130236. * Creates a new GradientBlockColorStep
  130237. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  130238. * @param color defines the color associated with this step
  130239. */
  130240. constructor(
  130241. /**
  130242. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  130243. */
  130244. step: number,
  130245. /**
  130246. * Gets or sets the color associated with this step
  130247. */
  130248. color: Color3);
  130249. }
  130250. /**
  130251. * Block used to return a color from a gradient based on an input value between 0 and 1
  130252. */
  130253. export class GradientBlock extends NodeMaterialBlock {
  130254. /**
  130255. * Gets or sets the list of color steps
  130256. */
  130257. colorSteps: GradientBlockColorStep[];
  130258. /**
  130259. * Creates a new GradientBlock
  130260. * @param name defines the block name
  130261. */
  130262. constructor(name: string);
  130263. /**
  130264. * Gets the current class name
  130265. * @returns the class name
  130266. */
  130267. getClassName(): string;
  130268. /**
  130269. * Gets the gradient input component
  130270. */
  130271. get gradient(): NodeMaterialConnectionPoint;
  130272. /**
  130273. * Gets the output component
  130274. */
  130275. get output(): NodeMaterialConnectionPoint;
  130276. private _writeColorConstant;
  130277. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130278. serialize(): any;
  130279. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130280. protected _dumpPropertiesCode(): string;
  130281. }
  130282. }
  130283. declare module BABYLON {
  130284. /**
  130285. * Block used to normalize lerp between 2 values
  130286. */
  130287. export class NLerpBlock extends NodeMaterialBlock {
  130288. /**
  130289. * Creates a new NLerpBlock
  130290. * @param name defines the block name
  130291. */
  130292. constructor(name: string);
  130293. /**
  130294. * Gets the current class name
  130295. * @returns the class name
  130296. */
  130297. getClassName(): string;
  130298. /**
  130299. * Gets the left operand input component
  130300. */
  130301. get left(): NodeMaterialConnectionPoint;
  130302. /**
  130303. * Gets the right operand input component
  130304. */
  130305. get right(): NodeMaterialConnectionPoint;
  130306. /**
  130307. * Gets the gradient operand input component
  130308. */
  130309. get gradient(): NodeMaterialConnectionPoint;
  130310. /**
  130311. * Gets the output component
  130312. */
  130313. get output(): NodeMaterialConnectionPoint;
  130314. protected _buildBlock(state: NodeMaterialBuildState): this;
  130315. }
  130316. }
  130317. declare module BABYLON {
  130318. /**
  130319. * block used to Generate a Worley Noise 3D Noise Pattern
  130320. */
  130321. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  130322. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  130323. manhattanDistance: boolean;
  130324. /**
  130325. * Creates a new WorleyNoise3DBlock
  130326. * @param name defines the block name
  130327. */
  130328. constructor(name: string);
  130329. /**
  130330. * Gets the current class name
  130331. * @returns the class name
  130332. */
  130333. getClassName(): string;
  130334. /**
  130335. * Gets the seed input component
  130336. */
  130337. get seed(): NodeMaterialConnectionPoint;
  130338. /**
  130339. * Gets the jitter input component
  130340. */
  130341. get jitter(): NodeMaterialConnectionPoint;
  130342. /**
  130343. * Gets the output component
  130344. */
  130345. get output(): NodeMaterialConnectionPoint;
  130346. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130347. /**
  130348. * Exposes the properties to the UI?
  130349. */
  130350. protected _dumpPropertiesCode(): string;
  130351. /**
  130352. * Exposes the properties to the Seralize?
  130353. */
  130354. serialize(): any;
  130355. /**
  130356. * Exposes the properties to the deseralize?
  130357. */
  130358. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130359. }
  130360. }
  130361. declare module BABYLON {
  130362. /**
  130363. * block used to Generate a Simplex Perlin 3d Noise Pattern
  130364. */
  130365. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  130366. /**
  130367. * Creates a new SimplexPerlin3DBlock
  130368. * @param name defines the block name
  130369. */
  130370. constructor(name: string);
  130371. /**
  130372. * Gets the current class name
  130373. * @returns the class name
  130374. */
  130375. getClassName(): string;
  130376. /**
  130377. * Gets the seed operand input component
  130378. */
  130379. get seed(): NodeMaterialConnectionPoint;
  130380. /**
  130381. * Gets the output component
  130382. */
  130383. get output(): NodeMaterialConnectionPoint;
  130384. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130385. }
  130386. }
  130387. declare module BABYLON {
  130388. /**
  130389. * Block used to blend normals
  130390. */
  130391. export class NormalBlendBlock extends NodeMaterialBlock {
  130392. /**
  130393. * Creates a new NormalBlendBlock
  130394. * @param name defines the block name
  130395. */
  130396. constructor(name: string);
  130397. /**
  130398. * Gets the current class name
  130399. * @returns the class name
  130400. */
  130401. getClassName(): string;
  130402. /**
  130403. * Gets the first input component
  130404. */
  130405. get normalMap0(): NodeMaterialConnectionPoint;
  130406. /**
  130407. * Gets the second input component
  130408. */
  130409. get normalMap1(): NodeMaterialConnectionPoint;
  130410. /**
  130411. * Gets the output component
  130412. */
  130413. get output(): NodeMaterialConnectionPoint;
  130414. protected _buildBlock(state: NodeMaterialBuildState): this;
  130415. }
  130416. }
  130417. declare module BABYLON {
  130418. /**
  130419. * Block used to rotate a 2d vector by a given angle
  130420. */
  130421. export class Rotate2dBlock extends NodeMaterialBlock {
  130422. /**
  130423. * Creates a new Rotate2dBlock
  130424. * @param name defines the block name
  130425. */
  130426. constructor(name: string);
  130427. /**
  130428. * Gets the current class name
  130429. * @returns the class name
  130430. */
  130431. getClassName(): string;
  130432. /**
  130433. * Gets the input vector
  130434. */
  130435. get input(): NodeMaterialConnectionPoint;
  130436. /**
  130437. * Gets the input angle
  130438. */
  130439. get angle(): NodeMaterialConnectionPoint;
  130440. /**
  130441. * Gets the output component
  130442. */
  130443. get output(): NodeMaterialConnectionPoint;
  130444. autoConfigure(material: NodeMaterial): void;
  130445. protected _buildBlock(state: NodeMaterialBuildState): this;
  130446. }
  130447. }
  130448. declare module BABYLON {
  130449. /**
  130450. * Block used to get the reflected vector from a direction and a normal
  130451. */
  130452. export class ReflectBlock extends NodeMaterialBlock {
  130453. /**
  130454. * Creates a new ReflectBlock
  130455. * @param name defines the block name
  130456. */
  130457. constructor(name: string);
  130458. /**
  130459. * Gets the current class name
  130460. * @returns the class name
  130461. */
  130462. getClassName(): string;
  130463. /**
  130464. * Gets the incident component
  130465. */
  130466. get incident(): NodeMaterialConnectionPoint;
  130467. /**
  130468. * Gets the normal component
  130469. */
  130470. get normal(): NodeMaterialConnectionPoint;
  130471. /**
  130472. * Gets the output component
  130473. */
  130474. get output(): NodeMaterialConnectionPoint;
  130475. protected _buildBlock(state: NodeMaterialBuildState): this;
  130476. }
  130477. }
  130478. declare module BABYLON {
  130479. /**
  130480. * Block used to get the refracted vector from a direction and a normal
  130481. */
  130482. export class RefractBlock extends NodeMaterialBlock {
  130483. /**
  130484. * Creates a new RefractBlock
  130485. * @param name defines the block name
  130486. */
  130487. constructor(name: string);
  130488. /**
  130489. * Gets the current class name
  130490. * @returns the class name
  130491. */
  130492. getClassName(): string;
  130493. /**
  130494. * Gets the incident component
  130495. */
  130496. get incident(): NodeMaterialConnectionPoint;
  130497. /**
  130498. * Gets the normal component
  130499. */
  130500. get normal(): NodeMaterialConnectionPoint;
  130501. /**
  130502. * Gets the index of refraction component
  130503. */
  130504. get ior(): NodeMaterialConnectionPoint;
  130505. /**
  130506. * Gets the output component
  130507. */
  130508. get output(): NodeMaterialConnectionPoint;
  130509. protected _buildBlock(state: NodeMaterialBuildState): this;
  130510. }
  130511. }
  130512. declare module BABYLON {
  130513. /**
  130514. * Block used to desaturate a color
  130515. */
  130516. export class DesaturateBlock extends NodeMaterialBlock {
  130517. /**
  130518. * Creates a new DesaturateBlock
  130519. * @param name defines the block name
  130520. */
  130521. constructor(name: string);
  130522. /**
  130523. * Gets the current class name
  130524. * @returns the class name
  130525. */
  130526. getClassName(): string;
  130527. /**
  130528. * Gets the color operand input component
  130529. */
  130530. get color(): NodeMaterialConnectionPoint;
  130531. /**
  130532. * Gets the level operand input component
  130533. */
  130534. get level(): NodeMaterialConnectionPoint;
  130535. /**
  130536. * Gets the output component
  130537. */
  130538. get output(): NodeMaterialConnectionPoint;
  130539. protected _buildBlock(state: NodeMaterialBuildState): this;
  130540. }
  130541. }
  130542. declare module BABYLON {
  130543. /**
  130544. * Effect Render Options
  130545. */
  130546. export interface IEffectRendererOptions {
  130547. /**
  130548. * Defines the vertices positions.
  130549. */
  130550. positions?: number[];
  130551. /**
  130552. * Defines the indices.
  130553. */
  130554. indices?: number[];
  130555. }
  130556. /**
  130557. * Helper class to render one or more effects
  130558. */
  130559. export class EffectRenderer {
  130560. private engine;
  130561. private static _DefaultOptions;
  130562. private _vertexBuffers;
  130563. private _indexBuffer;
  130564. private _ringBufferIndex;
  130565. private _ringScreenBuffer;
  130566. private _fullscreenViewport;
  130567. private _getNextFrameBuffer;
  130568. /**
  130569. * Creates an effect renderer
  130570. * @param engine the engine to use for rendering
  130571. * @param options defines the options of the effect renderer
  130572. */
  130573. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  130574. /**
  130575. * Sets the current viewport in normalized coordinates 0-1
  130576. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  130577. */
  130578. setViewport(viewport?: Viewport): void;
  130579. /**
  130580. * Binds the embedded attributes buffer to the effect.
  130581. * @param effect Defines the effect to bind the attributes for
  130582. */
  130583. bindBuffers(effect: Effect): void;
  130584. /**
  130585. * Sets the current effect wrapper to use during draw.
  130586. * The effect needs to be ready before calling this api.
  130587. * This also sets the default full screen position attribute.
  130588. * @param effectWrapper Defines the effect to draw with
  130589. */
  130590. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  130591. /**
  130592. * Draws a full screen quad.
  130593. */
  130594. draw(): void;
  130595. /**
  130596. * renders one or more effects to a specified texture
  130597. * @param effectWrappers list of effects to renderer
  130598. * @param outputTexture texture to draw to, if null it will render to the screen
  130599. */
  130600. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  130601. /**
  130602. * Disposes of the effect renderer
  130603. */
  130604. dispose(): void;
  130605. }
  130606. /**
  130607. * Options to create an EffectWrapper
  130608. */
  130609. interface EffectWrapperCreationOptions {
  130610. /**
  130611. * Engine to use to create the effect
  130612. */
  130613. engine: ThinEngine;
  130614. /**
  130615. * Fragment shader for the effect
  130616. */
  130617. fragmentShader: string;
  130618. /**
  130619. * Vertex shader for the effect
  130620. */
  130621. vertexShader?: string;
  130622. /**
  130623. * Attributes to use in the shader
  130624. */
  130625. attributeNames?: Array<string>;
  130626. /**
  130627. * Uniforms to use in the shader
  130628. */
  130629. uniformNames?: Array<string>;
  130630. /**
  130631. * Texture sampler names to use in the shader
  130632. */
  130633. samplerNames?: Array<string>;
  130634. /**
  130635. * The friendly name of the effect displayed in Spector.
  130636. */
  130637. name?: string;
  130638. }
  130639. /**
  130640. * Wraps an effect to be used for rendering
  130641. */
  130642. export class EffectWrapper {
  130643. /**
  130644. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  130645. */
  130646. onApplyObservable: Observable<{}>;
  130647. /**
  130648. * The underlying effect
  130649. */
  130650. effect: Effect;
  130651. /**
  130652. * Creates an effect to be renderer
  130653. * @param creationOptions options to create the effect
  130654. */
  130655. constructor(creationOptions: EffectWrapperCreationOptions);
  130656. /**
  130657. * Disposes of the effect wrapper
  130658. */
  130659. dispose(): void;
  130660. }
  130661. }
  130662. declare module BABYLON {
  130663. /**
  130664. * Helper class to push actions to a pool of workers.
  130665. */
  130666. export class WorkerPool implements IDisposable {
  130667. private _workerInfos;
  130668. private _pendingActions;
  130669. /**
  130670. * Constructor
  130671. * @param workers Array of workers to use for actions
  130672. */
  130673. constructor(workers: Array<Worker>);
  130674. /**
  130675. * Terminates all workers and clears any pending actions.
  130676. */
  130677. dispose(): void;
  130678. /**
  130679. * Pushes an action to the worker pool. If all the workers are active, the action will be
  130680. * pended until a worker has completed its action.
  130681. * @param action The action to perform. Call onComplete when the action is complete.
  130682. */
  130683. push(action: (worker: Worker, onComplete: () => void) => void): void;
  130684. private _execute;
  130685. }
  130686. }
  130687. declare module BABYLON {
  130688. /**
  130689. * Configuration for Draco compression
  130690. */
  130691. export interface IDracoCompressionConfiguration {
  130692. /**
  130693. * Configuration for the decoder.
  130694. */
  130695. decoder: {
  130696. /**
  130697. * The url to the WebAssembly module.
  130698. */
  130699. wasmUrl?: string;
  130700. /**
  130701. * The url to the WebAssembly binary.
  130702. */
  130703. wasmBinaryUrl?: string;
  130704. /**
  130705. * The url to the fallback JavaScript module.
  130706. */
  130707. fallbackUrl?: string;
  130708. };
  130709. }
  130710. /**
  130711. * Draco compression (https://google.github.io/draco/)
  130712. *
  130713. * This class wraps the Draco module.
  130714. *
  130715. * **Encoder**
  130716. *
  130717. * The encoder is not currently implemented.
  130718. *
  130719. * **Decoder**
  130720. *
  130721. * 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.
  130722. *
  130723. * To update the configuration, use the following code:
  130724. * ```javascript
  130725. * DracoCompression.Configuration = {
  130726. * decoder: {
  130727. * wasmUrl: "<url to the WebAssembly library>",
  130728. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  130729. * fallbackUrl: "<url to the fallback JavaScript library>",
  130730. * }
  130731. * };
  130732. * ```
  130733. *
  130734. * 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.
  130735. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  130736. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  130737. *
  130738. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  130739. * ```javascript
  130740. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  130741. * ```
  130742. *
  130743. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  130744. */
  130745. export class DracoCompression implements IDisposable {
  130746. private _workerPoolPromise?;
  130747. private _decoderModulePromise?;
  130748. /**
  130749. * The configuration. Defaults to the following urls:
  130750. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  130751. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  130752. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  130753. */
  130754. static Configuration: IDracoCompressionConfiguration;
  130755. /**
  130756. * Returns true if the decoder configuration is available.
  130757. */
  130758. static get DecoderAvailable(): boolean;
  130759. /**
  130760. * Default number of workers to create when creating the draco compression object.
  130761. */
  130762. static DefaultNumWorkers: number;
  130763. private static GetDefaultNumWorkers;
  130764. private static _Default;
  130765. /**
  130766. * Default instance for the draco compression object.
  130767. */
  130768. static get Default(): DracoCompression;
  130769. /**
  130770. * Constructor
  130771. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  130772. */
  130773. constructor(numWorkers?: number);
  130774. /**
  130775. * Stop all async operations and release resources.
  130776. */
  130777. dispose(): void;
  130778. /**
  130779. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  130780. * @returns a promise that resolves when ready
  130781. */
  130782. whenReadyAsync(): Promise<void>;
  130783. /**
  130784. * Decode Draco compressed mesh data to vertex data.
  130785. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  130786. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  130787. * @returns A promise that resolves with the decoded vertex data
  130788. */
  130789. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  130790. [kind: string]: number;
  130791. }): Promise<VertexData>;
  130792. }
  130793. }
  130794. declare module BABYLON {
  130795. /**
  130796. * Class for building Constructive Solid Geometry
  130797. */
  130798. export class CSG {
  130799. private polygons;
  130800. /**
  130801. * The world matrix
  130802. */
  130803. matrix: Matrix;
  130804. /**
  130805. * Stores the position
  130806. */
  130807. position: Vector3;
  130808. /**
  130809. * Stores the rotation
  130810. */
  130811. rotation: Vector3;
  130812. /**
  130813. * Stores the rotation quaternion
  130814. */
  130815. rotationQuaternion: Nullable<Quaternion>;
  130816. /**
  130817. * Stores the scaling vector
  130818. */
  130819. scaling: Vector3;
  130820. /**
  130821. * Convert the Mesh to CSG
  130822. * @param mesh The Mesh to convert to CSG
  130823. * @returns A new CSG from the Mesh
  130824. */
  130825. static FromMesh(mesh: Mesh): CSG;
  130826. /**
  130827. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  130828. * @param polygons Polygons used to construct a CSG solid
  130829. */
  130830. private static FromPolygons;
  130831. /**
  130832. * Clones, or makes a deep copy, of the CSG
  130833. * @returns A new CSG
  130834. */
  130835. clone(): CSG;
  130836. /**
  130837. * Unions this CSG with another CSG
  130838. * @param csg The CSG to union against this CSG
  130839. * @returns The unioned CSG
  130840. */
  130841. union(csg: CSG): CSG;
  130842. /**
  130843. * Unions this CSG with another CSG in place
  130844. * @param csg The CSG to union against this CSG
  130845. */
  130846. unionInPlace(csg: CSG): void;
  130847. /**
  130848. * Subtracts this CSG with another CSG
  130849. * @param csg The CSG to subtract against this CSG
  130850. * @returns A new CSG
  130851. */
  130852. subtract(csg: CSG): CSG;
  130853. /**
  130854. * Subtracts this CSG with another CSG in place
  130855. * @param csg The CSG to subtact against this CSG
  130856. */
  130857. subtractInPlace(csg: CSG): void;
  130858. /**
  130859. * Intersect this CSG with another CSG
  130860. * @param csg The CSG to intersect against this CSG
  130861. * @returns A new CSG
  130862. */
  130863. intersect(csg: CSG): CSG;
  130864. /**
  130865. * Intersects this CSG with another CSG in place
  130866. * @param csg The CSG to intersect against this CSG
  130867. */
  130868. intersectInPlace(csg: CSG): void;
  130869. /**
  130870. * Return a new CSG solid with solid and empty space switched. This solid is
  130871. * not modified.
  130872. * @returns A new CSG solid with solid and empty space switched
  130873. */
  130874. inverse(): CSG;
  130875. /**
  130876. * Inverses the CSG in place
  130877. */
  130878. inverseInPlace(): void;
  130879. /**
  130880. * This is used to keep meshes transformations so they can be restored
  130881. * when we build back a Babylon Mesh
  130882. * NB : All CSG operations are performed in world coordinates
  130883. * @param csg The CSG to copy the transform attributes from
  130884. * @returns This CSG
  130885. */
  130886. copyTransformAttributes(csg: CSG): CSG;
  130887. /**
  130888. * Build Raw mesh from CSG
  130889. * Coordinates here are in world space
  130890. * @param name The name of the mesh geometry
  130891. * @param scene The Scene
  130892. * @param keepSubMeshes Specifies if the submeshes should be kept
  130893. * @returns A new Mesh
  130894. */
  130895. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  130896. /**
  130897. * Build Mesh from CSG taking material and transforms into account
  130898. * @param name The name of the Mesh
  130899. * @param material The material of the Mesh
  130900. * @param scene The Scene
  130901. * @param keepSubMeshes Specifies if submeshes should be kept
  130902. * @returns The new Mesh
  130903. */
  130904. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  130905. }
  130906. }
  130907. declare module BABYLON {
  130908. /**
  130909. * Class used to create a trail following a mesh
  130910. */
  130911. export class TrailMesh extends Mesh {
  130912. private _generator;
  130913. private _autoStart;
  130914. private _running;
  130915. private _diameter;
  130916. private _length;
  130917. private _sectionPolygonPointsCount;
  130918. private _sectionVectors;
  130919. private _sectionNormalVectors;
  130920. private _beforeRenderObserver;
  130921. /**
  130922. * @constructor
  130923. * @param name The value used by scene.getMeshByName() to do a lookup.
  130924. * @param generator The mesh to generate a trail.
  130925. * @param scene The scene to add this mesh to.
  130926. * @param diameter Diameter of trailing mesh. Default is 1.
  130927. * @param length Length of trailing mesh. Default is 60.
  130928. * @param autoStart Automatically start trailing mesh. Default true.
  130929. */
  130930. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  130931. /**
  130932. * "TrailMesh"
  130933. * @returns "TrailMesh"
  130934. */
  130935. getClassName(): string;
  130936. private _createMesh;
  130937. /**
  130938. * Start trailing mesh.
  130939. */
  130940. start(): void;
  130941. /**
  130942. * Stop trailing mesh.
  130943. */
  130944. stop(): void;
  130945. /**
  130946. * Update trailing mesh geometry.
  130947. */
  130948. update(): void;
  130949. /**
  130950. * Returns a new TrailMesh object.
  130951. * @param name is a string, the name given to the new mesh
  130952. * @param newGenerator use new generator object for cloned trail mesh
  130953. * @returns a new mesh
  130954. */
  130955. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  130956. /**
  130957. * Serializes this trail mesh
  130958. * @param serializationObject object to write serialization to
  130959. */
  130960. serialize(serializationObject: any): void;
  130961. /**
  130962. * Parses a serialized trail mesh
  130963. * @param parsedMesh the serialized mesh
  130964. * @param scene the scene to create the trail mesh in
  130965. * @returns the created trail mesh
  130966. */
  130967. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  130968. }
  130969. }
  130970. declare module BABYLON {
  130971. /**
  130972. * Class containing static functions to help procedurally build meshes
  130973. */
  130974. export class TiledBoxBuilder {
  130975. /**
  130976. * Creates a box mesh
  130977. * 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)
  130978. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130980. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130982. * @param name defines the name of the mesh
  130983. * @param options defines the options used to create the mesh
  130984. * @param scene defines the hosting scene
  130985. * @returns the box mesh
  130986. */
  130987. static CreateTiledBox(name: string, options: {
  130988. pattern?: number;
  130989. width?: number;
  130990. height?: number;
  130991. depth?: number;
  130992. tileSize?: number;
  130993. tileWidth?: number;
  130994. tileHeight?: number;
  130995. alignHorizontal?: number;
  130996. alignVertical?: number;
  130997. faceUV?: Vector4[];
  130998. faceColors?: Color4[];
  130999. sideOrientation?: number;
  131000. updatable?: boolean;
  131001. }, scene?: Nullable<Scene>): Mesh;
  131002. }
  131003. }
  131004. declare module BABYLON {
  131005. /**
  131006. * Class containing static functions to help procedurally build meshes
  131007. */
  131008. export class TorusKnotBuilder {
  131009. /**
  131010. * Creates a torus knot mesh
  131011. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  131012. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  131013. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  131014. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  131015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131018. * @param name defines the name of the mesh
  131019. * @param options defines the options used to create the mesh
  131020. * @param scene defines the hosting scene
  131021. * @returns the torus knot mesh
  131022. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  131023. */
  131024. static CreateTorusKnot(name: string, options: {
  131025. radius?: number;
  131026. tube?: number;
  131027. radialSegments?: number;
  131028. tubularSegments?: number;
  131029. p?: number;
  131030. q?: number;
  131031. updatable?: boolean;
  131032. sideOrientation?: number;
  131033. frontUVs?: Vector4;
  131034. backUVs?: Vector4;
  131035. }, scene: any): Mesh;
  131036. }
  131037. }
  131038. declare module BABYLON {
  131039. /**
  131040. * Polygon
  131041. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  131042. */
  131043. export class Polygon {
  131044. /**
  131045. * Creates a rectangle
  131046. * @param xmin bottom X coord
  131047. * @param ymin bottom Y coord
  131048. * @param xmax top X coord
  131049. * @param ymax top Y coord
  131050. * @returns points that make the resulting rectation
  131051. */
  131052. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  131053. /**
  131054. * Creates a circle
  131055. * @param radius radius of circle
  131056. * @param cx scale in x
  131057. * @param cy scale in y
  131058. * @param numberOfSides number of sides that make up the circle
  131059. * @returns points that make the resulting circle
  131060. */
  131061. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  131062. /**
  131063. * Creates a polygon from input string
  131064. * @param input Input polygon data
  131065. * @returns the parsed points
  131066. */
  131067. static Parse(input: string): Vector2[];
  131068. /**
  131069. * Starts building a polygon from x and y coordinates
  131070. * @param x x coordinate
  131071. * @param y y coordinate
  131072. * @returns the started path2
  131073. */
  131074. static StartingAt(x: number, y: number): Path2;
  131075. }
  131076. /**
  131077. * Builds a polygon
  131078. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  131079. */
  131080. export class PolygonMeshBuilder {
  131081. private _points;
  131082. private _outlinepoints;
  131083. private _holes;
  131084. private _name;
  131085. private _scene;
  131086. private _epoints;
  131087. private _eholes;
  131088. private _addToepoint;
  131089. /**
  131090. * Babylon reference to the earcut plugin.
  131091. */
  131092. bjsEarcut: any;
  131093. /**
  131094. * Creates a PolygonMeshBuilder
  131095. * @param name name of the builder
  131096. * @param contours Path of the polygon
  131097. * @param scene scene to add to when creating the mesh
  131098. * @param earcutInjection can be used to inject your own earcut reference
  131099. */
  131100. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  131101. /**
  131102. * Adds a whole within the polygon
  131103. * @param hole Array of points defining the hole
  131104. * @returns this
  131105. */
  131106. addHole(hole: Vector2[]): PolygonMeshBuilder;
  131107. /**
  131108. * Creates the polygon
  131109. * @param updatable If the mesh should be updatable
  131110. * @param depth The depth of the mesh created
  131111. * @returns the created mesh
  131112. */
  131113. build(updatable?: boolean, depth?: number): Mesh;
  131114. /**
  131115. * Creates the polygon
  131116. * @param depth The depth of the mesh created
  131117. * @returns the created VertexData
  131118. */
  131119. buildVertexData(depth?: number): VertexData;
  131120. /**
  131121. * Adds a side to the polygon
  131122. * @param positions points that make the polygon
  131123. * @param normals normals of the polygon
  131124. * @param uvs uvs of the polygon
  131125. * @param indices indices of the polygon
  131126. * @param bounds bounds of the polygon
  131127. * @param points points of the polygon
  131128. * @param depth depth of the polygon
  131129. * @param flip flip of the polygon
  131130. */
  131131. private addSide;
  131132. }
  131133. }
  131134. declare module BABYLON {
  131135. /**
  131136. * Class containing static functions to help procedurally build meshes
  131137. */
  131138. export class PolygonBuilder {
  131139. /**
  131140. * Creates a polygon mesh
  131141. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  131142. * * 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
  131143. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  131144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  131146. * * Remember you can only change the shape positions, not their number when updating a polygon
  131147. * @param name defines the name of the mesh
  131148. * @param options defines the options used to create the mesh
  131149. * @param scene defines the hosting scene
  131150. * @param earcutInjection can be used to inject your own earcut reference
  131151. * @returns the polygon mesh
  131152. */
  131153. static CreatePolygon(name: string, options: {
  131154. shape: Vector3[];
  131155. holes?: Vector3[][];
  131156. depth?: number;
  131157. faceUV?: Vector4[];
  131158. faceColors?: Color4[];
  131159. updatable?: boolean;
  131160. sideOrientation?: number;
  131161. frontUVs?: Vector4;
  131162. backUVs?: Vector4;
  131163. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  131164. /**
  131165. * Creates an extruded polygon mesh, with depth in the Y direction.
  131166. * * 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)
  131167. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131168. * @param name defines the name of the mesh
  131169. * @param options defines the options used to create the mesh
  131170. * @param scene defines the hosting scene
  131171. * @param earcutInjection can be used to inject your own earcut reference
  131172. * @returns the polygon mesh
  131173. */
  131174. static ExtrudePolygon(name: string, options: {
  131175. shape: Vector3[];
  131176. holes?: Vector3[][];
  131177. depth?: number;
  131178. faceUV?: Vector4[];
  131179. faceColors?: Color4[];
  131180. updatable?: boolean;
  131181. sideOrientation?: number;
  131182. frontUVs?: Vector4;
  131183. backUVs?: Vector4;
  131184. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  131185. }
  131186. }
  131187. declare module BABYLON {
  131188. /**
  131189. * Class containing static functions to help procedurally build meshes
  131190. */
  131191. export class LatheBuilder {
  131192. /**
  131193. * Creates lathe mesh.
  131194. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  131195. * * 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
  131196. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  131197. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  131198. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  131199. * * 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
  131200. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  131201. * * 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
  131202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131204. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131206. * @param name defines the name of the mesh
  131207. * @param options defines the options used to create the mesh
  131208. * @param scene defines the hosting scene
  131209. * @returns the lathe mesh
  131210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  131211. */
  131212. static CreateLathe(name: string, options: {
  131213. shape: Vector3[];
  131214. radius?: number;
  131215. tessellation?: number;
  131216. clip?: number;
  131217. arc?: number;
  131218. closed?: boolean;
  131219. updatable?: boolean;
  131220. sideOrientation?: number;
  131221. frontUVs?: Vector4;
  131222. backUVs?: Vector4;
  131223. cap?: number;
  131224. invertUV?: boolean;
  131225. }, scene?: Nullable<Scene>): Mesh;
  131226. }
  131227. }
  131228. declare module BABYLON {
  131229. /**
  131230. * Class containing static functions to help procedurally build meshes
  131231. */
  131232. export class TiledPlaneBuilder {
  131233. /**
  131234. * Creates a tiled plane mesh
  131235. * * The parameter `pattern` will, depending on value, do nothing or
  131236. * * * flip (reflect about central vertical) alternate tiles across and up
  131237. * * * flip every tile on alternate rows
  131238. * * * rotate (180 degs) alternate tiles across and up
  131239. * * * rotate every tile on alternate rows
  131240. * * * flip and rotate alternate tiles across and up
  131241. * * * flip and rotate every tile on alternate rows
  131242. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  131243. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  131244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  131246. * * 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)
  131247. * * 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)
  131248. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131249. * @param name defines the name of the mesh
  131250. * @param options defines the options used to create the mesh
  131251. * @param scene defines the hosting scene
  131252. * @returns the box mesh
  131253. */
  131254. static CreateTiledPlane(name: string, options: {
  131255. pattern?: number;
  131256. tileSize?: number;
  131257. tileWidth?: number;
  131258. tileHeight?: number;
  131259. size?: number;
  131260. width?: number;
  131261. height?: number;
  131262. alignHorizontal?: number;
  131263. alignVertical?: number;
  131264. sideOrientation?: number;
  131265. frontUVs?: Vector4;
  131266. backUVs?: Vector4;
  131267. updatable?: boolean;
  131268. }, scene?: Nullable<Scene>): Mesh;
  131269. }
  131270. }
  131271. declare module BABYLON {
  131272. /**
  131273. * Class containing static functions to help procedurally build meshes
  131274. */
  131275. export class TubeBuilder {
  131276. /**
  131277. * Creates a tube mesh.
  131278. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131279. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  131280. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  131281. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  131282. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  131283. * * 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)
  131284. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  131285. * * 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
  131286. * * 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
  131287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131289. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131291. * @param name defines the name of the mesh
  131292. * @param options defines the options used to create the mesh
  131293. * @param scene defines the hosting scene
  131294. * @returns the tube mesh
  131295. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131296. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  131297. */
  131298. static CreateTube(name: string, options: {
  131299. path: Vector3[];
  131300. radius?: number;
  131301. tessellation?: number;
  131302. radiusFunction?: {
  131303. (i: number, distance: number): number;
  131304. };
  131305. cap?: number;
  131306. arc?: number;
  131307. updatable?: boolean;
  131308. sideOrientation?: number;
  131309. frontUVs?: Vector4;
  131310. backUVs?: Vector4;
  131311. instance?: Mesh;
  131312. invertUV?: boolean;
  131313. }, scene?: Nullable<Scene>): Mesh;
  131314. }
  131315. }
  131316. declare module BABYLON {
  131317. /**
  131318. * Class containing static functions to help procedurally build meshes
  131319. */
  131320. export class IcoSphereBuilder {
  131321. /**
  131322. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  131323. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  131324. * * 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`)
  131325. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  131326. * * 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
  131327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131330. * @param name defines the name of the mesh
  131331. * @param options defines the options used to create the mesh
  131332. * @param scene defines the hosting scene
  131333. * @returns the icosahedron mesh
  131334. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  131335. */
  131336. static CreateIcoSphere(name: string, options: {
  131337. radius?: number;
  131338. radiusX?: number;
  131339. radiusY?: number;
  131340. radiusZ?: number;
  131341. flat?: boolean;
  131342. subdivisions?: number;
  131343. sideOrientation?: number;
  131344. frontUVs?: Vector4;
  131345. backUVs?: Vector4;
  131346. updatable?: boolean;
  131347. }, scene?: Nullable<Scene>): Mesh;
  131348. }
  131349. }
  131350. declare module BABYLON {
  131351. /**
  131352. * Class containing static functions to help procedurally build meshes
  131353. */
  131354. export class DecalBuilder {
  131355. /**
  131356. * Creates a decal mesh.
  131357. * 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
  131358. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  131359. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  131360. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  131361. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  131362. * @param name defines the name of the mesh
  131363. * @param sourceMesh defines the mesh where the decal must be applied
  131364. * @param options defines the options used to create the mesh
  131365. * @param scene defines the hosting scene
  131366. * @returns the decal mesh
  131367. * @see https://doc.babylonjs.com/how_to/decals
  131368. */
  131369. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  131370. position?: Vector3;
  131371. normal?: Vector3;
  131372. size?: Vector3;
  131373. angle?: number;
  131374. }): Mesh;
  131375. }
  131376. }
  131377. declare module BABYLON {
  131378. /**
  131379. * Class containing static functions to help procedurally build meshes
  131380. */
  131381. export class MeshBuilder {
  131382. /**
  131383. * Creates a box mesh
  131384. * * The parameter `size` sets the size (float) of each box side (default 1)
  131385. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131386. * * 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)
  131387. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131391. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131392. * @param name defines the name of the mesh
  131393. * @param options defines the options used to create the mesh
  131394. * @param scene defines the hosting scene
  131395. * @returns the box mesh
  131396. */
  131397. static CreateBox(name: string, options: {
  131398. size?: number;
  131399. width?: number;
  131400. height?: number;
  131401. depth?: number;
  131402. faceUV?: Vector4[];
  131403. faceColors?: Color4[];
  131404. sideOrientation?: number;
  131405. frontUVs?: Vector4;
  131406. backUVs?: Vector4;
  131407. updatable?: boolean;
  131408. }, scene?: Nullable<Scene>): Mesh;
  131409. /**
  131410. * Creates a tiled box mesh
  131411. * * faceTiles sets the pattern, tile size and number of tiles for a face
  131412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131413. * @param name defines the name of the mesh
  131414. * @param options defines the options used to create the mesh
  131415. * @param scene defines the hosting scene
  131416. * @returns the tiled box mesh
  131417. */
  131418. static CreateTiledBox(name: string, options: {
  131419. pattern?: number;
  131420. size?: number;
  131421. width?: number;
  131422. height?: number;
  131423. depth: number;
  131424. tileSize?: number;
  131425. tileWidth?: number;
  131426. tileHeight?: number;
  131427. faceUV?: Vector4[];
  131428. faceColors?: Color4[];
  131429. alignHorizontal?: number;
  131430. alignVertical?: number;
  131431. sideOrientation?: number;
  131432. updatable?: boolean;
  131433. }, scene?: Nullable<Scene>): Mesh;
  131434. /**
  131435. * Creates a sphere mesh
  131436. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  131437. * * 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`)
  131438. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  131439. * * 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
  131440. * * 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)
  131441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131444. * @param name defines the name of the mesh
  131445. * @param options defines the options used to create the mesh
  131446. * @param scene defines the hosting scene
  131447. * @returns the sphere mesh
  131448. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  131449. */
  131450. static CreateSphere(name: string, options: {
  131451. segments?: number;
  131452. diameter?: number;
  131453. diameterX?: number;
  131454. diameterY?: number;
  131455. diameterZ?: number;
  131456. arc?: number;
  131457. slice?: number;
  131458. sideOrientation?: number;
  131459. frontUVs?: Vector4;
  131460. backUVs?: Vector4;
  131461. updatable?: boolean;
  131462. }, scene?: Nullable<Scene>): Mesh;
  131463. /**
  131464. * Creates a plane polygonal mesh. By default, this is a disc
  131465. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  131466. * * 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
  131467. * * 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
  131468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131471. * @param name defines the name of the mesh
  131472. * @param options defines the options used to create the mesh
  131473. * @param scene defines the hosting scene
  131474. * @returns the plane polygonal mesh
  131475. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  131476. */
  131477. static CreateDisc(name: string, options: {
  131478. radius?: number;
  131479. tessellation?: number;
  131480. arc?: number;
  131481. updatable?: boolean;
  131482. sideOrientation?: number;
  131483. frontUVs?: Vector4;
  131484. backUVs?: Vector4;
  131485. }, scene?: Nullable<Scene>): Mesh;
  131486. /**
  131487. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  131488. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  131489. * * 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`)
  131490. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  131491. * * 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
  131492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131495. * @param name defines the name of the mesh
  131496. * @param options defines the options used to create the mesh
  131497. * @param scene defines the hosting scene
  131498. * @returns the icosahedron mesh
  131499. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  131500. */
  131501. static CreateIcoSphere(name: string, options: {
  131502. radius?: number;
  131503. radiusX?: number;
  131504. radiusY?: number;
  131505. radiusZ?: number;
  131506. flat?: boolean;
  131507. subdivisions?: number;
  131508. sideOrientation?: number;
  131509. frontUVs?: Vector4;
  131510. backUVs?: Vector4;
  131511. updatable?: boolean;
  131512. }, scene?: Nullable<Scene>): Mesh;
  131513. /**
  131514. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131515. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131516. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131517. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131518. * * 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
  131519. * * 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
  131520. * * 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
  131521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131523. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131524. * * 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
  131525. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131526. * * 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
  131527. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131529. * @param name defines the name of the mesh
  131530. * @param options defines the options used to create the mesh
  131531. * @param scene defines the hosting scene
  131532. * @returns the ribbon mesh
  131533. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131534. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131535. */
  131536. static CreateRibbon(name: string, options: {
  131537. pathArray: Vector3[][];
  131538. closeArray?: boolean;
  131539. closePath?: boolean;
  131540. offset?: number;
  131541. updatable?: boolean;
  131542. sideOrientation?: number;
  131543. frontUVs?: Vector4;
  131544. backUVs?: Vector4;
  131545. instance?: Mesh;
  131546. invertUV?: boolean;
  131547. uvs?: Vector2[];
  131548. colors?: Color4[];
  131549. }, scene?: Nullable<Scene>): Mesh;
  131550. /**
  131551. * Creates a cylinder or a cone mesh
  131552. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  131553. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  131554. * * 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.
  131555. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  131556. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  131557. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  131558. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  131559. * * 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).
  131560. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  131561. * * 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).
  131562. * * 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
  131563. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  131564. * * 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
  131565. * * 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.
  131566. * * If `enclose` is false, a ring surface is one element.
  131567. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  131568. * * 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
  131569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131572. * @param name defines the name of the mesh
  131573. * @param options defines the options used to create the mesh
  131574. * @param scene defines the hosting scene
  131575. * @returns the cylinder mesh
  131576. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  131577. */
  131578. static CreateCylinder(name: string, options: {
  131579. height?: number;
  131580. diameterTop?: number;
  131581. diameterBottom?: number;
  131582. diameter?: number;
  131583. tessellation?: number;
  131584. subdivisions?: number;
  131585. arc?: number;
  131586. faceColors?: Color4[];
  131587. faceUV?: Vector4[];
  131588. updatable?: boolean;
  131589. hasRings?: boolean;
  131590. enclose?: boolean;
  131591. cap?: number;
  131592. sideOrientation?: number;
  131593. frontUVs?: Vector4;
  131594. backUVs?: Vector4;
  131595. }, scene?: Nullable<Scene>): Mesh;
  131596. /**
  131597. * Creates a torus mesh
  131598. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  131599. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  131600. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  131601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131604. * @param name defines the name of the mesh
  131605. * @param options defines the options used to create the mesh
  131606. * @param scene defines the hosting scene
  131607. * @returns the torus mesh
  131608. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  131609. */
  131610. static CreateTorus(name: string, options: {
  131611. diameter?: number;
  131612. thickness?: number;
  131613. tessellation?: number;
  131614. updatable?: boolean;
  131615. sideOrientation?: number;
  131616. frontUVs?: Vector4;
  131617. backUVs?: Vector4;
  131618. }, scene?: Nullable<Scene>): Mesh;
  131619. /**
  131620. * Creates a torus knot mesh
  131621. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  131622. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  131623. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  131624. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  131625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131626. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131628. * @param name defines the name of the mesh
  131629. * @param options defines the options used to create the mesh
  131630. * @param scene defines the hosting scene
  131631. * @returns the torus knot mesh
  131632. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  131633. */
  131634. static CreateTorusKnot(name: string, options: {
  131635. radius?: number;
  131636. tube?: number;
  131637. radialSegments?: number;
  131638. tubularSegments?: number;
  131639. p?: number;
  131640. q?: number;
  131641. updatable?: boolean;
  131642. sideOrientation?: number;
  131643. frontUVs?: Vector4;
  131644. backUVs?: Vector4;
  131645. }, scene?: Nullable<Scene>): Mesh;
  131646. /**
  131647. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  131648. * * 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
  131649. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  131650. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  131651. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  131652. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  131653. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  131654. * * 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
  131655. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  131656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  131658. * @param name defines the name of the new line system
  131659. * @param options defines the options used to create the line system
  131660. * @param scene defines the hosting scene
  131661. * @returns a new line system mesh
  131662. */
  131663. static CreateLineSystem(name: string, options: {
  131664. lines: Vector3[][];
  131665. updatable?: boolean;
  131666. instance?: Nullable<LinesMesh>;
  131667. colors?: Nullable<Color4[][]>;
  131668. useVertexAlpha?: boolean;
  131669. }, scene: Nullable<Scene>): LinesMesh;
  131670. /**
  131671. * Creates a line mesh
  131672. * 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
  131673. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  131674. * * The parameter `points` is an array successive Vector3
  131675. * * 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
  131676. * * The optional parameter `colors` is an array of successive Color4, one per line point
  131677. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  131678. * * When updating an instance, remember that only point positions can change, not the number of points
  131679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131680. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  131681. * @param name defines the name of the new line system
  131682. * @param options defines the options used to create the line system
  131683. * @param scene defines the hosting scene
  131684. * @returns a new line mesh
  131685. */
  131686. static CreateLines(name: string, options: {
  131687. points: Vector3[];
  131688. updatable?: boolean;
  131689. instance?: Nullable<LinesMesh>;
  131690. colors?: Color4[];
  131691. useVertexAlpha?: boolean;
  131692. }, scene?: Nullable<Scene>): LinesMesh;
  131693. /**
  131694. * Creates a dashed line mesh
  131695. * * 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
  131696. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  131697. * * The parameter `points` is an array successive Vector3
  131698. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  131699. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  131700. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  131701. * * 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
  131702. * * When updating an instance, remember that only point positions can change, not the number of points
  131703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131704. * @param name defines the name of the mesh
  131705. * @param options defines the options used to create the mesh
  131706. * @param scene defines the hosting scene
  131707. * @returns the dashed line mesh
  131708. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  131709. */
  131710. static CreateDashedLines(name: string, options: {
  131711. points: Vector3[];
  131712. dashSize?: number;
  131713. gapSize?: number;
  131714. dashNb?: number;
  131715. updatable?: boolean;
  131716. instance?: LinesMesh;
  131717. }, scene?: Nullable<Scene>): LinesMesh;
  131718. /**
  131719. * 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.
  131720. * * 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.
  131721. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131722. * * 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.
  131723. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131724. * * 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
  131725. * * 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
  131726. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131729. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131731. * @param name defines the name of the mesh
  131732. * @param options defines the options used to create the mesh
  131733. * @param scene defines the hosting scene
  131734. * @returns the extruded shape mesh
  131735. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131736. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131737. */
  131738. static ExtrudeShape(name: string, options: {
  131739. shape: Vector3[];
  131740. path: Vector3[];
  131741. scale?: number;
  131742. rotation?: number;
  131743. cap?: number;
  131744. updatable?: boolean;
  131745. sideOrientation?: number;
  131746. frontUVs?: Vector4;
  131747. backUVs?: Vector4;
  131748. instance?: Mesh;
  131749. invertUV?: boolean;
  131750. }, scene?: Nullable<Scene>): Mesh;
  131751. /**
  131752. * Creates an custom extruded shape mesh.
  131753. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131754. * * 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.
  131755. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131756. * * 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
  131757. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131758. * * 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
  131759. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131760. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131761. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131762. * * 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
  131763. * * 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
  131764. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131767. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131769. * @param name defines the name of the mesh
  131770. * @param options defines the options used to create the mesh
  131771. * @param scene defines the hosting scene
  131772. * @returns the custom extruded shape mesh
  131773. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131774. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131776. */
  131777. static ExtrudeShapeCustom(name: string, options: {
  131778. shape: Vector3[];
  131779. path: Vector3[];
  131780. scaleFunction?: any;
  131781. rotationFunction?: any;
  131782. ribbonCloseArray?: boolean;
  131783. ribbonClosePath?: boolean;
  131784. cap?: number;
  131785. updatable?: boolean;
  131786. sideOrientation?: number;
  131787. frontUVs?: Vector4;
  131788. backUVs?: Vector4;
  131789. instance?: Mesh;
  131790. invertUV?: boolean;
  131791. }, scene?: Nullable<Scene>): Mesh;
  131792. /**
  131793. * Creates lathe mesh.
  131794. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  131795. * * 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
  131796. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  131797. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  131798. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  131799. * * 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
  131800. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  131801. * * 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
  131802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131804. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131806. * @param name defines the name of the mesh
  131807. * @param options defines the options used to create the mesh
  131808. * @param scene defines the hosting scene
  131809. * @returns the lathe mesh
  131810. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  131811. */
  131812. static CreateLathe(name: string, options: {
  131813. shape: Vector3[];
  131814. radius?: number;
  131815. tessellation?: number;
  131816. clip?: number;
  131817. arc?: number;
  131818. closed?: boolean;
  131819. updatable?: boolean;
  131820. sideOrientation?: number;
  131821. frontUVs?: Vector4;
  131822. backUVs?: Vector4;
  131823. cap?: number;
  131824. invertUV?: boolean;
  131825. }, scene?: Nullable<Scene>): Mesh;
  131826. /**
  131827. * Creates a tiled plane mesh
  131828. * * You can set a limited pattern arrangement with the tiles
  131829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 plane mesh
  131836. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  131837. */
  131838. static CreateTiledPlane(name: string, options: {
  131839. pattern?: number;
  131840. tileSize?: number;
  131841. tileWidth?: number;
  131842. tileHeight?: number;
  131843. size?: number;
  131844. width?: number;
  131845. height?: number;
  131846. alignHorizontal?: number;
  131847. alignVertical?: number;
  131848. sideOrientation?: number;
  131849. frontUVs?: Vector4;
  131850. backUVs?: Vector4;
  131851. updatable?: boolean;
  131852. }, scene?: Nullable<Scene>): Mesh;
  131853. /**
  131854. * Creates a plane mesh
  131855. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  131856. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  131857. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  131858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131859. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131861. * @param name defines the name of the mesh
  131862. * @param options defines the options used to create the mesh
  131863. * @param scene defines the hosting scene
  131864. * @returns the plane mesh
  131865. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  131866. */
  131867. static CreatePlane(name: string, options: {
  131868. size?: number;
  131869. width?: number;
  131870. height?: number;
  131871. sideOrientation?: number;
  131872. frontUVs?: Vector4;
  131873. backUVs?: Vector4;
  131874. updatable?: boolean;
  131875. sourcePlane?: Plane;
  131876. }, scene?: Nullable<Scene>): Mesh;
  131877. /**
  131878. * Creates a ground mesh
  131879. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  131880. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  131881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131882. * @param name defines the name of the mesh
  131883. * @param options defines the options used to create the mesh
  131884. * @param scene defines the hosting scene
  131885. * @returns the ground mesh
  131886. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  131887. */
  131888. static CreateGround(name: string, options: {
  131889. width?: number;
  131890. height?: number;
  131891. subdivisions?: number;
  131892. subdivisionsX?: number;
  131893. subdivisionsY?: number;
  131894. updatable?: boolean;
  131895. }, scene?: Nullable<Scene>): Mesh;
  131896. /**
  131897. * Creates a tiled ground mesh
  131898. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  131899. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  131900. * * 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
  131901. * * 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
  131902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131903. * @param name defines the name of the mesh
  131904. * @param options defines the options used to create the mesh
  131905. * @param scene defines the hosting scene
  131906. * @returns the tiled ground mesh
  131907. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  131908. */
  131909. static CreateTiledGround(name: string, options: {
  131910. xmin: number;
  131911. zmin: number;
  131912. xmax: number;
  131913. zmax: number;
  131914. subdivisions?: {
  131915. w: number;
  131916. h: number;
  131917. };
  131918. precision?: {
  131919. w: number;
  131920. h: number;
  131921. };
  131922. updatable?: boolean;
  131923. }, scene?: Nullable<Scene>): Mesh;
  131924. /**
  131925. * Creates a ground mesh from a height map
  131926. * * The parameter `url` sets the URL of the height map image resource.
  131927. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  131928. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  131929. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  131930. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  131931. * * 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.
  131932. * * 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).
  131933. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  131934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131935. * @param name defines the name of the mesh
  131936. * @param url defines the url to the height map
  131937. * @param options defines the options used to create the mesh
  131938. * @param scene defines the hosting scene
  131939. * @returns the ground mesh
  131940. * @see https://doc.babylonjs.com/babylon101/height_map
  131941. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  131942. */
  131943. static CreateGroundFromHeightMap(name: string, url: string, options: {
  131944. width?: number;
  131945. height?: number;
  131946. subdivisions?: number;
  131947. minHeight?: number;
  131948. maxHeight?: number;
  131949. colorFilter?: Color3;
  131950. alphaFilter?: number;
  131951. updatable?: boolean;
  131952. onReady?: (mesh: GroundMesh) => void;
  131953. }, scene?: Nullable<Scene>): GroundMesh;
  131954. /**
  131955. * Creates a polygon mesh
  131956. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  131957. * * 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
  131958. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  131959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  131961. * * Remember you can only change the shape positions, not their number when updating a polygon
  131962. * @param name defines the name of the mesh
  131963. * @param options defines the options used to create the mesh
  131964. * @param scene defines the hosting scene
  131965. * @param earcutInjection can be used to inject your own earcut reference
  131966. * @returns the polygon mesh
  131967. */
  131968. static CreatePolygon(name: string, options: {
  131969. shape: Vector3[];
  131970. holes?: Vector3[][];
  131971. depth?: number;
  131972. faceUV?: Vector4[];
  131973. faceColors?: Color4[];
  131974. updatable?: boolean;
  131975. sideOrientation?: number;
  131976. frontUVs?: Vector4;
  131977. backUVs?: Vector4;
  131978. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  131979. /**
  131980. * Creates an extruded polygon mesh, with depth in the Y direction.
  131981. * * 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)
  131982. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131983. * @param name defines the name of the mesh
  131984. * @param options defines the options used to create the mesh
  131985. * @param scene defines the hosting scene
  131986. * @param earcutInjection can be used to inject your own earcut reference
  131987. * @returns the polygon mesh
  131988. */
  131989. static ExtrudePolygon(name: string, options: {
  131990. shape: Vector3[];
  131991. holes?: Vector3[][];
  131992. depth?: number;
  131993. faceUV?: Vector4[];
  131994. faceColors?: Color4[];
  131995. updatable?: boolean;
  131996. sideOrientation?: number;
  131997. frontUVs?: Vector4;
  131998. backUVs?: Vector4;
  131999. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  132000. /**
  132001. * Creates a tube mesh.
  132002. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  132003. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  132004. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  132005. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  132006. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  132007. * * 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)
  132008. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  132009. * * 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
  132010. * * 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
  132011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132013. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  132014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132015. * @param name defines the name of the mesh
  132016. * @param options defines the options used to create the mesh
  132017. * @param scene defines the hosting scene
  132018. * @returns the tube mesh
  132019. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  132020. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  132021. */
  132022. static CreateTube(name: string, options: {
  132023. path: Vector3[];
  132024. radius?: number;
  132025. tessellation?: number;
  132026. radiusFunction?: {
  132027. (i: number, distance: number): number;
  132028. };
  132029. cap?: number;
  132030. arc?: number;
  132031. updatable?: boolean;
  132032. sideOrientation?: number;
  132033. frontUVs?: Vector4;
  132034. backUVs?: Vector4;
  132035. instance?: Mesh;
  132036. invertUV?: boolean;
  132037. }, scene?: Nullable<Scene>): Mesh;
  132038. /**
  132039. * Creates a polyhedron mesh
  132040. * * 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
  132041. * * The parameter `size` (positive float, default 1) sets the polygon size
  132042. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  132043. * * 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`
  132044. * * 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
  132045. * * 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)`)
  132046. * * 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
  132047. * * 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
  132048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132049. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132051. * @param name defines the name of the mesh
  132052. * @param options defines the options used to create the mesh
  132053. * @param scene defines the hosting scene
  132054. * @returns the polyhedron mesh
  132055. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  132056. */
  132057. static CreatePolyhedron(name: string, options: {
  132058. type?: number;
  132059. size?: number;
  132060. sizeX?: number;
  132061. sizeY?: number;
  132062. sizeZ?: number;
  132063. custom?: any;
  132064. faceUV?: Vector4[];
  132065. faceColors?: Color4[];
  132066. flat?: boolean;
  132067. updatable?: boolean;
  132068. sideOrientation?: number;
  132069. frontUVs?: Vector4;
  132070. backUVs?: Vector4;
  132071. }, scene?: Nullable<Scene>): Mesh;
  132072. /**
  132073. * Creates a decal mesh.
  132074. * 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
  132075. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  132076. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  132077. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  132078. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  132079. * @param name defines the name of the mesh
  132080. * @param sourceMesh defines the mesh where the decal must be applied
  132081. * @param options defines the options used to create the mesh
  132082. * @param scene defines the hosting scene
  132083. * @returns the decal mesh
  132084. * @see https://doc.babylonjs.com/how_to/decals
  132085. */
  132086. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  132087. position?: Vector3;
  132088. normal?: Vector3;
  132089. size?: Vector3;
  132090. angle?: number;
  132091. }): Mesh;
  132092. }
  132093. }
  132094. declare module BABYLON {
  132095. /**
  132096. * A simplifier interface for future simplification implementations
  132097. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132098. */
  132099. export interface ISimplifier {
  132100. /**
  132101. * Simplification of a given mesh according to the given settings.
  132102. * Since this requires computation, it is assumed that the function runs async.
  132103. * @param settings The settings of the simplification, including quality and distance
  132104. * @param successCallback A callback that will be called after the mesh was simplified.
  132105. * @param errorCallback in case of an error, this callback will be called. optional.
  132106. */
  132107. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  132108. }
  132109. /**
  132110. * Expected simplification settings.
  132111. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  132112. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132113. */
  132114. export interface ISimplificationSettings {
  132115. /**
  132116. * Gets or sets the expected quality
  132117. */
  132118. quality: number;
  132119. /**
  132120. * Gets or sets the distance when this optimized version should be used
  132121. */
  132122. distance: number;
  132123. /**
  132124. * Gets an already optimized mesh
  132125. */
  132126. optimizeMesh?: boolean;
  132127. }
  132128. /**
  132129. * Class used to specify simplification options
  132130. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132131. */
  132132. export class SimplificationSettings implements ISimplificationSettings {
  132133. /** expected quality */
  132134. quality: number;
  132135. /** distance when this optimized version should be used */
  132136. distance: number;
  132137. /** already optimized mesh */
  132138. optimizeMesh?: boolean | undefined;
  132139. /**
  132140. * Creates a SimplificationSettings
  132141. * @param quality expected quality
  132142. * @param distance distance when this optimized version should be used
  132143. * @param optimizeMesh already optimized mesh
  132144. */
  132145. constructor(
  132146. /** expected quality */
  132147. quality: number,
  132148. /** distance when this optimized version should be used */
  132149. distance: number,
  132150. /** already optimized mesh */
  132151. optimizeMesh?: boolean | undefined);
  132152. }
  132153. /**
  132154. * Interface used to define a simplification task
  132155. */
  132156. export interface ISimplificationTask {
  132157. /**
  132158. * Array of settings
  132159. */
  132160. settings: Array<ISimplificationSettings>;
  132161. /**
  132162. * Simplification type
  132163. */
  132164. simplificationType: SimplificationType;
  132165. /**
  132166. * Mesh to simplify
  132167. */
  132168. mesh: Mesh;
  132169. /**
  132170. * Callback called on success
  132171. */
  132172. successCallback?: () => void;
  132173. /**
  132174. * Defines if parallel processing can be used
  132175. */
  132176. parallelProcessing: boolean;
  132177. }
  132178. /**
  132179. * Queue used to order the simplification tasks
  132180. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132181. */
  132182. export class SimplificationQueue {
  132183. private _simplificationArray;
  132184. /**
  132185. * Gets a boolean indicating that the process is still running
  132186. */
  132187. running: boolean;
  132188. /**
  132189. * Creates a new queue
  132190. */
  132191. constructor();
  132192. /**
  132193. * Adds a new simplification task
  132194. * @param task defines a task to add
  132195. */
  132196. addTask(task: ISimplificationTask): void;
  132197. /**
  132198. * Execute next task
  132199. */
  132200. executeNext(): void;
  132201. /**
  132202. * Execute a simplification task
  132203. * @param task defines the task to run
  132204. */
  132205. runSimplification(task: ISimplificationTask): void;
  132206. private getSimplifier;
  132207. }
  132208. /**
  132209. * The implemented types of simplification
  132210. * At the moment only Quadratic Error Decimation is implemented
  132211. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132212. */
  132213. export enum SimplificationType {
  132214. /** Quadratic error decimation */
  132215. QUADRATIC = 0
  132216. }
  132217. }
  132218. declare module BABYLON {
  132219. interface Scene {
  132220. /** @hidden (Backing field) */
  132221. _simplificationQueue: SimplificationQueue;
  132222. /**
  132223. * Gets or sets the simplification queue attached to the scene
  132224. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132225. */
  132226. simplificationQueue: SimplificationQueue;
  132227. }
  132228. interface Mesh {
  132229. /**
  132230. * Simplify the mesh according to the given array of settings.
  132231. * Function will return immediately and will simplify async
  132232. * @param settings a collection of simplification settings
  132233. * @param parallelProcessing should all levels calculate parallel or one after the other
  132234. * @param simplificationType the type of simplification to run
  132235. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  132236. * @returns the current mesh
  132237. */
  132238. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  132239. }
  132240. /**
  132241. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  132242. * created in a scene
  132243. */
  132244. export class SimplicationQueueSceneComponent implements ISceneComponent {
  132245. /**
  132246. * The component name helpfull to identify the component in the list of scene components.
  132247. */
  132248. readonly name: string;
  132249. /**
  132250. * The scene the component belongs to.
  132251. */
  132252. scene: Scene;
  132253. /**
  132254. * Creates a new instance of the component for the given scene
  132255. * @param scene Defines the scene to register the component in
  132256. */
  132257. constructor(scene: Scene);
  132258. /**
  132259. * Registers the component in a given scene
  132260. */
  132261. register(): void;
  132262. /**
  132263. * Rebuilds the elements related to this component in case of
  132264. * context lost for instance.
  132265. */
  132266. rebuild(): void;
  132267. /**
  132268. * Disposes the component and the associated ressources
  132269. */
  132270. dispose(): void;
  132271. private _beforeCameraUpdate;
  132272. }
  132273. }
  132274. declare module BABYLON {
  132275. /**
  132276. * Navigation plugin interface to add navigation constrained by a navigation mesh
  132277. */
  132278. export interface INavigationEnginePlugin {
  132279. /**
  132280. * plugin name
  132281. */
  132282. name: string;
  132283. /**
  132284. * Creates a navigation mesh
  132285. * @param meshes array of all the geometry used to compute the navigatio mesh
  132286. * @param parameters bunch of parameters used to filter geometry
  132287. */
  132288. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  132289. /**
  132290. * Create a navigation mesh debug mesh
  132291. * @param scene is where the mesh will be added
  132292. * @returns debug display mesh
  132293. */
  132294. createDebugNavMesh(scene: Scene): Mesh;
  132295. /**
  132296. * Get a navigation mesh constrained position, closest to the parameter position
  132297. * @param position world position
  132298. * @returns the closest point to position constrained by the navigation mesh
  132299. */
  132300. getClosestPoint(position: Vector3): Vector3;
  132301. /**
  132302. * Get a navigation mesh constrained position, within a particular radius
  132303. * @param position world position
  132304. * @param maxRadius the maximum distance to the constrained world position
  132305. * @returns the closest point to position constrained by the navigation mesh
  132306. */
  132307. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  132308. /**
  132309. * Compute the final position from a segment made of destination-position
  132310. * @param position world position
  132311. * @param destination world position
  132312. * @returns the resulting point along the navmesh
  132313. */
  132314. moveAlong(position: Vector3, destination: Vector3): Vector3;
  132315. /**
  132316. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  132317. * @param start world position
  132318. * @param end world position
  132319. * @returns array containing world position composing the path
  132320. */
  132321. computePath(start: Vector3, end: Vector3): Vector3[];
  132322. /**
  132323. * If this plugin is supported
  132324. * @returns true if plugin is supported
  132325. */
  132326. isSupported(): boolean;
  132327. /**
  132328. * Create a new Crowd so you can add agents
  132329. * @param maxAgents the maximum agent count in the crowd
  132330. * @param maxAgentRadius the maximum radius an agent can have
  132331. * @param scene to attach the crowd to
  132332. * @returns the crowd you can add agents to
  132333. */
  132334. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  132335. /**
  132336. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  132337. * The queries will try to find a solution within those bounds
  132338. * default is (1,1,1)
  132339. * @param extent x,y,z value that define the extent around the queries point of reference
  132340. */
  132341. setDefaultQueryExtent(extent: Vector3): void;
  132342. /**
  132343. * Get the Bounding box extent specified by setDefaultQueryExtent
  132344. * @returns the box extent values
  132345. */
  132346. getDefaultQueryExtent(): Vector3;
  132347. /**
  132348. * Release all resources
  132349. */
  132350. dispose(): void;
  132351. }
  132352. /**
  132353. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  132354. */
  132355. export interface ICrowd {
  132356. /**
  132357. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  132358. * You can attach anything to that node. The node position is updated in the scene update tick.
  132359. * @param pos world position that will be constrained by the navigation mesh
  132360. * @param parameters agent parameters
  132361. * @param transform hooked to the agent that will be update by the scene
  132362. * @returns agent index
  132363. */
  132364. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  132365. /**
  132366. * Returns the agent position in world space
  132367. * @param index agent index returned by addAgent
  132368. * @returns world space position
  132369. */
  132370. getAgentPosition(index: number): Vector3;
  132371. /**
  132372. * Gets the agent velocity in world space
  132373. * @param index agent index returned by addAgent
  132374. * @returns world space velocity
  132375. */
  132376. getAgentVelocity(index: number): Vector3;
  132377. /**
  132378. * remove a particular agent previously created
  132379. * @param index agent index returned by addAgent
  132380. */
  132381. removeAgent(index: number): void;
  132382. /**
  132383. * get the list of all agents attached to this crowd
  132384. * @returns list of agent indices
  132385. */
  132386. getAgents(): number[];
  132387. /**
  132388. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  132389. * @param deltaTime in seconds
  132390. */
  132391. update(deltaTime: number): void;
  132392. /**
  132393. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  132394. * @param index agent index returned by addAgent
  132395. * @param destination targeted world position
  132396. */
  132397. agentGoto(index: number, destination: Vector3): void;
  132398. /**
  132399. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  132400. * The queries will try to find a solution within those bounds
  132401. * default is (1,1,1)
  132402. * @param extent x,y,z value that define the extent around the queries point of reference
  132403. */
  132404. setDefaultQueryExtent(extent: Vector3): void;
  132405. /**
  132406. * Get the Bounding box extent specified by setDefaultQueryExtent
  132407. * @returns the box extent values
  132408. */
  132409. getDefaultQueryExtent(): Vector3;
  132410. /**
  132411. * Release all resources
  132412. */
  132413. dispose(): void;
  132414. }
  132415. /**
  132416. * Configures an agent
  132417. */
  132418. export interface IAgentParameters {
  132419. /**
  132420. * Agent radius. [Limit: >= 0]
  132421. */
  132422. radius: number;
  132423. /**
  132424. * Agent height. [Limit: > 0]
  132425. */
  132426. height: number;
  132427. /**
  132428. * Maximum allowed acceleration. [Limit: >= 0]
  132429. */
  132430. maxAcceleration: number;
  132431. /**
  132432. * Maximum allowed speed. [Limit: >= 0]
  132433. */
  132434. maxSpeed: number;
  132435. /**
  132436. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  132437. */
  132438. collisionQueryRange: number;
  132439. /**
  132440. * The path visibility optimization range. [Limit: > 0]
  132441. */
  132442. pathOptimizationRange: number;
  132443. /**
  132444. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  132445. */
  132446. separationWeight: number;
  132447. }
  132448. /**
  132449. * Configures the navigation mesh creation
  132450. */
  132451. export interface INavMeshParameters {
  132452. /**
  132453. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  132454. */
  132455. cs: number;
  132456. /**
  132457. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  132458. */
  132459. ch: number;
  132460. /**
  132461. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  132462. */
  132463. walkableSlopeAngle: number;
  132464. /**
  132465. * Minimum floor to 'ceiling' height that will still allow the floor area to
  132466. * be considered walkable. [Limit: >= 3] [Units: vx]
  132467. */
  132468. walkableHeight: number;
  132469. /**
  132470. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  132471. */
  132472. walkableClimb: number;
  132473. /**
  132474. * The distance to erode/shrink the walkable area of the heightfield away from
  132475. * obstructions. [Limit: >=0] [Units: vx]
  132476. */
  132477. walkableRadius: number;
  132478. /**
  132479. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  132480. */
  132481. maxEdgeLen: number;
  132482. /**
  132483. * The maximum distance a simplfied contour's border edges should deviate
  132484. * the original raw contour. [Limit: >=0] [Units: vx]
  132485. */
  132486. maxSimplificationError: number;
  132487. /**
  132488. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  132489. */
  132490. minRegionArea: number;
  132491. /**
  132492. * Any regions with a span count smaller than this value will, if possible,
  132493. * be merged with larger regions. [Limit: >=0] [Units: vx]
  132494. */
  132495. mergeRegionArea: number;
  132496. /**
  132497. * The maximum number of vertices allowed for polygons generated during the
  132498. * contour to polygon conversion process. [Limit: >= 3]
  132499. */
  132500. maxVertsPerPoly: number;
  132501. /**
  132502. * Sets the sampling distance to use when generating the detail mesh.
  132503. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  132504. */
  132505. detailSampleDist: number;
  132506. /**
  132507. * The maximum distance the detail mesh surface should deviate from heightfield
  132508. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  132509. */
  132510. detailSampleMaxError: number;
  132511. }
  132512. }
  132513. declare module BABYLON {
  132514. /**
  132515. * RecastJS navigation plugin
  132516. */
  132517. export class RecastJSPlugin implements INavigationEnginePlugin {
  132518. /**
  132519. * Reference to the Recast library
  132520. */
  132521. bjsRECAST: any;
  132522. /**
  132523. * plugin name
  132524. */
  132525. name: string;
  132526. /**
  132527. * the first navmesh created. We might extend this to support multiple navmeshes
  132528. */
  132529. navMesh: any;
  132530. /**
  132531. * Initializes the recastJS plugin
  132532. * @param recastInjection can be used to inject your own recast reference
  132533. */
  132534. constructor(recastInjection?: any);
  132535. /**
  132536. * Creates a navigation mesh
  132537. * @param meshes array of all the geometry used to compute the navigatio mesh
  132538. * @param parameters bunch of parameters used to filter geometry
  132539. */
  132540. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  132541. /**
  132542. * Create a navigation mesh debug mesh
  132543. * @param scene is where the mesh will be added
  132544. * @returns debug display mesh
  132545. */
  132546. createDebugNavMesh(scene: Scene): Mesh;
  132547. /**
  132548. * Get a navigation mesh constrained position, closest to the parameter position
  132549. * @param position world position
  132550. * @returns the closest point to position constrained by the navigation mesh
  132551. */
  132552. getClosestPoint(position: Vector3): Vector3;
  132553. /**
  132554. * Get a navigation mesh constrained position, within a particular radius
  132555. * @param position world position
  132556. * @param maxRadius the maximum distance to the constrained world position
  132557. * @returns the closest point to position constrained by the navigation mesh
  132558. */
  132559. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  132560. /**
  132561. * Compute the final position from a segment made of destination-position
  132562. * @param position world position
  132563. * @param destination world position
  132564. * @returns the resulting point along the navmesh
  132565. */
  132566. moveAlong(position: Vector3, destination: Vector3): Vector3;
  132567. /**
  132568. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  132569. * @param start world position
  132570. * @param end world position
  132571. * @returns array containing world position composing the path
  132572. */
  132573. computePath(start: Vector3, end: Vector3): Vector3[];
  132574. /**
  132575. * Create a new Crowd so you can add agents
  132576. * @param maxAgents the maximum agent count in the crowd
  132577. * @param maxAgentRadius the maximum radius an agent can have
  132578. * @param scene to attach the crowd to
  132579. * @returns the crowd you can add agents to
  132580. */
  132581. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  132582. /**
  132583. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  132584. * The queries will try to find a solution within those bounds
  132585. * default is (1,1,1)
  132586. * @param extent x,y,z value that define the extent around the queries point of reference
  132587. */
  132588. setDefaultQueryExtent(extent: Vector3): void;
  132589. /**
  132590. * Get the Bounding box extent specified by setDefaultQueryExtent
  132591. * @returns the box extent values
  132592. */
  132593. getDefaultQueryExtent(): Vector3;
  132594. /**
  132595. * Disposes
  132596. */
  132597. dispose(): void;
  132598. /**
  132599. * If this plugin is supported
  132600. * @returns true if plugin is supported
  132601. */
  132602. isSupported(): boolean;
  132603. }
  132604. /**
  132605. * Recast detour crowd implementation
  132606. */
  132607. export class RecastJSCrowd implements ICrowd {
  132608. /**
  132609. * Recast/detour plugin
  132610. */
  132611. bjsRECASTPlugin: RecastJSPlugin;
  132612. /**
  132613. * Link to the detour crowd
  132614. */
  132615. recastCrowd: any;
  132616. /**
  132617. * One transform per agent
  132618. */
  132619. transforms: TransformNode[];
  132620. /**
  132621. * All agents created
  132622. */
  132623. agents: number[];
  132624. /**
  132625. * Link to the scene is kept to unregister the crowd from the scene
  132626. */
  132627. private _scene;
  132628. /**
  132629. * Observer for crowd updates
  132630. */
  132631. private _onBeforeAnimationsObserver;
  132632. /**
  132633. * Constructor
  132634. * @param plugin recastJS plugin
  132635. * @param maxAgents the maximum agent count in the crowd
  132636. * @param maxAgentRadius the maximum radius an agent can have
  132637. * @param scene to attach the crowd to
  132638. * @returns the crowd you can add agents to
  132639. */
  132640. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  132641. /**
  132642. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  132643. * You can attach anything to that node. The node position is updated in the scene update tick.
  132644. * @param pos world position that will be constrained by the navigation mesh
  132645. * @param parameters agent parameters
  132646. * @param transform hooked to the agent that will be update by the scene
  132647. * @returns agent index
  132648. */
  132649. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  132650. /**
  132651. * Returns the agent position in world space
  132652. * @param index agent index returned by addAgent
  132653. * @returns world space position
  132654. */
  132655. getAgentPosition(index: number): Vector3;
  132656. /**
  132657. * Returns the agent velocity in world space
  132658. * @param index agent index returned by addAgent
  132659. * @returns world space velocity
  132660. */
  132661. getAgentVelocity(index: number): Vector3;
  132662. /**
  132663. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  132664. * @param index agent index returned by addAgent
  132665. * @param destination targeted world position
  132666. */
  132667. agentGoto(index: number, destination: Vector3): void;
  132668. /**
  132669. * remove a particular agent previously created
  132670. * @param index agent index returned by addAgent
  132671. */
  132672. removeAgent(index: number): void;
  132673. /**
  132674. * get the list of all agents attached to this crowd
  132675. * @returns list of agent indices
  132676. */
  132677. getAgents(): number[];
  132678. /**
  132679. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  132680. * @param deltaTime in seconds
  132681. */
  132682. update(deltaTime: number): void;
  132683. /**
  132684. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  132685. * The queries will try to find a solution within those bounds
  132686. * default is (1,1,1)
  132687. * @param extent x,y,z value that define the extent around the queries point of reference
  132688. */
  132689. setDefaultQueryExtent(extent: Vector3): void;
  132690. /**
  132691. * Get the Bounding box extent specified by setDefaultQueryExtent
  132692. * @returns the box extent values
  132693. */
  132694. getDefaultQueryExtent(): Vector3;
  132695. /**
  132696. * Release all resources
  132697. */
  132698. dispose(): void;
  132699. }
  132700. }
  132701. declare module BABYLON {
  132702. /**
  132703. * Class used to enable access to IndexedDB
  132704. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  132705. */
  132706. export class Database implements IOfflineProvider {
  132707. private _callbackManifestChecked;
  132708. private _currentSceneUrl;
  132709. private _db;
  132710. private _enableSceneOffline;
  132711. private _enableTexturesOffline;
  132712. private _manifestVersionFound;
  132713. private _mustUpdateRessources;
  132714. private _hasReachedQuota;
  132715. private _isSupported;
  132716. private _idbFactory;
  132717. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  132718. private static IsUASupportingBlobStorage;
  132719. /**
  132720. * Gets a boolean indicating if Database storate is enabled (off by default)
  132721. */
  132722. static IDBStorageEnabled: boolean;
  132723. /**
  132724. * Gets a boolean indicating if scene must be saved in the database
  132725. */
  132726. get enableSceneOffline(): boolean;
  132727. /**
  132728. * Gets a boolean indicating if textures must be saved in the database
  132729. */
  132730. get enableTexturesOffline(): boolean;
  132731. /**
  132732. * Creates a new Database
  132733. * @param urlToScene defines the url to load the scene
  132734. * @param callbackManifestChecked defines the callback to use when manifest is checked
  132735. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  132736. */
  132737. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  132738. private static _ParseURL;
  132739. private static _ReturnFullUrlLocation;
  132740. private _checkManifestFile;
  132741. /**
  132742. * Open the database and make it available
  132743. * @param successCallback defines the callback to call on success
  132744. * @param errorCallback defines the callback to call on error
  132745. */
  132746. open(successCallback: () => void, errorCallback: () => void): void;
  132747. /**
  132748. * Loads an image from the database
  132749. * @param url defines the url to load from
  132750. * @param image defines the target DOM image
  132751. */
  132752. loadImage(url: string, image: HTMLImageElement): void;
  132753. private _loadImageFromDBAsync;
  132754. private _saveImageIntoDBAsync;
  132755. private _checkVersionFromDB;
  132756. private _loadVersionFromDBAsync;
  132757. private _saveVersionIntoDBAsync;
  132758. /**
  132759. * Loads a file from database
  132760. * @param url defines the URL to load from
  132761. * @param sceneLoaded defines a callback to call on success
  132762. * @param progressCallBack defines a callback to call when progress changed
  132763. * @param errorCallback defines a callback to call on error
  132764. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  132765. */
  132766. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  132767. private _loadFileAsync;
  132768. private _saveFileAsync;
  132769. /**
  132770. * Validates if xhr data is correct
  132771. * @param xhr defines the request to validate
  132772. * @param dataType defines the expected data type
  132773. * @returns true if data is correct
  132774. */
  132775. private static _ValidateXHRData;
  132776. }
  132777. }
  132778. declare module BABYLON {
  132779. /** @hidden */
  132780. export var gpuUpdateParticlesPixelShader: {
  132781. name: string;
  132782. shader: string;
  132783. };
  132784. }
  132785. declare module BABYLON {
  132786. /** @hidden */
  132787. export var gpuUpdateParticlesVertexShader: {
  132788. name: string;
  132789. shader: string;
  132790. };
  132791. }
  132792. declare module BABYLON {
  132793. /** @hidden */
  132794. export var clipPlaneFragmentDeclaration2: {
  132795. name: string;
  132796. shader: string;
  132797. };
  132798. }
  132799. declare module BABYLON {
  132800. /** @hidden */
  132801. export var gpuRenderParticlesPixelShader: {
  132802. name: string;
  132803. shader: string;
  132804. };
  132805. }
  132806. declare module BABYLON {
  132807. /** @hidden */
  132808. export var clipPlaneVertexDeclaration2: {
  132809. name: string;
  132810. shader: string;
  132811. };
  132812. }
  132813. declare module BABYLON {
  132814. /** @hidden */
  132815. export var gpuRenderParticlesVertexShader: {
  132816. name: string;
  132817. shader: string;
  132818. };
  132819. }
  132820. declare module BABYLON {
  132821. /**
  132822. * This represents a GPU particle system in Babylon
  132823. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  132824. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  132825. */
  132826. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  132827. /**
  132828. * The layer mask we are rendering the particles through.
  132829. */
  132830. layerMask: number;
  132831. private _capacity;
  132832. private _activeCount;
  132833. private _currentActiveCount;
  132834. private _accumulatedCount;
  132835. private _renderEffect;
  132836. private _updateEffect;
  132837. private _buffer0;
  132838. private _buffer1;
  132839. private _spriteBuffer;
  132840. private _updateVAO;
  132841. private _renderVAO;
  132842. private _targetIndex;
  132843. private _sourceBuffer;
  132844. private _targetBuffer;
  132845. private _engine;
  132846. private _currentRenderId;
  132847. private _started;
  132848. private _stopped;
  132849. private _timeDelta;
  132850. private _randomTexture;
  132851. private _randomTexture2;
  132852. private _attributesStrideSize;
  132853. private _updateEffectOptions;
  132854. private _randomTextureSize;
  132855. private _actualFrame;
  132856. private readonly _rawTextureWidth;
  132857. /**
  132858. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  132859. */
  132860. static get IsSupported(): boolean;
  132861. /**
  132862. * An event triggered when the system is disposed.
  132863. */
  132864. onDisposeObservable: Observable<GPUParticleSystem>;
  132865. /**
  132866. * Gets the maximum number of particles active at the same time.
  132867. * @returns The max number of active particles.
  132868. */
  132869. getCapacity(): number;
  132870. /**
  132871. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  132872. * to override the particles.
  132873. */
  132874. forceDepthWrite: boolean;
  132875. /**
  132876. * Gets or set the number of active particles
  132877. */
  132878. get activeParticleCount(): number;
  132879. set activeParticleCount(value: number);
  132880. private _preWarmDone;
  132881. /**
  132882. * Is this system ready to be used/rendered
  132883. * @return true if the system is ready
  132884. */
  132885. isReady(): boolean;
  132886. /**
  132887. * Gets if the system has been started. (Note: this will still be true after stop is called)
  132888. * @returns True if it has been started, otherwise false.
  132889. */
  132890. isStarted(): boolean;
  132891. /**
  132892. * Starts the particle system and begins to emit
  132893. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  132894. */
  132895. start(delay?: number): void;
  132896. /**
  132897. * Stops the particle system.
  132898. */
  132899. stop(): void;
  132900. /**
  132901. * Remove all active particles
  132902. */
  132903. reset(): void;
  132904. /**
  132905. * Returns the string "GPUParticleSystem"
  132906. * @returns a string containing the class name
  132907. */
  132908. getClassName(): string;
  132909. private _colorGradientsTexture;
  132910. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  132911. /**
  132912. * Adds a new color gradient
  132913. * @param gradient defines the gradient to use (between 0 and 1)
  132914. * @param color1 defines the color to affect to the specified gradient
  132915. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  132916. * @returns the current particle system
  132917. */
  132918. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  132919. /**
  132920. * Remove a specific color gradient
  132921. * @param gradient defines the gradient to remove
  132922. * @returns the current particle system
  132923. */
  132924. removeColorGradient(gradient: number): GPUParticleSystem;
  132925. private _angularSpeedGradientsTexture;
  132926. private _sizeGradientsTexture;
  132927. private _velocityGradientsTexture;
  132928. private _limitVelocityGradientsTexture;
  132929. private _dragGradientsTexture;
  132930. private _addFactorGradient;
  132931. /**
  132932. * Adds a new size gradient
  132933. * @param gradient defines the gradient to use (between 0 and 1)
  132934. * @param factor defines the size factor to affect to the specified gradient
  132935. * @returns the current particle system
  132936. */
  132937. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  132938. /**
  132939. * Remove a specific size gradient
  132940. * @param gradient defines the gradient to remove
  132941. * @returns the current particle system
  132942. */
  132943. removeSizeGradient(gradient: number): GPUParticleSystem;
  132944. /**
  132945. * Adds a new angular speed gradient
  132946. * @param gradient defines the gradient to use (between 0 and 1)
  132947. * @param factor defines the angular speed to affect to the specified gradient
  132948. * @returns the current particle system
  132949. */
  132950. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  132951. /**
  132952. * Remove a specific angular speed gradient
  132953. * @param gradient defines the gradient to remove
  132954. * @returns the current particle system
  132955. */
  132956. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  132957. /**
  132958. * Adds a new velocity gradient
  132959. * @param gradient defines the gradient to use (between 0 and 1)
  132960. * @param factor defines the velocity to affect to the specified gradient
  132961. * @returns the current particle system
  132962. */
  132963. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  132964. /**
  132965. * Remove a specific velocity gradient
  132966. * @param gradient defines the gradient to remove
  132967. * @returns the current particle system
  132968. */
  132969. removeVelocityGradient(gradient: number): GPUParticleSystem;
  132970. /**
  132971. * Adds a new limit velocity gradient
  132972. * @param gradient defines the gradient to use (between 0 and 1)
  132973. * @param factor defines the limit velocity value to affect to the specified gradient
  132974. * @returns the current particle system
  132975. */
  132976. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  132977. /**
  132978. * Remove a specific limit velocity gradient
  132979. * @param gradient defines the gradient to remove
  132980. * @returns the current particle system
  132981. */
  132982. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  132983. /**
  132984. * Adds a new drag gradient
  132985. * @param gradient defines the gradient to use (between 0 and 1)
  132986. * @param factor defines the drag value to affect to the specified gradient
  132987. * @returns the current particle system
  132988. */
  132989. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  132990. /**
  132991. * Remove a specific drag gradient
  132992. * @param gradient defines the gradient to remove
  132993. * @returns the current particle system
  132994. */
  132995. removeDragGradient(gradient: number): GPUParticleSystem;
  132996. /**
  132997. * Not supported by GPUParticleSystem
  132998. * @param gradient defines the gradient to use (between 0 and 1)
  132999. * @param factor defines the emit rate value to affect to the specified gradient
  133000. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  133001. * @returns the current particle system
  133002. */
  133003. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  133004. /**
  133005. * Not supported by GPUParticleSystem
  133006. * @param gradient defines the gradient to remove
  133007. * @returns the current particle system
  133008. */
  133009. removeEmitRateGradient(gradient: number): IParticleSystem;
  133010. /**
  133011. * Not supported by GPUParticleSystem
  133012. * @param gradient defines the gradient to use (between 0 and 1)
  133013. * @param factor defines the start size value to affect to the specified gradient
  133014. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  133015. * @returns the current particle system
  133016. */
  133017. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  133018. /**
  133019. * Not supported by GPUParticleSystem
  133020. * @param gradient defines the gradient to remove
  133021. * @returns the current particle system
  133022. */
  133023. removeStartSizeGradient(gradient: number): IParticleSystem;
  133024. /**
  133025. * Not supported by GPUParticleSystem
  133026. * @param gradient defines the gradient to use (between 0 and 1)
  133027. * @param min defines the color remap minimal range
  133028. * @param max defines the color remap maximal range
  133029. * @returns the current particle system
  133030. */
  133031. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  133032. /**
  133033. * Not supported by GPUParticleSystem
  133034. * @param gradient defines the gradient to remove
  133035. * @returns the current particle system
  133036. */
  133037. removeColorRemapGradient(): IParticleSystem;
  133038. /**
  133039. * Not supported by GPUParticleSystem
  133040. * @param gradient defines the gradient to use (between 0 and 1)
  133041. * @param min defines the alpha remap minimal range
  133042. * @param max defines the alpha remap maximal range
  133043. * @returns the current particle system
  133044. */
  133045. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  133046. /**
  133047. * Not supported by GPUParticleSystem
  133048. * @param gradient defines the gradient to remove
  133049. * @returns the current particle system
  133050. */
  133051. removeAlphaRemapGradient(): IParticleSystem;
  133052. /**
  133053. * Not supported by GPUParticleSystem
  133054. * @param gradient defines the gradient to use (between 0 and 1)
  133055. * @param color defines the color to affect to the specified gradient
  133056. * @returns the current particle system
  133057. */
  133058. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  133059. /**
  133060. * Not supported by GPUParticleSystem
  133061. * @param gradient defines the gradient to remove
  133062. * @returns the current particle system
  133063. */
  133064. removeRampGradient(): IParticleSystem;
  133065. /**
  133066. * Not supported by GPUParticleSystem
  133067. * @returns the list of ramp gradients
  133068. */
  133069. getRampGradients(): Nullable<Array<Color3Gradient>>;
  133070. /**
  133071. * Not supported by GPUParticleSystem
  133072. * Gets or sets a boolean indicating that ramp gradients must be used
  133073. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  133074. */
  133075. get useRampGradients(): boolean;
  133076. set useRampGradients(value: boolean);
  133077. /**
  133078. * Not supported by GPUParticleSystem
  133079. * @param gradient defines the gradient to use (between 0 and 1)
  133080. * @param factor defines the life time factor to affect to the specified gradient
  133081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  133082. * @returns the current particle system
  133083. */
  133084. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  133085. /**
  133086. * Not supported by GPUParticleSystem
  133087. * @param gradient defines the gradient to remove
  133088. * @returns the current particle system
  133089. */
  133090. removeLifeTimeGradient(gradient: number): IParticleSystem;
  133091. /**
  133092. * Instantiates a GPU particle system.
  133093. * 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.
  133094. * @param name The name of the particle system
  133095. * @param options The options used to create the system
  133096. * @param scene The scene the particle system belongs to
  133097. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  133098. */
  133099. constructor(name: string, options: Partial<{
  133100. capacity: number;
  133101. randomTextureSize: number;
  133102. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  133103. protected _reset(): void;
  133104. private _createUpdateVAO;
  133105. private _createRenderVAO;
  133106. private _initialize;
  133107. /** @hidden */
  133108. _recreateUpdateEffect(): void;
  133109. /** @hidden */
  133110. _recreateRenderEffect(): void;
  133111. /**
  133112. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  133113. * @param preWarm defines if we are in the pre-warmimg phase
  133114. */
  133115. animate(preWarm?: boolean): void;
  133116. private _createFactorGradientTexture;
  133117. private _createSizeGradientTexture;
  133118. private _createAngularSpeedGradientTexture;
  133119. private _createVelocityGradientTexture;
  133120. private _createLimitVelocityGradientTexture;
  133121. private _createDragGradientTexture;
  133122. private _createColorGradientTexture;
  133123. /**
  133124. * Renders the particle system in its current state
  133125. * @param preWarm defines if the system should only update the particles but not render them
  133126. * @returns the current number of particles
  133127. */
  133128. render(preWarm?: boolean): number;
  133129. /**
  133130. * Rebuilds the particle system
  133131. */
  133132. rebuild(): void;
  133133. private _releaseBuffers;
  133134. private _releaseVAOs;
  133135. /**
  133136. * Disposes the particle system and free the associated resources
  133137. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  133138. */
  133139. dispose(disposeTexture?: boolean): void;
  133140. /**
  133141. * Clones the particle system.
  133142. * @param name The name of the cloned object
  133143. * @param newEmitter The new emitter to use
  133144. * @returns the cloned particle system
  133145. */
  133146. clone(name: string, newEmitter: any): GPUParticleSystem;
  133147. /**
  133148. * Serializes the particle system to a JSON object.
  133149. * @returns the JSON object
  133150. */
  133151. serialize(): any;
  133152. /**
  133153. * Parses a JSON object to create a GPU particle system.
  133154. * @param parsedParticleSystem The JSON object to parse
  133155. * @param scene The scene to create the particle system in
  133156. * @param rootUrl The root url to use to load external dependencies like texture
  133157. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  133158. * @returns the parsed GPU particle system
  133159. */
  133160. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  133161. }
  133162. }
  133163. declare module BABYLON {
  133164. /**
  133165. * Represents a set of particle systems working together to create a specific effect
  133166. */
  133167. export class ParticleSystemSet implements IDisposable {
  133168. /**
  133169. * Gets or sets base Assets URL
  133170. */
  133171. static BaseAssetsUrl: string;
  133172. private _emitterCreationOptions;
  133173. private _emitterNode;
  133174. /**
  133175. * Gets the particle system list
  133176. */
  133177. systems: IParticleSystem[];
  133178. /**
  133179. * Gets the emitter node used with this set
  133180. */
  133181. get emitterNode(): Nullable<TransformNode>;
  133182. /**
  133183. * Creates a new emitter mesh as a sphere
  133184. * @param options defines the options used to create the sphere
  133185. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  133186. * @param scene defines the hosting scene
  133187. */
  133188. setEmitterAsSphere(options: {
  133189. diameter: number;
  133190. segments: number;
  133191. color: Color3;
  133192. }, renderingGroupId: number, scene: Scene): void;
  133193. /**
  133194. * Starts all particle systems of the set
  133195. * @param emitter defines an optional mesh to use as emitter for the particle systems
  133196. */
  133197. start(emitter?: AbstractMesh): void;
  133198. /**
  133199. * Release all associated resources
  133200. */
  133201. dispose(): void;
  133202. /**
  133203. * Serialize the set into a JSON compatible object
  133204. * @returns a JSON compatible representation of the set
  133205. */
  133206. serialize(): any;
  133207. /**
  133208. * Parse a new ParticleSystemSet from a serialized source
  133209. * @param data defines a JSON compatible representation of the set
  133210. * @param scene defines the hosting scene
  133211. * @param gpu defines if we want GPU particles or CPU particles
  133212. * @returns a new ParticleSystemSet
  133213. */
  133214. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  133215. }
  133216. }
  133217. declare module BABYLON {
  133218. /**
  133219. * This class is made for on one-liner static method to help creating particle system set.
  133220. */
  133221. export class ParticleHelper {
  133222. /**
  133223. * Gets or sets base Assets URL
  133224. */
  133225. static BaseAssetsUrl: string;
  133226. /**
  133227. * Create a default particle system that you can tweak
  133228. * @param emitter defines the emitter to use
  133229. * @param capacity defines the system capacity (default is 500 particles)
  133230. * @param scene defines the hosting scene
  133231. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  133232. * @returns the new Particle system
  133233. */
  133234. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  133235. /**
  133236. * This is the main static method (one-liner) of this helper to create different particle systems
  133237. * @param type This string represents the type to the particle system to create
  133238. * @param scene The scene where the particle system should live
  133239. * @param gpu If the system will use gpu
  133240. * @returns the ParticleSystemSet created
  133241. */
  133242. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  133243. /**
  133244. * Static function used to export a particle system to a ParticleSystemSet variable.
  133245. * Please note that the emitter shape is not exported
  133246. * @param systems defines the particle systems to export
  133247. * @returns the created particle system set
  133248. */
  133249. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  133250. }
  133251. }
  133252. declare module BABYLON {
  133253. interface Engine {
  133254. /**
  133255. * Create an effect to use with particle systems.
  133256. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  133257. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  133258. * @param uniformsNames defines a list of attribute names
  133259. * @param samplers defines an array of string used to represent textures
  133260. * @param defines defines the string containing the defines to use to compile the shaders
  133261. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  133262. * @param onCompiled defines a function to call when the effect creation is successful
  133263. * @param onError defines a function to call when the effect creation has failed
  133264. * @returns the new Effect
  133265. */
  133266. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  133267. }
  133268. interface Mesh {
  133269. /**
  133270. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  133271. * @returns an array of IParticleSystem
  133272. */
  133273. getEmittedParticleSystems(): IParticleSystem[];
  133274. /**
  133275. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  133276. * @returns an array of IParticleSystem
  133277. */
  133278. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  133279. }
  133280. /**
  133281. * @hidden
  133282. */
  133283. export var _IDoNeedToBeInTheBuild: number;
  133284. }
  133285. declare module BABYLON {
  133286. /** Defines the 4 color options */
  133287. export enum PointColor {
  133288. /** color value */
  133289. Color = 2,
  133290. /** uv value */
  133291. UV = 1,
  133292. /** random value */
  133293. Random = 0,
  133294. /** stated value */
  133295. Stated = 3
  133296. }
  133297. /**
  133298. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  133299. * 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.
  133300. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  133301. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  133302. *
  133303. * Full documentation here : TO BE ENTERED
  133304. */
  133305. export class PointsCloudSystem implements IDisposable {
  133306. /**
  133307. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  133308. * Example : var p = SPS.particles[i];
  133309. */
  133310. particles: CloudPoint[];
  133311. /**
  133312. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  133313. */
  133314. nbParticles: number;
  133315. /**
  133316. * This a counter for your own usage. It's not set by any SPS functions.
  133317. */
  133318. counter: number;
  133319. /**
  133320. * The PCS name. This name is also given to the underlying mesh.
  133321. */
  133322. name: string;
  133323. /**
  133324. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  133325. */
  133326. mesh: Mesh;
  133327. /**
  133328. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  133329. * Please read :
  133330. */
  133331. vars: any;
  133332. /**
  133333. * @hidden
  133334. */
  133335. _size: number;
  133336. private _scene;
  133337. private _promises;
  133338. private _positions;
  133339. private _indices;
  133340. private _normals;
  133341. private _colors;
  133342. private _uvs;
  133343. private _indices32;
  133344. private _positions32;
  133345. private _colors32;
  133346. private _uvs32;
  133347. private _updatable;
  133348. private _isVisibilityBoxLocked;
  133349. private _alwaysVisible;
  133350. private _groups;
  133351. private _groupCounter;
  133352. private _computeParticleColor;
  133353. private _computeParticleTexture;
  133354. private _computeParticleRotation;
  133355. private _computeBoundingBox;
  133356. private _isReady;
  133357. /**
  133358. * Creates a PCS (Points Cloud System) object
  133359. * @param name (String) is the PCS name, this will be the underlying mesh name
  133360. * @param pointSize (number) is the size for each point
  133361. * @param scene (Scene) is the scene in which the PCS is added
  133362. * @param options defines the options of the PCS e.g.
  133363. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  133364. */
  133365. constructor(name: string, pointSize: number, scene: Scene, options?: {
  133366. updatable?: boolean;
  133367. });
  133368. /**
  133369. * Builds the PCS underlying mesh. Returns a standard Mesh.
  133370. * If no points were added to the PCS, the returned mesh is just a single point.
  133371. * @returns a promise for the created mesh
  133372. */
  133373. buildMeshAsync(): Promise<Mesh>;
  133374. /**
  133375. * @hidden
  133376. */
  133377. private _buildMesh;
  133378. private _addParticle;
  133379. private _randomUnitVector;
  133380. private _getColorIndicesForCoord;
  133381. private _setPointsColorOrUV;
  133382. private _colorFromTexture;
  133383. private _calculateDensity;
  133384. /**
  133385. * Adds points to the PCS in random positions within a unit sphere
  133386. * @param nb (positive integer) the number of particles to be created from this model
  133387. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  133388. * @returns the number of groups in the system
  133389. */
  133390. addPoints(nb: number, pointFunction?: any): number;
  133391. /**
  133392. * Adds points to the PCS from the surface of the model shape
  133393. * @param mesh is any Mesh object that will be used as a surface model for the points
  133394. * @param nb (positive integer) the number of particles to be created from this model
  133395. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  133396. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  133397. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  133398. * @returns the number of groups in the system
  133399. */
  133400. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  133401. /**
  133402. * Adds points to the PCS inside the model shape
  133403. * @param mesh is any Mesh object that will be used as a surface model for the points
  133404. * @param nb (positive integer) the number of particles to be created from this model
  133405. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  133406. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  133407. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  133408. * @returns the number of groups in the system
  133409. */
  133410. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  133411. /**
  133412. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  133413. * This method calls `updateParticle()` for each particle of the SPS.
  133414. * For an animated SPS, it is usually called within the render loop.
  133415. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  133416. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  133417. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  133418. * @returns the PCS.
  133419. */
  133420. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  133421. /**
  133422. * Disposes the PCS.
  133423. */
  133424. dispose(): void;
  133425. /**
  133426. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  133427. * doc :
  133428. * @returns the PCS.
  133429. */
  133430. refreshVisibleSize(): PointsCloudSystem;
  133431. /**
  133432. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  133433. * @param size the size (float) of the visibility box
  133434. * note : this doesn't lock the PCS mesh bounding box.
  133435. * doc :
  133436. */
  133437. setVisibilityBox(size: number): void;
  133438. /**
  133439. * Gets whether the PCS is always visible or not
  133440. * doc :
  133441. */
  133442. get isAlwaysVisible(): boolean;
  133443. /**
  133444. * Sets the PCS as always visible or not
  133445. * doc :
  133446. */
  133447. set isAlwaysVisible(val: boolean);
  133448. /**
  133449. * Tells to `setParticles()` to compute the particle rotations or not
  133450. * Default value : false. The PCS is faster when it's set to false
  133451. * Note : particle rotations are only applied to parent particles
  133452. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  133453. */
  133454. set computeParticleRotation(val: boolean);
  133455. /**
  133456. * Tells to `setParticles()` to compute the particle colors or not.
  133457. * Default value : true. The PCS is faster when it's set to false.
  133458. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  133459. */
  133460. set computeParticleColor(val: boolean);
  133461. set computeParticleTexture(val: boolean);
  133462. /**
  133463. * Gets if `setParticles()` computes the particle colors or not.
  133464. * Default value : false. The PCS is faster when it's set to false.
  133465. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  133466. */
  133467. get computeParticleColor(): boolean;
  133468. /**
  133469. * Gets if `setParticles()` computes the particle textures or not.
  133470. * Default value : false. The PCS is faster when it's set to false.
  133471. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  133472. */
  133473. get computeParticleTexture(): boolean;
  133474. /**
  133475. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  133476. */
  133477. set computeBoundingBox(val: boolean);
  133478. /**
  133479. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  133480. */
  133481. get computeBoundingBox(): boolean;
  133482. /**
  133483. * This function does nothing. It may be overwritten to set all the particle first values.
  133484. * The PCS doesn't call this function, you may have to call it by your own.
  133485. * doc :
  133486. */
  133487. initParticles(): void;
  133488. /**
  133489. * This function does nothing. It may be overwritten to recycle a particle
  133490. * The PCS doesn't call this function, you can to call it
  133491. * doc :
  133492. * @param particle The particle to recycle
  133493. * @returns the recycled particle
  133494. */
  133495. recycleParticle(particle: CloudPoint): CloudPoint;
  133496. /**
  133497. * Updates a particle : this function should be overwritten by the user.
  133498. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  133499. * doc :
  133500. * @example : just set a particle position or velocity and recycle conditions
  133501. * @param particle The particle to update
  133502. * @returns the updated particle
  133503. */
  133504. updateParticle(particle: CloudPoint): CloudPoint;
  133505. /**
  133506. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  133507. * This does nothing and may be overwritten by the user.
  133508. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  133509. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  133510. * @param update the boolean update value actually passed to setParticles()
  133511. */
  133512. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  133513. /**
  133514. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  133515. * This will be passed three parameters.
  133516. * This does nothing and may be overwritten by the user.
  133517. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  133518. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  133519. * @param update the boolean update value actually passed to setParticles()
  133520. */
  133521. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  133522. }
  133523. }
  133524. declare module BABYLON {
  133525. /**
  133526. * Represents one particle of a points cloud system.
  133527. */
  133528. export class CloudPoint {
  133529. /**
  133530. * particle global index
  133531. */
  133532. idx: number;
  133533. /**
  133534. * The color of the particle
  133535. */
  133536. color: Nullable<Color4>;
  133537. /**
  133538. * The world space position of the particle.
  133539. */
  133540. position: Vector3;
  133541. /**
  133542. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  133543. */
  133544. rotation: Vector3;
  133545. /**
  133546. * The world space rotation quaternion of the particle.
  133547. */
  133548. rotationQuaternion: Nullable<Quaternion>;
  133549. /**
  133550. * The uv of the particle.
  133551. */
  133552. uv: Nullable<Vector2>;
  133553. /**
  133554. * The current speed of the particle.
  133555. */
  133556. velocity: Vector3;
  133557. /**
  133558. * The pivot point in the particle local space.
  133559. */
  133560. pivot: Vector3;
  133561. /**
  133562. * Must the particle be translated from its pivot point in its local space ?
  133563. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  133564. * Default : false
  133565. */
  133566. translateFromPivot: boolean;
  133567. /**
  133568. * Index of this particle in the global "positions" array (Internal use)
  133569. * @hidden
  133570. */
  133571. _pos: number;
  133572. /**
  133573. * @hidden Index of this particle in the global "indices" array (Internal use)
  133574. */
  133575. _ind: number;
  133576. /**
  133577. * Group this particle belongs to
  133578. */
  133579. _group: PointsGroup;
  133580. /**
  133581. * Group id of this particle
  133582. */
  133583. groupId: number;
  133584. /**
  133585. * Index of the particle in its group id (Internal use)
  133586. */
  133587. idxInGroup: number;
  133588. /**
  133589. * @hidden Particle BoundingInfo object (Internal use)
  133590. */
  133591. _boundingInfo: BoundingInfo;
  133592. /**
  133593. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  133594. */
  133595. _pcs: PointsCloudSystem;
  133596. /**
  133597. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  133598. */
  133599. _stillInvisible: boolean;
  133600. /**
  133601. * @hidden Last computed particle rotation matrix
  133602. */
  133603. _rotationMatrix: number[];
  133604. /**
  133605. * Parent particle Id, if any.
  133606. * Default null.
  133607. */
  133608. parentId: Nullable<number>;
  133609. /**
  133610. * @hidden Internal global position in the PCS.
  133611. */
  133612. _globalPosition: Vector3;
  133613. /**
  133614. * Creates a Point Cloud object.
  133615. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  133616. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  133617. * @param group (PointsGroup) is the group the particle belongs to
  133618. * @param groupId (integer) is the group identifier in the PCS.
  133619. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  133620. * @param pcs defines the PCS it is associated to
  133621. */
  133622. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  133623. /**
  133624. * get point size
  133625. */
  133626. get size(): Vector3;
  133627. /**
  133628. * Set point size
  133629. */
  133630. set size(scale: Vector3);
  133631. /**
  133632. * Legacy support, changed quaternion to rotationQuaternion
  133633. */
  133634. get quaternion(): Nullable<Quaternion>;
  133635. /**
  133636. * Legacy support, changed quaternion to rotationQuaternion
  133637. */
  133638. set quaternion(q: Nullable<Quaternion>);
  133639. /**
  133640. * Returns a boolean. True if the particle intersects a mesh, else false
  133641. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  133642. * @param target is the object (point or mesh) what the intersection is computed against
  133643. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  133644. * @returns true if it intersects
  133645. */
  133646. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  133647. /**
  133648. * get the rotation matrix of the particle
  133649. * @hidden
  133650. */
  133651. getRotationMatrix(m: Matrix): void;
  133652. }
  133653. /**
  133654. * Represents a group of points in a points cloud system
  133655. * * PCS internal tool, don't use it manually.
  133656. */
  133657. export class PointsGroup {
  133658. /**
  133659. * The group id
  133660. * @hidden
  133661. */
  133662. groupID: number;
  133663. /**
  133664. * image data for group (internal use)
  133665. * @hidden
  133666. */
  133667. _groupImageData: Nullable<ArrayBufferView>;
  133668. /**
  133669. * Image Width (internal use)
  133670. * @hidden
  133671. */
  133672. _groupImgWidth: number;
  133673. /**
  133674. * Image Height (internal use)
  133675. * @hidden
  133676. */
  133677. _groupImgHeight: number;
  133678. /**
  133679. * Custom position function (internal use)
  133680. * @hidden
  133681. */
  133682. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  133683. /**
  133684. * density per facet for surface points
  133685. * @hidden
  133686. */
  133687. _groupDensity: number[];
  133688. /**
  133689. * Only when points are colored by texture carries pointer to texture list array
  133690. * @hidden
  133691. */
  133692. _textureNb: number;
  133693. /**
  133694. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  133695. * PCS internal tool, don't use it manually.
  133696. * @hidden
  133697. */
  133698. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  133699. }
  133700. }
  133701. declare module BABYLON {
  133702. interface Scene {
  133703. /** @hidden (Backing field) */
  133704. _physicsEngine: Nullable<IPhysicsEngine>;
  133705. /** @hidden */
  133706. _physicsTimeAccumulator: number;
  133707. /**
  133708. * Gets the current physics engine
  133709. * @returns a IPhysicsEngine or null if none attached
  133710. */
  133711. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  133712. /**
  133713. * Enables physics to the current scene
  133714. * @param gravity defines the scene's gravity for the physics engine
  133715. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  133716. * @return a boolean indicating if the physics engine was initialized
  133717. */
  133718. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  133719. /**
  133720. * Disables and disposes the physics engine associated with the scene
  133721. */
  133722. disablePhysicsEngine(): void;
  133723. /**
  133724. * Gets a boolean indicating if there is an active physics engine
  133725. * @returns a boolean indicating if there is an active physics engine
  133726. */
  133727. isPhysicsEnabled(): boolean;
  133728. /**
  133729. * Deletes a physics compound impostor
  133730. * @param compound defines the compound to delete
  133731. */
  133732. deleteCompoundImpostor(compound: any): void;
  133733. /**
  133734. * An event triggered when physic simulation is about to be run
  133735. */
  133736. onBeforePhysicsObservable: Observable<Scene>;
  133737. /**
  133738. * An event triggered when physic simulation has been done
  133739. */
  133740. onAfterPhysicsObservable: Observable<Scene>;
  133741. }
  133742. interface AbstractMesh {
  133743. /** @hidden */
  133744. _physicsImpostor: Nullable<PhysicsImpostor>;
  133745. /**
  133746. * Gets or sets impostor used for physic simulation
  133747. * @see http://doc.babylonjs.com/features/physics_engine
  133748. */
  133749. physicsImpostor: Nullable<PhysicsImpostor>;
  133750. /**
  133751. * Gets the current physics impostor
  133752. * @see http://doc.babylonjs.com/features/physics_engine
  133753. * @returns a physics impostor or null
  133754. */
  133755. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  133756. /** Apply a physic impulse to the mesh
  133757. * @param force defines the force to apply
  133758. * @param contactPoint defines where to apply the force
  133759. * @returns the current mesh
  133760. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  133761. */
  133762. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  133763. /**
  133764. * Creates a physic joint between two meshes
  133765. * @param otherMesh defines the other mesh to use
  133766. * @param pivot1 defines the pivot to use on this mesh
  133767. * @param pivot2 defines the pivot to use on the other mesh
  133768. * @param options defines additional options (can be plugin dependent)
  133769. * @returns the current mesh
  133770. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  133771. */
  133772. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  133773. /** @hidden */
  133774. _disposePhysicsObserver: Nullable<Observer<Node>>;
  133775. }
  133776. /**
  133777. * Defines the physics engine scene component responsible to manage a physics engine
  133778. */
  133779. export class PhysicsEngineSceneComponent implements ISceneComponent {
  133780. /**
  133781. * The component name helpful to identify the component in the list of scene components.
  133782. */
  133783. readonly name: string;
  133784. /**
  133785. * The scene the component belongs to.
  133786. */
  133787. scene: Scene;
  133788. /**
  133789. * Creates a new instance of the component for the given scene
  133790. * @param scene Defines the scene to register the component in
  133791. */
  133792. constructor(scene: Scene);
  133793. /**
  133794. * Registers the component in a given scene
  133795. */
  133796. register(): void;
  133797. /**
  133798. * Rebuilds the elements related to this component in case of
  133799. * context lost for instance.
  133800. */
  133801. rebuild(): void;
  133802. /**
  133803. * Disposes the component and the associated ressources
  133804. */
  133805. dispose(): void;
  133806. }
  133807. }
  133808. declare module BABYLON {
  133809. /**
  133810. * A helper for physics simulations
  133811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  133812. */
  133813. export class PhysicsHelper {
  133814. private _scene;
  133815. private _physicsEngine;
  133816. /**
  133817. * Initializes the Physics helper
  133818. * @param scene Babylon.js scene
  133819. */
  133820. constructor(scene: Scene);
  133821. /**
  133822. * Applies a radial explosion impulse
  133823. * @param origin the origin of the explosion
  133824. * @param radiusOrEventOptions the radius or the options of radial explosion
  133825. * @param strength the explosion strength
  133826. * @param falloff possible options: Constant & Linear. Defaults to Constant
  133827. * @returns A physics radial explosion event, or null
  133828. */
  133829. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  133830. /**
  133831. * Applies a radial explosion force
  133832. * @param origin the origin of the explosion
  133833. * @param radiusOrEventOptions the radius or the options of radial explosion
  133834. * @param strength the explosion strength
  133835. * @param falloff possible options: Constant & Linear. Defaults to Constant
  133836. * @returns A physics radial explosion event, or null
  133837. */
  133838. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  133839. /**
  133840. * Creates a gravitational field
  133841. * @param origin the origin of the explosion
  133842. * @param radiusOrEventOptions the radius or the options of radial explosion
  133843. * @param strength the explosion strength
  133844. * @param falloff possible options: Constant & Linear. Defaults to Constant
  133845. * @returns A physics gravitational field event, or null
  133846. */
  133847. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  133848. /**
  133849. * Creates a physics updraft event
  133850. * @param origin the origin of the updraft
  133851. * @param radiusOrEventOptions the radius or the options of the updraft
  133852. * @param strength the strength of the updraft
  133853. * @param height the height of the updraft
  133854. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  133855. * @returns A physics updraft event, or null
  133856. */
  133857. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  133858. /**
  133859. * Creates a physics vortex event
  133860. * @param origin the of the vortex
  133861. * @param radiusOrEventOptions the radius or the options of the vortex
  133862. * @param strength the strength of the vortex
  133863. * @param height the height of the vortex
  133864. * @returns a Physics vortex event, or null
  133865. * A physics vortex event or null
  133866. */
  133867. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  133868. }
  133869. /**
  133870. * Represents a physics radial explosion event
  133871. */
  133872. class PhysicsRadialExplosionEvent {
  133873. private _scene;
  133874. private _options;
  133875. private _sphere;
  133876. private _dataFetched;
  133877. /**
  133878. * Initializes a radial explosioin event
  133879. * @param _scene BabylonJS scene
  133880. * @param _options The options for the vortex event
  133881. */
  133882. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  133883. /**
  133884. * Returns the data related to the radial explosion event (sphere).
  133885. * @returns The radial explosion event data
  133886. */
  133887. getData(): PhysicsRadialExplosionEventData;
  133888. /**
  133889. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  133890. * @param impostor A physics imposter
  133891. * @param origin the origin of the explosion
  133892. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  133893. */
  133894. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  133895. /**
  133896. * Triggers affecterd impostors callbacks
  133897. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  133898. */
  133899. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  133900. /**
  133901. * Disposes the sphere.
  133902. * @param force Specifies if the sphere should be disposed by force
  133903. */
  133904. dispose(force?: boolean): void;
  133905. /*** Helpers ***/
  133906. private _prepareSphere;
  133907. private _intersectsWithSphere;
  133908. }
  133909. /**
  133910. * Represents a gravitational field event
  133911. */
  133912. class PhysicsGravitationalFieldEvent {
  133913. private _physicsHelper;
  133914. private _scene;
  133915. private _origin;
  133916. private _options;
  133917. private _tickCallback;
  133918. private _sphere;
  133919. private _dataFetched;
  133920. /**
  133921. * Initializes the physics gravitational field event
  133922. * @param _physicsHelper A physics helper
  133923. * @param _scene BabylonJS scene
  133924. * @param _origin The origin position of the gravitational field event
  133925. * @param _options The options for the vortex event
  133926. */
  133927. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  133928. /**
  133929. * Returns the data related to the gravitational field event (sphere).
  133930. * @returns A gravitational field event
  133931. */
  133932. getData(): PhysicsGravitationalFieldEventData;
  133933. /**
  133934. * Enables the gravitational field.
  133935. */
  133936. enable(): void;
  133937. /**
  133938. * Disables the gravitational field.
  133939. */
  133940. disable(): void;
  133941. /**
  133942. * Disposes the sphere.
  133943. * @param force The force to dispose from the gravitational field event
  133944. */
  133945. dispose(force?: boolean): void;
  133946. private _tick;
  133947. }
  133948. /**
  133949. * Represents a physics updraft event
  133950. */
  133951. class PhysicsUpdraftEvent {
  133952. private _scene;
  133953. private _origin;
  133954. private _options;
  133955. private _physicsEngine;
  133956. private _originTop;
  133957. private _originDirection;
  133958. private _tickCallback;
  133959. private _cylinder;
  133960. private _cylinderPosition;
  133961. private _dataFetched;
  133962. /**
  133963. * Initializes the physics updraft event
  133964. * @param _scene BabylonJS scene
  133965. * @param _origin The origin position of the updraft
  133966. * @param _options The options for the updraft event
  133967. */
  133968. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  133969. /**
  133970. * Returns the data related to the updraft event (cylinder).
  133971. * @returns A physics updraft event
  133972. */
  133973. getData(): PhysicsUpdraftEventData;
  133974. /**
  133975. * Enables the updraft.
  133976. */
  133977. enable(): void;
  133978. /**
  133979. * Disables the updraft.
  133980. */
  133981. disable(): void;
  133982. /**
  133983. * Disposes the cylinder.
  133984. * @param force Specifies if the updraft should be disposed by force
  133985. */
  133986. dispose(force?: boolean): void;
  133987. private getImpostorHitData;
  133988. private _tick;
  133989. /*** Helpers ***/
  133990. private _prepareCylinder;
  133991. private _intersectsWithCylinder;
  133992. }
  133993. /**
  133994. * Represents a physics vortex event
  133995. */
  133996. class PhysicsVortexEvent {
  133997. private _scene;
  133998. private _origin;
  133999. private _options;
  134000. private _physicsEngine;
  134001. private _originTop;
  134002. private _tickCallback;
  134003. private _cylinder;
  134004. private _cylinderPosition;
  134005. private _dataFetched;
  134006. /**
  134007. * Initializes the physics vortex event
  134008. * @param _scene The BabylonJS scene
  134009. * @param _origin The origin position of the vortex
  134010. * @param _options The options for the vortex event
  134011. */
  134012. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  134013. /**
  134014. * Returns the data related to the vortex event (cylinder).
  134015. * @returns The physics vortex event data
  134016. */
  134017. getData(): PhysicsVortexEventData;
  134018. /**
  134019. * Enables the vortex.
  134020. */
  134021. enable(): void;
  134022. /**
  134023. * Disables the cortex.
  134024. */
  134025. disable(): void;
  134026. /**
  134027. * Disposes the sphere.
  134028. * @param force
  134029. */
  134030. dispose(force?: boolean): void;
  134031. private getImpostorHitData;
  134032. private _tick;
  134033. /*** Helpers ***/
  134034. private _prepareCylinder;
  134035. private _intersectsWithCylinder;
  134036. }
  134037. /**
  134038. * Options fot the radial explosion event
  134039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134040. */
  134041. export class PhysicsRadialExplosionEventOptions {
  134042. /**
  134043. * The radius of the sphere for the radial explosion.
  134044. */
  134045. radius: number;
  134046. /**
  134047. * The strenth of the explosion.
  134048. */
  134049. strength: number;
  134050. /**
  134051. * The strenght of the force in correspondence to the distance of the affected object
  134052. */
  134053. falloff: PhysicsRadialImpulseFalloff;
  134054. /**
  134055. * Sphere options for the radial explosion.
  134056. */
  134057. sphere: {
  134058. segments: number;
  134059. diameter: number;
  134060. };
  134061. /**
  134062. * Sphere options for the radial explosion.
  134063. */
  134064. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  134065. }
  134066. /**
  134067. * Options fot the updraft event
  134068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134069. */
  134070. export class PhysicsUpdraftEventOptions {
  134071. /**
  134072. * The radius of the cylinder for the vortex
  134073. */
  134074. radius: number;
  134075. /**
  134076. * The strenth of the updraft.
  134077. */
  134078. strength: number;
  134079. /**
  134080. * The height of the cylinder for the updraft.
  134081. */
  134082. height: number;
  134083. /**
  134084. * The mode for the the updraft.
  134085. */
  134086. updraftMode: PhysicsUpdraftMode;
  134087. }
  134088. /**
  134089. * Options fot the vortex event
  134090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134091. */
  134092. export class PhysicsVortexEventOptions {
  134093. /**
  134094. * The radius of the cylinder for the vortex
  134095. */
  134096. radius: number;
  134097. /**
  134098. * The strenth of the vortex.
  134099. */
  134100. strength: number;
  134101. /**
  134102. * The height of the cylinder for the vortex.
  134103. */
  134104. height: number;
  134105. /**
  134106. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  134107. */
  134108. centripetalForceThreshold: number;
  134109. /**
  134110. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  134111. */
  134112. centripetalForceMultiplier: number;
  134113. /**
  134114. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  134115. */
  134116. centrifugalForceMultiplier: number;
  134117. /**
  134118. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  134119. */
  134120. updraftForceMultiplier: number;
  134121. }
  134122. /**
  134123. * The strenght of the force in correspondence to the distance of the affected object
  134124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134125. */
  134126. export enum PhysicsRadialImpulseFalloff {
  134127. /** Defines that impulse is constant in strength across it's whole radius */
  134128. Constant = 0,
  134129. /** Defines that impulse gets weaker if it's further from the origin */
  134130. Linear = 1
  134131. }
  134132. /**
  134133. * The strength of the force in correspondence to the distance of the affected object
  134134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134135. */
  134136. export enum PhysicsUpdraftMode {
  134137. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  134138. Center = 0,
  134139. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  134140. Perpendicular = 1
  134141. }
  134142. /**
  134143. * Interface for a physics hit data
  134144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134145. */
  134146. export interface PhysicsHitData {
  134147. /**
  134148. * The force applied at the contact point
  134149. */
  134150. force: Vector3;
  134151. /**
  134152. * The contact point
  134153. */
  134154. contactPoint: Vector3;
  134155. /**
  134156. * The distance from the origin to the contact point
  134157. */
  134158. distanceFromOrigin: number;
  134159. }
  134160. /**
  134161. * Interface for radial explosion event data
  134162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134163. */
  134164. export interface PhysicsRadialExplosionEventData {
  134165. /**
  134166. * A sphere used for the radial explosion event
  134167. */
  134168. sphere: Mesh;
  134169. }
  134170. /**
  134171. * Interface for gravitational field event data
  134172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134173. */
  134174. export interface PhysicsGravitationalFieldEventData {
  134175. /**
  134176. * A sphere mesh used for the gravitational field event
  134177. */
  134178. sphere: Mesh;
  134179. }
  134180. /**
  134181. * Interface for updraft event data
  134182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134183. */
  134184. export interface PhysicsUpdraftEventData {
  134185. /**
  134186. * A cylinder used for the updraft event
  134187. */
  134188. cylinder: Mesh;
  134189. }
  134190. /**
  134191. * Interface for vortex event data
  134192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134193. */
  134194. export interface PhysicsVortexEventData {
  134195. /**
  134196. * A cylinder used for the vortex event
  134197. */
  134198. cylinder: Mesh;
  134199. }
  134200. /**
  134201. * Interface for an affected physics impostor
  134202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134203. */
  134204. export interface PhysicsAffectedImpostorWithData {
  134205. /**
  134206. * The impostor affected by the effect
  134207. */
  134208. impostor: PhysicsImpostor;
  134209. /**
  134210. * The data about the hit/horce from the explosion
  134211. */
  134212. hitData: PhysicsHitData;
  134213. }
  134214. }
  134215. declare module BABYLON {
  134216. /** @hidden */
  134217. export var blackAndWhitePixelShader: {
  134218. name: string;
  134219. shader: string;
  134220. };
  134221. }
  134222. declare module BABYLON {
  134223. /**
  134224. * Post process used to render in black and white
  134225. */
  134226. export class BlackAndWhitePostProcess extends PostProcess {
  134227. /**
  134228. * Linear about to convert he result to black and white (default: 1)
  134229. */
  134230. degree: number;
  134231. /**
  134232. * Creates a black and white post process
  134233. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  134234. * @param name The name of the effect.
  134235. * @param options The required width/height ratio to downsize to before computing the render pass.
  134236. * @param camera The camera to apply the render pass to.
  134237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134238. * @param engine The engine which the post process will be applied. (default: current engine)
  134239. * @param reusable If the post process can be reused on the same frame. (default: false)
  134240. */
  134241. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  134242. }
  134243. }
  134244. declare module BABYLON {
  134245. /**
  134246. * This represents a set of one or more post processes in Babylon.
  134247. * A post process can be used to apply a shader to a texture after it is rendered.
  134248. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  134249. */
  134250. export class PostProcessRenderEffect {
  134251. private _postProcesses;
  134252. private _getPostProcesses;
  134253. private _singleInstance;
  134254. private _cameras;
  134255. private _indicesForCamera;
  134256. /**
  134257. * Name of the effect
  134258. * @hidden
  134259. */
  134260. _name: string;
  134261. /**
  134262. * Instantiates a post process render effect.
  134263. * A post process can be used to apply a shader to a texture after it is rendered.
  134264. * @param engine The engine the effect is tied to
  134265. * @param name The name of the effect
  134266. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  134267. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  134268. */
  134269. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  134270. /**
  134271. * Checks if all the post processes in the effect are supported.
  134272. */
  134273. get isSupported(): boolean;
  134274. /**
  134275. * Updates the current state of the effect
  134276. * @hidden
  134277. */
  134278. _update(): void;
  134279. /**
  134280. * Attaches the effect on cameras
  134281. * @param cameras The camera to attach to.
  134282. * @hidden
  134283. */
  134284. _attachCameras(cameras: Camera): void;
  134285. /**
  134286. * Attaches the effect on cameras
  134287. * @param cameras The camera to attach to.
  134288. * @hidden
  134289. */
  134290. _attachCameras(cameras: Camera[]): void;
  134291. /**
  134292. * Detaches the effect on cameras
  134293. * @param cameras The camera to detatch from.
  134294. * @hidden
  134295. */
  134296. _detachCameras(cameras: Camera): void;
  134297. /**
  134298. * Detatches the effect on cameras
  134299. * @param cameras The camera to detatch from.
  134300. * @hidden
  134301. */
  134302. _detachCameras(cameras: Camera[]): void;
  134303. /**
  134304. * Enables the effect on given cameras
  134305. * @param cameras The camera to enable.
  134306. * @hidden
  134307. */
  134308. _enable(cameras: Camera): void;
  134309. /**
  134310. * Enables the effect on given cameras
  134311. * @param cameras The camera to enable.
  134312. * @hidden
  134313. */
  134314. _enable(cameras: Nullable<Camera[]>): void;
  134315. /**
  134316. * Disables the effect on the given cameras
  134317. * @param cameras The camera to disable.
  134318. * @hidden
  134319. */
  134320. _disable(cameras: Camera): void;
  134321. /**
  134322. * Disables the effect on the given cameras
  134323. * @param cameras The camera to disable.
  134324. * @hidden
  134325. */
  134326. _disable(cameras: Nullable<Camera[]>): void;
  134327. /**
  134328. * Gets a list of the post processes contained in the effect.
  134329. * @param camera The camera to get the post processes on.
  134330. * @returns The list of the post processes in the effect.
  134331. */
  134332. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  134333. }
  134334. }
  134335. declare module BABYLON {
  134336. /** @hidden */
  134337. export var extractHighlightsPixelShader: {
  134338. name: string;
  134339. shader: string;
  134340. };
  134341. }
  134342. declare module BABYLON {
  134343. /**
  134344. * 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.
  134345. */
  134346. export class ExtractHighlightsPostProcess extends PostProcess {
  134347. /**
  134348. * The luminance threshold, pixels below this value will be set to black.
  134349. */
  134350. threshold: number;
  134351. /** @hidden */
  134352. _exposure: number;
  134353. /**
  134354. * Post process which has the input texture to be used when performing highlight extraction
  134355. * @hidden
  134356. */
  134357. _inputPostProcess: Nullable<PostProcess>;
  134358. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134359. }
  134360. }
  134361. declare module BABYLON {
  134362. /** @hidden */
  134363. export var bloomMergePixelShader: {
  134364. name: string;
  134365. shader: string;
  134366. };
  134367. }
  134368. declare module BABYLON {
  134369. /**
  134370. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  134371. */
  134372. export class BloomMergePostProcess extends PostProcess {
  134373. /** Weight of the bloom to be added to the original input. */
  134374. weight: number;
  134375. /**
  134376. * Creates a new instance of @see BloomMergePostProcess
  134377. * @param name The name of the effect.
  134378. * @param originalFromInput Post process which's input will be used for the merge.
  134379. * @param blurred Blurred highlights post process which's output will be used.
  134380. * @param weight Weight of the bloom to be added to the original input.
  134381. * @param options The required width/height ratio to downsize to before computing the render pass.
  134382. * @param camera The camera to apply the render pass to.
  134383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134384. * @param engine The engine which the post process will be applied. (default: current engine)
  134385. * @param reusable If the post process can be reused on the same frame. (default: false)
  134386. * @param textureType Type of textures used when performing the post process. (default: 0)
  134387. * @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)
  134388. */
  134389. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  134390. /** Weight of the bloom to be added to the original input. */
  134391. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134392. }
  134393. }
  134394. declare module BABYLON {
  134395. /**
  134396. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  134397. */
  134398. export class BloomEffect extends PostProcessRenderEffect {
  134399. private bloomScale;
  134400. /**
  134401. * @hidden Internal
  134402. */
  134403. _effects: Array<PostProcess>;
  134404. /**
  134405. * @hidden Internal
  134406. */
  134407. _downscale: ExtractHighlightsPostProcess;
  134408. private _blurX;
  134409. private _blurY;
  134410. private _merge;
  134411. /**
  134412. * The luminance threshold to find bright areas of the image to bloom.
  134413. */
  134414. get threshold(): number;
  134415. set threshold(value: number);
  134416. /**
  134417. * The strength of the bloom.
  134418. */
  134419. get weight(): number;
  134420. set weight(value: number);
  134421. /**
  134422. * Specifies the size of the bloom blur kernel, relative to the final output size
  134423. */
  134424. get kernel(): number;
  134425. set kernel(value: number);
  134426. /**
  134427. * Creates a new instance of @see BloomEffect
  134428. * @param scene The scene the effect belongs to.
  134429. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  134430. * @param bloomKernel The size of the kernel to be used when applying the blur.
  134431. * @param bloomWeight The the strength of bloom.
  134432. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  134433. * @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)
  134434. */
  134435. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  134436. /**
  134437. * Disposes each of the internal effects for a given camera.
  134438. * @param camera The camera to dispose the effect on.
  134439. */
  134440. disposeEffects(camera: Camera): void;
  134441. /**
  134442. * @hidden Internal
  134443. */
  134444. _updateEffects(): void;
  134445. /**
  134446. * Internal
  134447. * @returns if all the contained post processes are ready.
  134448. * @hidden
  134449. */
  134450. _isReady(): boolean;
  134451. }
  134452. }
  134453. declare module BABYLON {
  134454. /** @hidden */
  134455. export var chromaticAberrationPixelShader: {
  134456. name: string;
  134457. shader: string;
  134458. };
  134459. }
  134460. declare module BABYLON {
  134461. /**
  134462. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  134463. */
  134464. export class ChromaticAberrationPostProcess extends PostProcess {
  134465. /**
  134466. * The amount of seperation of rgb channels (default: 30)
  134467. */
  134468. aberrationAmount: number;
  134469. /**
  134470. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  134471. */
  134472. radialIntensity: number;
  134473. /**
  134474. * 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))
  134475. */
  134476. direction: Vector2;
  134477. /**
  134478. * 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))
  134479. */
  134480. centerPosition: Vector2;
  134481. /**
  134482. * Creates a new instance ChromaticAberrationPostProcess
  134483. * @param name The name of the effect.
  134484. * @param screenWidth The width of the screen to apply the effect on.
  134485. * @param screenHeight The height of the screen to apply the effect on.
  134486. * @param options The required width/height ratio to downsize to before computing the render pass.
  134487. * @param camera The camera to apply the render pass to.
  134488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134489. * @param engine The engine which the post process will be applied. (default: current engine)
  134490. * @param reusable If the post process can be reused on the same frame. (default: false)
  134491. * @param textureType Type of textures used when performing the post process. (default: 0)
  134492. * @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)
  134493. */
  134494. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134495. }
  134496. }
  134497. declare module BABYLON {
  134498. /** @hidden */
  134499. export var circleOfConfusionPixelShader: {
  134500. name: string;
  134501. shader: string;
  134502. };
  134503. }
  134504. declare module BABYLON {
  134505. /**
  134506. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  134507. */
  134508. export class CircleOfConfusionPostProcess extends PostProcess {
  134509. /**
  134510. * 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.
  134511. */
  134512. lensSize: number;
  134513. /**
  134514. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  134515. */
  134516. fStop: number;
  134517. /**
  134518. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  134519. */
  134520. focusDistance: number;
  134521. /**
  134522. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  134523. */
  134524. focalLength: number;
  134525. private _depthTexture;
  134526. /**
  134527. * Creates a new instance CircleOfConfusionPostProcess
  134528. * @param name The name of the effect.
  134529. * @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.
  134530. * @param options The required width/height ratio to downsize to before computing the render pass.
  134531. * @param camera The camera to apply the render pass to.
  134532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134533. * @param engine The engine which the post process will be applied. (default: current engine)
  134534. * @param reusable If the post process can be reused on the same frame. (default: false)
  134535. * @param textureType Type of textures used when performing the post process. (default: 0)
  134536. * @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)
  134537. */
  134538. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134539. /**
  134540. * 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.
  134541. */
  134542. set depthTexture(value: RenderTargetTexture);
  134543. }
  134544. }
  134545. declare module BABYLON {
  134546. /** @hidden */
  134547. export var colorCorrectionPixelShader: {
  134548. name: string;
  134549. shader: string;
  134550. };
  134551. }
  134552. declare module BABYLON {
  134553. /**
  134554. *
  134555. * This post-process allows the modification of rendered colors by using
  134556. * a 'look-up table' (LUT). This effect is also called Color Grading.
  134557. *
  134558. * The object needs to be provided an url to a texture containing the color
  134559. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  134560. * Use an image editing software to tweak the LUT to match your needs.
  134561. *
  134562. * For an example of a color LUT, see here:
  134563. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  134564. * For explanations on color grading, see here:
  134565. * @see http://udn.epicgames.com/Three/ColorGrading.html
  134566. *
  134567. */
  134568. export class ColorCorrectionPostProcess extends PostProcess {
  134569. private _colorTableTexture;
  134570. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  134571. }
  134572. }
  134573. declare module BABYLON {
  134574. /** @hidden */
  134575. export var convolutionPixelShader: {
  134576. name: string;
  134577. shader: string;
  134578. };
  134579. }
  134580. declare module BABYLON {
  134581. /**
  134582. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  134583. * input texture to perform effects such as edge detection or sharpening
  134584. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  134585. */
  134586. export class ConvolutionPostProcess extends PostProcess {
  134587. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  134588. kernel: number[];
  134589. /**
  134590. * Creates a new instance ConvolutionPostProcess
  134591. * @param name The name of the effect.
  134592. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  134593. * @param options The required width/height ratio to downsize to before computing the render pass.
  134594. * @param camera The camera to apply the render pass to.
  134595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134596. * @param engine The engine which the post process will be applied. (default: current engine)
  134597. * @param reusable If the post process can be reused on the same frame. (default: false)
  134598. * @param textureType Type of textures used when performing the post process. (default: 0)
  134599. */
  134600. constructor(name: string,
  134601. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  134602. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  134603. /**
  134604. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134605. */
  134606. static EdgeDetect0Kernel: number[];
  134607. /**
  134608. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134609. */
  134610. static EdgeDetect1Kernel: number[];
  134611. /**
  134612. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134613. */
  134614. static EdgeDetect2Kernel: number[];
  134615. /**
  134616. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134617. */
  134618. static SharpenKernel: number[];
  134619. /**
  134620. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134621. */
  134622. static EmbossKernel: number[];
  134623. /**
  134624. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134625. */
  134626. static GaussianKernel: number[];
  134627. }
  134628. }
  134629. declare module BABYLON {
  134630. /**
  134631. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  134632. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  134633. * based on samples that have a large difference in distance than the center pixel.
  134634. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  134635. */
  134636. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  134637. direction: Vector2;
  134638. /**
  134639. * Creates a new instance CircleOfConfusionPostProcess
  134640. * @param name The name of the effect.
  134641. * @param scene The scene the effect belongs to.
  134642. * @param direction The direction the blur should be applied.
  134643. * @param kernel The size of the kernel used to blur.
  134644. * @param options The required width/height ratio to downsize to before computing the render pass.
  134645. * @param camera The camera to apply the render pass to.
  134646. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  134647. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  134648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134649. * @param engine The engine which the post process will be applied. (default: current engine)
  134650. * @param reusable If the post process can be reused on the same frame. (default: false)
  134651. * @param textureType Type of textures used when performing the post process. (default: 0)
  134652. * @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)
  134653. */
  134654. 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);
  134655. }
  134656. }
  134657. declare module BABYLON {
  134658. /** @hidden */
  134659. export var depthOfFieldMergePixelShader: {
  134660. name: string;
  134661. shader: string;
  134662. };
  134663. }
  134664. declare module BABYLON {
  134665. /**
  134666. * Options to be set when merging outputs from the default pipeline.
  134667. */
  134668. export class DepthOfFieldMergePostProcessOptions {
  134669. /**
  134670. * The original image to merge on top of
  134671. */
  134672. originalFromInput: PostProcess;
  134673. /**
  134674. * Parameters to perform the merge of the depth of field effect
  134675. */
  134676. depthOfField?: {
  134677. circleOfConfusion: PostProcess;
  134678. blurSteps: Array<PostProcess>;
  134679. };
  134680. /**
  134681. * Parameters to perform the merge of bloom effect
  134682. */
  134683. bloom?: {
  134684. blurred: PostProcess;
  134685. weight: number;
  134686. };
  134687. }
  134688. /**
  134689. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  134690. */
  134691. export class DepthOfFieldMergePostProcess extends PostProcess {
  134692. private blurSteps;
  134693. /**
  134694. * Creates a new instance of DepthOfFieldMergePostProcess
  134695. * @param name The name of the effect.
  134696. * @param originalFromInput Post process which's input will be used for the merge.
  134697. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  134698. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  134699. * @param options The required width/height ratio to downsize to before computing the render pass.
  134700. * @param camera The camera to apply the render pass to.
  134701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134702. * @param engine The engine which the post process will be applied. (default: current engine)
  134703. * @param reusable If the post process can be reused on the same frame. (default: false)
  134704. * @param textureType Type of textures used when performing the post process. (default: 0)
  134705. * @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)
  134706. */
  134707. 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);
  134708. /**
  134709. * Updates the effect with the current post process compile time values and recompiles the shader.
  134710. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  134711. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  134712. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  134713. * @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
  134714. * @param onCompiled Called when the shader has been compiled.
  134715. * @param onError Called if there is an error when compiling a shader.
  134716. */
  134717. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  134718. }
  134719. }
  134720. declare module BABYLON {
  134721. /**
  134722. * Specifies the level of max blur that should be applied when using the depth of field effect
  134723. */
  134724. export enum DepthOfFieldEffectBlurLevel {
  134725. /**
  134726. * Subtle blur
  134727. */
  134728. Low = 0,
  134729. /**
  134730. * Medium blur
  134731. */
  134732. Medium = 1,
  134733. /**
  134734. * Large blur
  134735. */
  134736. High = 2
  134737. }
  134738. /**
  134739. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  134740. */
  134741. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  134742. private _circleOfConfusion;
  134743. /**
  134744. * @hidden Internal, blurs from high to low
  134745. */
  134746. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  134747. private _depthOfFieldBlurY;
  134748. private _dofMerge;
  134749. /**
  134750. * @hidden Internal post processes in depth of field effect
  134751. */
  134752. _effects: Array<PostProcess>;
  134753. /**
  134754. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  134755. */
  134756. set focalLength(value: number);
  134757. get focalLength(): number;
  134758. /**
  134759. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  134760. */
  134761. set fStop(value: number);
  134762. get fStop(): number;
  134763. /**
  134764. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  134765. */
  134766. set focusDistance(value: number);
  134767. get focusDistance(): number;
  134768. /**
  134769. * 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.
  134770. */
  134771. set lensSize(value: number);
  134772. get lensSize(): number;
  134773. /**
  134774. * Creates a new instance DepthOfFieldEffect
  134775. * @param scene The scene the effect belongs to.
  134776. * @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.
  134777. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  134778. * @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)
  134779. */
  134780. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  134781. /**
  134782. * Get the current class name of the current effet
  134783. * @returns "DepthOfFieldEffect"
  134784. */
  134785. getClassName(): string;
  134786. /**
  134787. * 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.
  134788. */
  134789. set depthTexture(value: RenderTargetTexture);
  134790. /**
  134791. * Disposes each of the internal effects for a given camera.
  134792. * @param camera The camera to dispose the effect on.
  134793. */
  134794. disposeEffects(camera: Camera): void;
  134795. /**
  134796. * @hidden Internal
  134797. */
  134798. _updateEffects(): void;
  134799. /**
  134800. * Internal
  134801. * @returns if all the contained post processes are ready.
  134802. * @hidden
  134803. */
  134804. _isReady(): boolean;
  134805. }
  134806. }
  134807. declare module BABYLON {
  134808. /** @hidden */
  134809. export var displayPassPixelShader: {
  134810. name: string;
  134811. shader: string;
  134812. };
  134813. }
  134814. declare module BABYLON {
  134815. /**
  134816. * DisplayPassPostProcess which produces an output the same as it's input
  134817. */
  134818. export class DisplayPassPostProcess extends PostProcess {
  134819. /**
  134820. * Creates the DisplayPassPostProcess
  134821. * @param name The name of the effect.
  134822. * @param options The required width/height ratio to downsize to before computing the render pass.
  134823. * @param camera The camera to apply the render pass to.
  134824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134825. * @param engine The engine which the post process will be applied. (default: current engine)
  134826. * @param reusable If the post process can be reused on the same frame. (default: false)
  134827. */
  134828. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  134829. }
  134830. }
  134831. declare module BABYLON {
  134832. /** @hidden */
  134833. export var filterPixelShader: {
  134834. name: string;
  134835. shader: string;
  134836. };
  134837. }
  134838. declare module BABYLON {
  134839. /**
  134840. * Applies a kernel filter to the image
  134841. */
  134842. export class FilterPostProcess extends PostProcess {
  134843. /** The matrix to be applied to the image */
  134844. kernelMatrix: Matrix;
  134845. /**
  134846. *
  134847. * @param name The name of the effect.
  134848. * @param kernelMatrix The matrix to be applied to the image
  134849. * @param options The required width/height ratio to downsize to before computing the render pass.
  134850. * @param camera The camera to apply the render pass to.
  134851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134852. * @param engine The engine which the post process will be applied. (default: current engine)
  134853. * @param reusable If the post process can be reused on the same frame. (default: false)
  134854. */
  134855. constructor(name: string,
  134856. /** The matrix to be applied to the image */
  134857. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  134858. }
  134859. }
  134860. declare module BABYLON {
  134861. /** @hidden */
  134862. export var fxaaPixelShader: {
  134863. name: string;
  134864. shader: string;
  134865. };
  134866. }
  134867. declare module BABYLON {
  134868. /** @hidden */
  134869. export var fxaaVertexShader: {
  134870. name: string;
  134871. shader: string;
  134872. };
  134873. }
  134874. declare module BABYLON {
  134875. /**
  134876. * Fxaa post process
  134877. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  134878. */
  134879. export class FxaaPostProcess extends PostProcess {
  134880. /** @hidden */
  134881. texelWidth: number;
  134882. /** @hidden */
  134883. texelHeight: number;
  134884. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  134885. private _getDefines;
  134886. }
  134887. }
  134888. declare module BABYLON {
  134889. /** @hidden */
  134890. export var grainPixelShader: {
  134891. name: string;
  134892. shader: string;
  134893. };
  134894. }
  134895. declare module BABYLON {
  134896. /**
  134897. * The GrainPostProcess adds noise to the image at mid luminance levels
  134898. */
  134899. export class GrainPostProcess extends PostProcess {
  134900. /**
  134901. * The intensity of the grain added (default: 30)
  134902. */
  134903. intensity: number;
  134904. /**
  134905. * If the grain should be randomized on every frame
  134906. */
  134907. animated: boolean;
  134908. /**
  134909. * Creates a new instance of @see GrainPostProcess
  134910. * @param name The name of the effect.
  134911. * @param options The required width/height ratio to downsize to before computing the render pass.
  134912. * @param camera The camera to apply the render pass to.
  134913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134914. * @param engine The engine which the post process will be applied. (default: current engine)
  134915. * @param reusable If the post process can be reused on the same frame. (default: false)
  134916. * @param textureType Type of textures used when performing the post process. (default: 0)
  134917. * @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)
  134918. */
  134919. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134920. }
  134921. }
  134922. declare module BABYLON {
  134923. /** @hidden */
  134924. export var highlightsPixelShader: {
  134925. name: string;
  134926. shader: string;
  134927. };
  134928. }
  134929. declare module BABYLON {
  134930. /**
  134931. * Extracts highlights from the image
  134932. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  134933. */
  134934. export class HighlightsPostProcess extends PostProcess {
  134935. /**
  134936. * Extracts highlights from the image
  134937. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  134938. * @param name The name of the effect.
  134939. * @param options The required width/height ratio to downsize to before computing the render pass.
  134940. * @param camera The camera to apply the render pass to.
  134941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134942. * @param engine The engine which the post process will be applied. (default: current engine)
  134943. * @param reusable If the post process can be reused on the same frame. (default: false)
  134944. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  134945. */
  134946. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  134947. }
  134948. }
  134949. declare module BABYLON {
  134950. /** @hidden */
  134951. export var mrtFragmentDeclaration: {
  134952. name: string;
  134953. shader: string;
  134954. };
  134955. }
  134956. declare module BABYLON {
  134957. /** @hidden */
  134958. export var geometryPixelShader: {
  134959. name: string;
  134960. shader: string;
  134961. };
  134962. }
  134963. declare module BABYLON {
  134964. /** @hidden */
  134965. export var geometryVertexShader: {
  134966. name: string;
  134967. shader: string;
  134968. };
  134969. }
  134970. declare module BABYLON {
  134971. /** @hidden */
  134972. interface ISavedTransformationMatrix {
  134973. world: Matrix;
  134974. viewProjection: Matrix;
  134975. }
  134976. /**
  134977. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  134978. */
  134979. export class GeometryBufferRenderer {
  134980. /**
  134981. * Constant used to retrieve the position texture index in the G-Buffer textures array
  134982. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  134983. */
  134984. static readonly POSITION_TEXTURE_TYPE: number;
  134985. /**
  134986. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  134987. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  134988. */
  134989. static readonly VELOCITY_TEXTURE_TYPE: number;
  134990. /**
  134991. * Dictionary used to store the previous transformation matrices of each rendered mesh
  134992. * in order to compute objects velocities when enableVelocity is set to "true"
  134993. * @hidden
  134994. */
  134995. _previousTransformationMatrices: {
  134996. [index: number]: ISavedTransformationMatrix;
  134997. };
  134998. /**
  134999. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  135000. * in order to compute objects velocities when enableVelocity is set to "true"
  135001. * @hidden
  135002. */
  135003. _previousBonesTransformationMatrices: {
  135004. [index: number]: Float32Array;
  135005. };
  135006. /**
  135007. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  135008. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  135009. */
  135010. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  135011. private _scene;
  135012. private _multiRenderTarget;
  135013. private _ratio;
  135014. private _enablePosition;
  135015. private _enableVelocity;
  135016. private _positionIndex;
  135017. private _velocityIndex;
  135018. protected _effect: Effect;
  135019. protected _cachedDefines: string;
  135020. /**
  135021. * Set the render list (meshes to be rendered) used in the G buffer.
  135022. */
  135023. set renderList(meshes: Mesh[]);
  135024. /**
  135025. * Gets wether or not G buffer are supported by the running hardware.
  135026. * This requires draw buffer supports
  135027. */
  135028. get isSupported(): boolean;
  135029. /**
  135030. * Returns the index of the given texture type in the G-Buffer textures array
  135031. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  135032. * @returns the index of the given texture type in the G-Buffer textures array
  135033. */
  135034. getTextureIndex(textureType: number): number;
  135035. /**
  135036. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  135037. */
  135038. get enablePosition(): boolean;
  135039. /**
  135040. * Sets whether or not objects positions are enabled for the G buffer.
  135041. */
  135042. set enablePosition(enable: boolean);
  135043. /**
  135044. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  135045. */
  135046. get enableVelocity(): boolean;
  135047. /**
  135048. * Sets wether or not objects velocities are enabled for the G buffer.
  135049. */
  135050. set enableVelocity(enable: boolean);
  135051. /**
  135052. * Gets the scene associated with the buffer.
  135053. */
  135054. get scene(): Scene;
  135055. /**
  135056. * Gets the ratio used by the buffer during its creation.
  135057. * How big is the buffer related to the main canvas.
  135058. */
  135059. get ratio(): number;
  135060. /** @hidden */
  135061. static _SceneComponentInitialization: (scene: Scene) => void;
  135062. /**
  135063. * Creates a new G Buffer for the scene
  135064. * @param scene The scene the buffer belongs to
  135065. * @param ratio How big is the buffer related to the main canvas.
  135066. */
  135067. constructor(scene: Scene, ratio?: number);
  135068. /**
  135069. * Checks wether everything is ready to render a submesh to the G buffer.
  135070. * @param subMesh the submesh to check readiness for
  135071. * @param useInstances is the mesh drawn using instance or not
  135072. * @returns true if ready otherwise false
  135073. */
  135074. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135075. /**
  135076. * Gets the current underlying G Buffer.
  135077. * @returns the buffer
  135078. */
  135079. getGBuffer(): MultiRenderTarget;
  135080. /**
  135081. * Gets the number of samples used to render the buffer (anti aliasing).
  135082. */
  135083. get samples(): number;
  135084. /**
  135085. * Sets the number of samples used to render the buffer (anti aliasing).
  135086. */
  135087. set samples(value: number);
  135088. /**
  135089. * Disposes the renderer and frees up associated resources.
  135090. */
  135091. dispose(): void;
  135092. protected _createRenderTargets(): void;
  135093. private _copyBonesTransformationMatrices;
  135094. }
  135095. }
  135096. declare module BABYLON {
  135097. interface Scene {
  135098. /** @hidden (Backing field) */
  135099. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  135100. /**
  135101. * Gets or Sets the current geometry buffer associated to the scene.
  135102. */
  135103. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  135104. /**
  135105. * Enables a GeometryBufferRender and associates it with the scene
  135106. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  135107. * @returns the GeometryBufferRenderer
  135108. */
  135109. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  135110. /**
  135111. * Disables the GeometryBufferRender associated with the scene
  135112. */
  135113. disableGeometryBufferRenderer(): void;
  135114. }
  135115. /**
  135116. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  135117. * in several rendering techniques.
  135118. */
  135119. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  135120. /**
  135121. * The component name helpful to identify the component in the list of scene components.
  135122. */
  135123. readonly name: string;
  135124. /**
  135125. * The scene the component belongs to.
  135126. */
  135127. scene: Scene;
  135128. /**
  135129. * Creates a new instance of the component for the given scene
  135130. * @param scene Defines the scene to register the component in
  135131. */
  135132. constructor(scene: Scene);
  135133. /**
  135134. * Registers the component in a given scene
  135135. */
  135136. register(): void;
  135137. /**
  135138. * Rebuilds the elements related to this component in case of
  135139. * context lost for instance.
  135140. */
  135141. rebuild(): void;
  135142. /**
  135143. * Disposes the component and the associated ressources
  135144. */
  135145. dispose(): void;
  135146. private _gatherRenderTargets;
  135147. }
  135148. }
  135149. declare module BABYLON {
  135150. /** @hidden */
  135151. export var motionBlurPixelShader: {
  135152. name: string;
  135153. shader: string;
  135154. };
  135155. }
  135156. declare module BABYLON {
  135157. /**
  135158. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  135159. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  135160. * As an example, all you have to do is to create the post-process:
  135161. * var mb = new BABYLON.MotionBlurPostProcess(
  135162. * 'mb', // The name of the effect.
  135163. * scene, // The scene containing the objects to blur according to their velocity.
  135164. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  135165. * camera // The camera to apply the render pass to.
  135166. * );
  135167. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  135168. */
  135169. export class MotionBlurPostProcess extends PostProcess {
  135170. /**
  135171. * Defines how much the image is blurred by the movement. Default value is equal to 1
  135172. */
  135173. motionStrength: number;
  135174. /**
  135175. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  135176. */
  135177. get motionBlurSamples(): number;
  135178. /**
  135179. * Sets the number of iterations to be used for motion blur quality
  135180. */
  135181. set motionBlurSamples(samples: number);
  135182. private _motionBlurSamples;
  135183. private _geometryBufferRenderer;
  135184. /**
  135185. * Creates a new instance MotionBlurPostProcess
  135186. * @param name The name of the effect.
  135187. * @param scene The scene containing the objects to blur according to their velocity.
  135188. * @param options The required width/height ratio to downsize to before computing the render pass.
  135189. * @param camera The camera to apply the render pass to.
  135190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135191. * @param engine The engine which the post process will be applied. (default: current engine)
  135192. * @param reusable If the post process can be reused on the same frame. (default: false)
  135193. * @param textureType Type of textures used when performing the post process. (default: 0)
  135194. * @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)
  135195. */
  135196. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  135197. /**
  135198. * Excludes the given skinned mesh from computing bones velocities.
  135199. * 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.
  135200. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  135201. */
  135202. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  135203. /**
  135204. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  135205. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  135206. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  135207. */
  135208. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  135209. /**
  135210. * Disposes the post process.
  135211. * @param camera The camera to dispose the post process on.
  135212. */
  135213. dispose(camera?: Camera): void;
  135214. }
  135215. }
  135216. declare module BABYLON {
  135217. /** @hidden */
  135218. export var refractionPixelShader: {
  135219. name: string;
  135220. shader: string;
  135221. };
  135222. }
  135223. declare module BABYLON {
  135224. /**
  135225. * Post process which applies a refractin texture
  135226. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  135227. */
  135228. export class RefractionPostProcess extends PostProcess {
  135229. /** the base color of the refraction (used to taint the rendering) */
  135230. color: Color3;
  135231. /** simulated refraction depth */
  135232. depth: number;
  135233. /** the coefficient of the base color (0 to remove base color tainting) */
  135234. colorLevel: number;
  135235. private _refTexture;
  135236. private _ownRefractionTexture;
  135237. /**
  135238. * Gets or sets the refraction texture
  135239. * Please note that you are responsible for disposing the texture if you set it manually
  135240. */
  135241. get refractionTexture(): Texture;
  135242. set refractionTexture(value: Texture);
  135243. /**
  135244. * Initializes the RefractionPostProcess
  135245. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  135246. * @param name The name of the effect.
  135247. * @param refractionTextureUrl Url of the refraction texture to use
  135248. * @param color the base color of the refraction (used to taint the rendering)
  135249. * @param depth simulated refraction depth
  135250. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  135251. * @param camera The camera to apply the render pass to.
  135252. * @param options The required width/height ratio to downsize to before computing the render pass.
  135253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135254. * @param engine The engine which the post process will be applied. (default: current engine)
  135255. * @param reusable If the post process can be reused on the same frame. (default: false)
  135256. */
  135257. constructor(name: string, refractionTextureUrl: string,
  135258. /** the base color of the refraction (used to taint the rendering) */
  135259. color: Color3,
  135260. /** simulated refraction depth */
  135261. depth: number,
  135262. /** the coefficient of the base color (0 to remove base color tainting) */
  135263. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  135264. /**
  135265. * Disposes of the post process
  135266. * @param camera Camera to dispose post process on
  135267. */
  135268. dispose(camera: Camera): void;
  135269. }
  135270. }
  135271. declare module BABYLON {
  135272. /** @hidden */
  135273. export var sharpenPixelShader: {
  135274. name: string;
  135275. shader: string;
  135276. };
  135277. }
  135278. declare module BABYLON {
  135279. /**
  135280. * The SharpenPostProcess applies a sharpen kernel to every pixel
  135281. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  135282. */
  135283. export class SharpenPostProcess extends PostProcess {
  135284. /**
  135285. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  135286. */
  135287. colorAmount: number;
  135288. /**
  135289. * How much sharpness should be applied (default: 0.3)
  135290. */
  135291. edgeAmount: number;
  135292. /**
  135293. * Creates a new instance ConvolutionPostProcess
  135294. * @param name The name of the effect.
  135295. * @param options The required width/height ratio to downsize to before computing the render pass.
  135296. * @param camera The camera to apply the render pass to.
  135297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135298. * @param engine The engine which the post process will be applied. (default: current engine)
  135299. * @param reusable If the post process can be reused on the same frame. (default: false)
  135300. * @param textureType Type of textures used when performing the post process. (default: 0)
  135301. * @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)
  135302. */
  135303. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  135304. }
  135305. }
  135306. declare module BABYLON {
  135307. /**
  135308. * PostProcessRenderPipeline
  135309. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  135310. */
  135311. export class PostProcessRenderPipeline {
  135312. private engine;
  135313. private _renderEffects;
  135314. private _renderEffectsForIsolatedPass;
  135315. /**
  135316. * List of inspectable custom properties (used by the Inspector)
  135317. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  135318. */
  135319. inspectableCustomProperties: IInspectable[];
  135320. /**
  135321. * @hidden
  135322. */
  135323. protected _cameras: Camera[];
  135324. /** @hidden */
  135325. _name: string;
  135326. /**
  135327. * Gets pipeline name
  135328. */
  135329. get name(): string;
  135330. /** Gets the list of attached cameras */
  135331. get cameras(): Camera[];
  135332. /**
  135333. * Initializes a PostProcessRenderPipeline
  135334. * @param engine engine to add the pipeline to
  135335. * @param name name of the pipeline
  135336. */
  135337. constructor(engine: Engine, name: string);
  135338. /**
  135339. * Gets the class name
  135340. * @returns "PostProcessRenderPipeline"
  135341. */
  135342. getClassName(): string;
  135343. /**
  135344. * If all the render effects in the pipeline are supported
  135345. */
  135346. get isSupported(): boolean;
  135347. /**
  135348. * Adds an effect to the pipeline
  135349. * @param renderEffect the effect to add
  135350. */
  135351. addEffect(renderEffect: PostProcessRenderEffect): void;
  135352. /** @hidden */
  135353. _rebuild(): void;
  135354. /** @hidden */
  135355. _enableEffect(renderEffectName: string, cameras: Camera): void;
  135356. /** @hidden */
  135357. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  135358. /** @hidden */
  135359. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  135360. /** @hidden */
  135361. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  135362. /** @hidden */
  135363. _attachCameras(cameras: Camera, unique: boolean): void;
  135364. /** @hidden */
  135365. _attachCameras(cameras: Camera[], unique: boolean): void;
  135366. /** @hidden */
  135367. _detachCameras(cameras: Camera): void;
  135368. /** @hidden */
  135369. _detachCameras(cameras: Nullable<Camera[]>): void;
  135370. /** @hidden */
  135371. _update(): void;
  135372. /** @hidden */
  135373. _reset(): void;
  135374. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  135375. /**
  135376. * Disposes of the pipeline
  135377. */
  135378. dispose(): void;
  135379. }
  135380. }
  135381. declare module BABYLON {
  135382. /**
  135383. * PostProcessRenderPipelineManager class
  135384. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  135385. */
  135386. export class PostProcessRenderPipelineManager {
  135387. private _renderPipelines;
  135388. /**
  135389. * Initializes a PostProcessRenderPipelineManager
  135390. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  135391. */
  135392. constructor();
  135393. /**
  135394. * Gets the list of supported render pipelines
  135395. */
  135396. get supportedPipelines(): PostProcessRenderPipeline[];
  135397. /**
  135398. * Adds a pipeline to the manager
  135399. * @param renderPipeline The pipeline to add
  135400. */
  135401. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  135402. /**
  135403. * Attaches a camera to the pipeline
  135404. * @param renderPipelineName The name of the pipeline to attach to
  135405. * @param cameras the camera to attach
  135406. * @param unique if the camera can be attached multiple times to the pipeline
  135407. */
  135408. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  135409. /**
  135410. * Detaches a camera from the pipeline
  135411. * @param renderPipelineName The name of the pipeline to detach from
  135412. * @param cameras the camera to detach
  135413. */
  135414. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  135415. /**
  135416. * Enables an effect by name on a pipeline
  135417. * @param renderPipelineName the name of the pipeline to enable the effect in
  135418. * @param renderEffectName the name of the effect to enable
  135419. * @param cameras the cameras that the effect should be enabled on
  135420. */
  135421. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  135422. /**
  135423. * Disables an effect by name on a pipeline
  135424. * @param renderPipelineName the name of the pipeline to disable the effect in
  135425. * @param renderEffectName the name of the effect to disable
  135426. * @param cameras the cameras that the effect should be disabled on
  135427. */
  135428. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  135429. /**
  135430. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  135431. */
  135432. update(): void;
  135433. /** @hidden */
  135434. _rebuild(): void;
  135435. /**
  135436. * Disposes of the manager and pipelines
  135437. */
  135438. dispose(): void;
  135439. }
  135440. }
  135441. declare module BABYLON {
  135442. interface Scene {
  135443. /** @hidden (Backing field) */
  135444. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  135445. /**
  135446. * Gets the postprocess render pipeline manager
  135447. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  135448. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  135449. */
  135450. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  135451. }
  135452. /**
  135453. * Defines the Render Pipeline scene component responsible to rendering pipelines
  135454. */
  135455. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  135456. /**
  135457. * The component name helpfull to identify the component in the list of scene components.
  135458. */
  135459. readonly name: string;
  135460. /**
  135461. * The scene the component belongs to.
  135462. */
  135463. scene: Scene;
  135464. /**
  135465. * Creates a new instance of the component for the given scene
  135466. * @param scene Defines the scene to register the component in
  135467. */
  135468. constructor(scene: Scene);
  135469. /**
  135470. * Registers the component in a given scene
  135471. */
  135472. register(): void;
  135473. /**
  135474. * Rebuilds the elements related to this component in case of
  135475. * context lost for instance.
  135476. */
  135477. rebuild(): void;
  135478. /**
  135479. * Disposes the component and the associated ressources
  135480. */
  135481. dispose(): void;
  135482. private _gatherRenderTargets;
  135483. }
  135484. }
  135485. declare module BABYLON {
  135486. /**
  135487. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  135488. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  135489. */
  135490. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  135491. private _scene;
  135492. private _camerasToBeAttached;
  135493. /**
  135494. * ID of the sharpen post process,
  135495. */
  135496. private readonly SharpenPostProcessId;
  135497. /**
  135498. * @ignore
  135499. * ID of the image processing post process;
  135500. */
  135501. readonly ImageProcessingPostProcessId: string;
  135502. /**
  135503. * @ignore
  135504. * ID of the Fast Approximate Anti-Aliasing post process;
  135505. */
  135506. readonly FxaaPostProcessId: string;
  135507. /**
  135508. * ID of the chromatic aberration post process,
  135509. */
  135510. private readonly ChromaticAberrationPostProcessId;
  135511. /**
  135512. * ID of the grain post process
  135513. */
  135514. private readonly GrainPostProcessId;
  135515. /**
  135516. * Sharpen post process which will apply a sharpen convolution to enhance edges
  135517. */
  135518. sharpen: SharpenPostProcess;
  135519. private _sharpenEffect;
  135520. private bloom;
  135521. /**
  135522. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  135523. */
  135524. depthOfField: DepthOfFieldEffect;
  135525. /**
  135526. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  135527. */
  135528. fxaa: FxaaPostProcess;
  135529. /**
  135530. * Image post processing pass used to perform operations such as tone mapping or color grading.
  135531. */
  135532. imageProcessing: ImageProcessingPostProcess;
  135533. /**
  135534. * Chromatic aberration post process which will shift rgb colors in the image
  135535. */
  135536. chromaticAberration: ChromaticAberrationPostProcess;
  135537. private _chromaticAberrationEffect;
  135538. /**
  135539. * Grain post process which add noise to the image
  135540. */
  135541. grain: GrainPostProcess;
  135542. private _grainEffect;
  135543. /**
  135544. * Glow post process which adds a glow to emissive areas of the image
  135545. */
  135546. private _glowLayer;
  135547. /**
  135548. * Animations which can be used to tweak settings over a period of time
  135549. */
  135550. animations: Animation[];
  135551. private _imageProcessingConfigurationObserver;
  135552. private _sharpenEnabled;
  135553. private _bloomEnabled;
  135554. private _depthOfFieldEnabled;
  135555. private _depthOfFieldBlurLevel;
  135556. private _fxaaEnabled;
  135557. private _imageProcessingEnabled;
  135558. private _defaultPipelineTextureType;
  135559. private _bloomScale;
  135560. private _chromaticAberrationEnabled;
  135561. private _grainEnabled;
  135562. private _buildAllowed;
  135563. /**
  135564. * Gets active scene
  135565. */
  135566. get scene(): Scene;
  135567. /**
  135568. * Enable or disable the sharpen process from the pipeline
  135569. */
  135570. set sharpenEnabled(enabled: boolean);
  135571. get sharpenEnabled(): boolean;
  135572. private _resizeObserver;
  135573. private _hardwareScaleLevel;
  135574. private _bloomKernel;
  135575. /**
  135576. * Specifies the size of the bloom blur kernel, relative to the final output size
  135577. */
  135578. get bloomKernel(): number;
  135579. set bloomKernel(value: number);
  135580. /**
  135581. * Specifies the weight of the bloom in the final rendering
  135582. */
  135583. private _bloomWeight;
  135584. /**
  135585. * Specifies the luma threshold for the area that will be blurred by the bloom
  135586. */
  135587. private _bloomThreshold;
  135588. private _hdr;
  135589. /**
  135590. * The strength of the bloom.
  135591. */
  135592. set bloomWeight(value: number);
  135593. get bloomWeight(): number;
  135594. /**
  135595. * The strength of the bloom.
  135596. */
  135597. set bloomThreshold(value: number);
  135598. get bloomThreshold(): number;
  135599. /**
  135600. * The scale of the bloom, lower value will provide better performance.
  135601. */
  135602. set bloomScale(value: number);
  135603. get bloomScale(): number;
  135604. /**
  135605. * Enable or disable the bloom from the pipeline
  135606. */
  135607. set bloomEnabled(enabled: boolean);
  135608. get bloomEnabled(): boolean;
  135609. private _rebuildBloom;
  135610. /**
  135611. * If the depth of field is enabled.
  135612. */
  135613. get depthOfFieldEnabled(): boolean;
  135614. set depthOfFieldEnabled(enabled: boolean);
  135615. /**
  135616. * Blur level of the depth of field effect. (Higher blur will effect performance)
  135617. */
  135618. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  135619. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  135620. /**
  135621. * If the anti aliasing is enabled.
  135622. */
  135623. set fxaaEnabled(enabled: boolean);
  135624. get fxaaEnabled(): boolean;
  135625. private _samples;
  135626. /**
  135627. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  135628. */
  135629. set samples(sampleCount: number);
  135630. get samples(): number;
  135631. /**
  135632. * If image processing is enabled.
  135633. */
  135634. set imageProcessingEnabled(enabled: boolean);
  135635. get imageProcessingEnabled(): boolean;
  135636. /**
  135637. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  135638. */
  135639. set glowLayerEnabled(enabled: boolean);
  135640. get glowLayerEnabled(): boolean;
  135641. /**
  135642. * Gets the glow layer (or null if not defined)
  135643. */
  135644. get glowLayer(): Nullable<GlowLayer>;
  135645. /**
  135646. * Enable or disable the chromaticAberration process from the pipeline
  135647. */
  135648. set chromaticAberrationEnabled(enabled: boolean);
  135649. get chromaticAberrationEnabled(): boolean;
  135650. /**
  135651. * Enable or disable the grain process from the pipeline
  135652. */
  135653. set grainEnabled(enabled: boolean);
  135654. get grainEnabled(): boolean;
  135655. /**
  135656. * @constructor
  135657. * @param name - The rendering pipeline name (default: "")
  135658. * @param hdr - If high dynamic range textures should be used (default: true)
  135659. * @param scene - The scene linked to this pipeline (default: the last created scene)
  135660. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  135661. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  135662. */
  135663. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  135664. /**
  135665. * Get the class name
  135666. * @returns "DefaultRenderingPipeline"
  135667. */
  135668. getClassName(): string;
  135669. /**
  135670. * Force the compilation of the entire pipeline.
  135671. */
  135672. prepare(): void;
  135673. private _hasCleared;
  135674. private _prevPostProcess;
  135675. private _prevPrevPostProcess;
  135676. private _setAutoClearAndTextureSharing;
  135677. private _depthOfFieldSceneObserver;
  135678. private _buildPipeline;
  135679. private _disposePostProcesses;
  135680. /**
  135681. * Adds a camera to the pipeline
  135682. * @param camera the camera to be added
  135683. */
  135684. addCamera(camera: Camera): void;
  135685. /**
  135686. * Removes a camera from the pipeline
  135687. * @param camera the camera to remove
  135688. */
  135689. removeCamera(camera: Camera): void;
  135690. /**
  135691. * Dispose of the pipeline and stop all post processes
  135692. */
  135693. dispose(): void;
  135694. /**
  135695. * Serialize the rendering pipeline (Used when exporting)
  135696. * @returns the serialized object
  135697. */
  135698. serialize(): any;
  135699. /**
  135700. * Parse the serialized pipeline
  135701. * @param source Source pipeline.
  135702. * @param scene The scene to load the pipeline to.
  135703. * @param rootUrl The URL of the serialized pipeline.
  135704. * @returns An instantiated pipeline from the serialized object.
  135705. */
  135706. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  135707. }
  135708. }
  135709. declare module BABYLON {
  135710. /** @hidden */
  135711. export var lensHighlightsPixelShader: {
  135712. name: string;
  135713. shader: string;
  135714. };
  135715. }
  135716. declare module BABYLON {
  135717. /** @hidden */
  135718. export var depthOfFieldPixelShader: {
  135719. name: string;
  135720. shader: string;
  135721. };
  135722. }
  135723. declare module BABYLON {
  135724. /**
  135725. * BABYLON.JS Chromatic Aberration GLSL Shader
  135726. * Author: Olivier Guyot
  135727. * Separates very slightly R, G and B colors on the edges of the screen
  135728. * Inspired by Francois Tarlier & Martins Upitis
  135729. */
  135730. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  135731. /**
  135732. * @ignore
  135733. * The chromatic aberration PostProcess id in the pipeline
  135734. */
  135735. LensChromaticAberrationEffect: string;
  135736. /**
  135737. * @ignore
  135738. * The highlights enhancing PostProcess id in the pipeline
  135739. */
  135740. HighlightsEnhancingEffect: string;
  135741. /**
  135742. * @ignore
  135743. * The depth-of-field PostProcess id in the pipeline
  135744. */
  135745. LensDepthOfFieldEffect: string;
  135746. private _scene;
  135747. private _depthTexture;
  135748. private _grainTexture;
  135749. private _chromaticAberrationPostProcess;
  135750. private _highlightsPostProcess;
  135751. private _depthOfFieldPostProcess;
  135752. private _edgeBlur;
  135753. private _grainAmount;
  135754. private _chromaticAberration;
  135755. private _distortion;
  135756. private _highlightsGain;
  135757. private _highlightsThreshold;
  135758. private _dofDistance;
  135759. private _dofAperture;
  135760. private _dofDarken;
  135761. private _dofPentagon;
  135762. private _blurNoise;
  135763. /**
  135764. * @constructor
  135765. *
  135766. * Effect parameters are as follow:
  135767. * {
  135768. * chromatic_aberration: number; // from 0 to x (1 for realism)
  135769. * edge_blur: number; // from 0 to x (1 for realism)
  135770. * distortion: number; // from 0 to x (1 for realism)
  135771. * grain_amount: number; // from 0 to 1
  135772. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  135773. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  135774. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  135775. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  135776. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  135777. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  135778. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  135779. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  135780. * }
  135781. * Note: if an effect parameter is unset, effect is disabled
  135782. *
  135783. * @param name The rendering pipeline name
  135784. * @param parameters - An object containing all parameters (see above)
  135785. * @param scene The scene linked to this pipeline
  135786. * @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)
  135787. * @param cameras The array of cameras that the rendering pipeline will be attached to
  135788. */
  135789. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  135790. /**
  135791. * Get the class name
  135792. * @returns "LensRenderingPipeline"
  135793. */
  135794. getClassName(): string;
  135795. /**
  135796. * Gets associated scene
  135797. */
  135798. get scene(): Scene;
  135799. /**
  135800. * Gets or sets the edge blur
  135801. */
  135802. get edgeBlur(): number;
  135803. set edgeBlur(value: number);
  135804. /**
  135805. * Gets or sets the grain amount
  135806. */
  135807. get grainAmount(): number;
  135808. set grainAmount(value: number);
  135809. /**
  135810. * Gets or sets the chromatic aberration amount
  135811. */
  135812. get chromaticAberration(): number;
  135813. set chromaticAberration(value: number);
  135814. /**
  135815. * Gets or sets the depth of field aperture
  135816. */
  135817. get dofAperture(): number;
  135818. set dofAperture(value: number);
  135819. /**
  135820. * Gets or sets the edge distortion
  135821. */
  135822. get edgeDistortion(): number;
  135823. set edgeDistortion(value: number);
  135824. /**
  135825. * Gets or sets the depth of field distortion
  135826. */
  135827. get dofDistortion(): number;
  135828. set dofDistortion(value: number);
  135829. /**
  135830. * Gets or sets the darken out of focus amount
  135831. */
  135832. get darkenOutOfFocus(): number;
  135833. set darkenOutOfFocus(value: number);
  135834. /**
  135835. * Gets or sets a boolean indicating if blur noise is enabled
  135836. */
  135837. get blurNoise(): boolean;
  135838. set blurNoise(value: boolean);
  135839. /**
  135840. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  135841. */
  135842. get pentagonBokeh(): boolean;
  135843. set pentagonBokeh(value: boolean);
  135844. /**
  135845. * Gets or sets the highlight grain amount
  135846. */
  135847. get highlightsGain(): number;
  135848. set highlightsGain(value: number);
  135849. /**
  135850. * Gets or sets the highlight threshold
  135851. */
  135852. get highlightsThreshold(): number;
  135853. set highlightsThreshold(value: number);
  135854. /**
  135855. * Sets the amount of blur at the edges
  135856. * @param amount blur amount
  135857. */
  135858. setEdgeBlur(amount: number): void;
  135859. /**
  135860. * Sets edge blur to 0
  135861. */
  135862. disableEdgeBlur(): void;
  135863. /**
  135864. * Sets the amout of grain
  135865. * @param amount Amount of grain
  135866. */
  135867. setGrainAmount(amount: number): void;
  135868. /**
  135869. * Set grain amount to 0
  135870. */
  135871. disableGrain(): void;
  135872. /**
  135873. * Sets the chromatic aberration amount
  135874. * @param amount amount of chromatic aberration
  135875. */
  135876. setChromaticAberration(amount: number): void;
  135877. /**
  135878. * Sets chromatic aberration amount to 0
  135879. */
  135880. disableChromaticAberration(): void;
  135881. /**
  135882. * Sets the EdgeDistortion amount
  135883. * @param amount amount of EdgeDistortion
  135884. */
  135885. setEdgeDistortion(amount: number): void;
  135886. /**
  135887. * Sets edge distortion to 0
  135888. */
  135889. disableEdgeDistortion(): void;
  135890. /**
  135891. * Sets the FocusDistance amount
  135892. * @param amount amount of FocusDistance
  135893. */
  135894. setFocusDistance(amount: number): void;
  135895. /**
  135896. * Disables depth of field
  135897. */
  135898. disableDepthOfField(): void;
  135899. /**
  135900. * Sets the Aperture amount
  135901. * @param amount amount of Aperture
  135902. */
  135903. setAperture(amount: number): void;
  135904. /**
  135905. * Sets the DarkenOutOfFocus amount
  135906. * @param amount amount of DarkenOutOfFocus
  135907. */
  135908. setDarkenOutOfFocus(amount: number): void;
  135909. private _pentagonBokehIsEnabled;
  135910. /**
  135911. * Creates a pentagon bokeh effect
  135912. */
  135913. enablePentagonBokeh(): void;
  135914. /**
  135915. * Disables the pentagon bokeh effect
  135916. */
  135917. disablePentagonBokeh(): void;
  135918. /**
  135919. * Enables noise blur
  135920. */
  135921. enableNoiseBlur(): void;
  135922. /**
  135923. * Disables noise blur
  135924. */
  135925. disableNoiseBlur(): void;
  135926. /**
  135927. * Sets the HighlightsGain amount
  135928. * @param amount amount of HighlightsGain
  135929. */
  135930. setHighlightsGain(amount: number): void;
  135931. /**
  135932. * Sets the HighlightsThreshold amount
  135933. * @param amount amount of HighlightsThreshold
  135934. */
  135935. setHighlightsThreshold(amount: number): void;
  135936. /**
  135937. * Disables highlights
  135938. */
  135939. disableHighlights(): void;
  135940. /**
  135941. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  135942. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  135943. */
  135944. dispose(disableDepthRender?: boolean): void;
  135945. private _createChromaticAberrationPostProcess;
  135946. private _createHighlightsPostProcess;
  135947. private _createDepthOfFieldPostProcess;
  135948. private _createGrainTexture;
  135949. }
  135950. }
  135951. declare module BABYLON {
  135952. /** @hidden */
  135953. export var ssao2PixelShader: {
  135954. name: string;
  135955. shader: string;
  135956. };
  135957. }
  135958. declare module BABYLON {
  135959. /** @hidden */
  135960. export var ssaoCombinePixelShader: {
  135961. name: string;
  135962. shader: string;
  135963. };
  135964. }
  135965. declare module BABYLON {
  135966. /**
  135967. * Render pipeline to produce ssao effect
  135968. */
  135969. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  135970. /**
  135971. * @ignore
  135972. * The PassPostProcess id in the pipeline that contains the original scene color
  135973. */
  135974. SSAOOriginalSceneColorEffect: string;
  135975. /**
  135976. * @ignore
  135977. * The SSAO PostProcess id in the pipeline
  135978. */
  135979. SSAORenderEffect: string;
  135980. /**
  135981. * @ignore
  135982. * The horizontal blur PostProcess id in the pipeline
  135983. */
  135984. SSAOBlurHRenderEffect: string;
  135985. /**
  135986. * @ignore
  135987. * The vertical blur PostProcess id in the pipeline
  135988. */
  135989. SSAOBlurVRenderEffect: string;
  135990. /**
  135991. * @ignore
  135992. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  135993. */
  135994. SSAOCombineRenderEffect: string;
  135995. /**
  135996. * The output strength of the SSAO post-process. Default value is 1.0.
  135997. */
  135998. totalStrength: number;
  135999. /**
  136000. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  136001. */
  136002. maxZ: number;
  136003. /**
  136004. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  136005. */
  136006. minZAspect: number;
  136007. private _samples;
  136008. /**
  136009. * Number of samples used for the SSAO calculations. Default value is 8
  136010. */
  136011. set samples(n: number);
  136012. get samples(): number;
  136013. private _textureSamples;
  136014. /**
  136015. * Number of samples to use for antialiasing
  136016. */
  136017. set textureSamples(n: number);
  136018. get textureSamples(): number;
  136019. /**
  136020. * Ratio object used for SSAO ratio and blur ratio
  136021. */
  136022. private _ratio;
  136023. /**
  136024. * Dynamically generated sphere sampler.
  136025. */
  136026. private _sampleSphere;
  136027. /**
  136028. * Blur filter offsets
  136029. */
  136030. private _samplerOffsets;
  136031. private _expensiveBlur;
  136032. /**
  136033. * If bilateral blur should be used
  136034. */
  136035. set expensiveBlur(b: boolean);
  136036. get expensiveBlur(): boolean;
  136037. /**
  136038. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  136039. */
  136040. radius: number;
  136041. /**
  136042. * The base color of the SSAO post-process
  136043. * The final result is "base + ssao" between [0, 1]
  136044. */
  136045. base: number;
  136046. /**
  136047. * Support test.
  136048. */
  136049. static get IsSupported(): boolean;
  136050. private _scene;
  136051. private _depthTexture;
  136052. private _normalTexture;
  136053. private _randomTexture;
  136054. private _originalColorPostProcess;
  136055. private _ssaoPostProcess;
  136056. private _blurHPostProcess;
  136057. private _blurVPostProcess;
  136058. private _ssaoCombinePostProcess;
  136059. /**
  136060. * Gets active scene
  136061. */
  136062. get scene(): Scene;
  136063. /**
  136064. * @constructor
  136065. * @param name The rendering pipeline name
  136066. * @param scene The scene linked to this pipeline
  136067. * @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 }
  136068. * @param cameras The array of cameras that the rendering pipeline will be attached to
  136069. */
  136070. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  136071. /**
  136072. * Get the class name
  136073. * @returns "SSAO2RenderingPipeline"
  136074. */
  136075. getClassName(): string;
  136076. /**
  136077. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  136078. */
  136079. dispose(disableGeometryBufferRenderer?: boolean): void;
  136080. private _createBlurPostProcess;
  136081. /** @hidden */
  136082. _rebuild(): void;
  136083. private _bits;
  136084. private _radicalInverse_VdC;
  136085. private _hammersley;
  136086. private _hemisphereSample_uniform;
  136087. private _generateHemisphere;
  136088. private _createSSAOPostProcess;
  136089. private _createSSAOCombinePostProcess;
  136090. private _createRandomTexture;
  136091. /**
  136092. * Serialize the rendering pipeline (Used when exporting)
  136093. * @returns the serialized object
  136094. */
  136095. serialize(): any;
  136096. /**
  136097. * Parse the serialized pipeline
  136098. * @param source Source pipeline.
  136099. * @param scene The scene to load the pipeline to.
  136100. * @param rootUrl The URL of the serialized pipeline.
  136101. * @returns An instantiated pipeline from the serialized object.
  136102. */
  136103. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  136104. }
  136105. }
  136106. declare module BABYLON {
  136107. /** @hidden */
  136108. export var ssaoPixelShader: {
  136109. name: string;
  136110. shader: string;
  136111. };
  136112. }
  136113. declare module BABYLON {
  136114. /**
  136115. * Render pipeline to produce ssao effect
  136116. */
  136117. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  136118. /**
  136119. * @ignore
  136120. * The PassPostProcess id in the pipeline that contains the original scene color
  136121. */
  136122. SSAOOriginalSceneColorEffect: string;
  136123. /**
  136124. * @ignore
  136125. * The SSAO PostProcess id in the pipeline
  136126. */
  136127. SSAORenderEffect: string;
  136128. /**
  136129. * @ignore
  136130. * The horizontal blur PostProcess id in the pipeline
  136131. */
  136132. SSAOBlurHRenderEffect: string;
  136133. /**
  136134. * @ignore
  136135. * The vertical blur PostProcess id in the pipeline
  136136. */
  136137. SSAOBlurVRenderEffect: string;
  136138. /**
  136139. * @ignore
  136140. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  136141. */
  136142. SSAOCombineRenderEffect: string;
  136143. /**
  136144. * The output strength of the SSAO post-process. Default value is 1.0.
  136145. */
  136146. totalStrength: number;
  136147. /**
  136148. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  136149. */
  136150. radius: number;
  136151. /**
  136152. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  136153. * Must not be equal to fallOff and superior to fallOff.
  136154. * Default value is 0.0075
  136155. */
  136156. area: number;
  136157. /**
  136158. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  136159. * Must not be equal to area and inferior to area.
  136160. * Default value is 0.000001
  136161. */
  136162. fallOff: number;
  136163. /**
  136164. * The base color of the SSAO post-process
  136165. * The final result is "base + ssao" between [0, 1]
  136166. */
  136167. base: number;
  136168. private _scene;
  136169. private _depthTexture;
  136170. private _randomTexture;
  136171. private _originalColorPostProcess;
  136172. private _ssaoPostProcess;
  136173. private _blurHPostProcess;
  136174. private _blurVPostProcess;
  136175. private _ssaoCombinePostProcess;
  136176. private _firstUpdate;
  136177. /**
  136178. * Gets active scene
  136179. */
  136180. get scene(): Scene;
  136181. /**
  136182. * @constructor
  136183. * @param name - The rendering pipeline name
  136184. * @param scene - The scene linked to this pipeline
  136185. * @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 }
  136186. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  136187. */
  136188. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  136189. /**
  136190. * Get the class name
  136191. * @returns "SSAORenderingPipeline"
  136192. */
  136193. getClassName(): string;
  136194. /**
  136195. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  136196. */
  136197. dispose(disableDepthRender?: boolean): void;
  136198. private _createBlurPostProcess;
  136199. /** @hidden */
  136200. _rebuild(): void;
  136201. private _createSSAOPostProcess;
  136202. private _createSSAOCombinePostProcess;
  136203. private _createRandomTexture;
  136204. }
  136205. }
  136206. declare module BABYLON {
  136207. /** @hidden */
  136208. export var standardPixelShader: {
  136209. name: string;
  136210. shader: string;
  136211. };
  136212. }
  136213. declare module BABYLON {
  136214. /**
  136215. * Standard rendering pipeline
  136216. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  136217. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  136218. */
  136219. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  136220. /**
  136221. * Public members
  136222. */
  136223. /**
  136224. * Post-process which contains the original scene color before the pipeline applies all the effects
  136225. */
  136226. originalPostProcess: Nullable<PostProcess>;
  136227. /**
  136228. * Post-process used to down scale an image x4
  136229. */
  136230. downSampleX4PostProcess: Nullable<PostProcess>;
  136231. /**
  136232. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  136233. */
  136234. brightPassPostProcess: Nullable<PostProcess>;
  136235. /**
  136236. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  136237. */
  136238. blurHPostProcesses: PostProcess[];
  136239. /**
  136240. * Post-process array storing all the vertical blur post-processes used by the pipeline
  136241. */
  136242. blurVPostProcesses: PostProcess[];
  136243. /**
  136244. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  136245. */
  136246. textureAdderPostProcess: Nullable<PostProcess>;
  136247. /**
  136248. * Post-process used to create volumetric lighting effect
  136249. */
  136250. volumetricLightPostProcess: Nullable<PostProcess>;
  136251. /**
  136252. * Post-process used to smooth the previous volumetric light post-process on the X axis
  136253. */
  136254. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  136255. /**
  136256. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  136257. */
  136258. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  136259. /**
  136260. * Post-process used to merge the volumetric light effect and the real scene color
  136261. */
  136262. volumetricLightMergePostProces: Nullable<PostProcess>;
  136263. /**
  136264. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  136265. */
  136266. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  136267. /**
  136268. * Base post-process used to calculate the average luminance of the final image for HDR
  136269. */
  136270. luminancePostProcess: Nullable<PostProcess>;
  136271. /**
  136272. * Post-processes used to create down sample post-processes in order to get
  136273. * the average luminance of the final image for HDR
  136274. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  136275. */
  136276. luminanceDownSamplePostProcesses: PostProcess[];
  136277. /**
  136278. * Post-process used to create a HDR effect (light adaptation)
  136279. */
  136280. hdrPostProcess: Nullable<PostProcess>;
  136281. /**
  136282. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  136283. */
  136284. textureAdderFinalPostProcess: Nullable<PostProcess>;
  136285. /**
  136286. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  136287. */
  136288. lensFlareFinalPostProcess: Nullable<PostProcess>;
  136289. /**
  136290. * Post-process used to merge the final HDR post-process and the real scene color
  136291. */
  136292. hdrFinalPostProcess: Nullable<PostProcess>;
  136293. /**
  136294. * Post-process used to create a lens flare effect
  136295. */
  136296. lensFlarePostProcess: Nullable<PostProcess>;
  136297. /**
  136298. * Post-process that merges the result of the lens flare post-process and the real scene color
  136299. */
  136300. lensFlareComposePostProcess: Nullable<PostProcess>;
  136301. /**
  136302. * Post-process used to create a motion blur effect
  136303. */
  136304. motionBlurPostProcess: Nullable<PostProcess>;
  136305. /**
  136306. * Post-process used to create a depth of field effect
  136307. */
  136308. depthOfFieldPostProcess: Nullable<PostProcess>;
  136309. /**
  136310. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  136311. */
  136312. fxaaPostProcess: Nullable<FxaaPostProcess>;
  136313. /**
  136314. * Represents the brightness threshold in order to configure the illuminated surfaces
  136315. */
  136316. brightThreshold: number;
  136317. /**
  136318. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  136319. */
  136320. blurWidth: number;
  136321. /**
  136322. * Sets if the blur for highlighted surfaces must be only horizontal
  136323. */
  136324. horizontalBlur: boolean;
  136325. /**
  136326. * Gets the overall exposure used by the pipeline
  136327. */
  136328. get exposure(): number;
  136329. /**
  136330. * Sets the overall exposure used by the pipeline
  136331. */
  136332. set exposure(value: number);
  136333. /**
  136334. * Texture used typically to simulate "dirty" on camera lens
  136335. */
  136336. lensTexture: Nullable<Texture>;
  136337. /**
  136338. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  136339. */
  136340. volumetricLightCoefficient: number;
  136341. /**
  136342. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  136343. */
  136344. volumetricLightPower: number;
  136345. /**
  136346. * Used the set the blur intensity to smooth the volumetric lights
  136347. */
  136348. volumetricLightBlurScale: number;
  136349. /**
  136350. * Light (spot or directional) used to generate the volumetric lights rays
  136351. * The source light must have a shadow generate so the pipeline can get its
  136352. * depth map
  136353. */
  136354. sourceLight: Nullable<SpotLight | DirectionalLight>;
  136355. /**
  136356. * For eye adaptation, represents the minimum luminance the eye can see
  136357. */
  136358. hdrMinimumLuminance: number;
  136359. /**
  136360. * For eye adaptation, represents the decrease luminance speed
  136361. */
  136362. hdrDecreaseRate: number;
  136363. /**
  136364. * For eye adaptation, represents the increase luminance speed
  136365. */
  136366. hdrIncreaseRate: number;
  136367. /**
  136368. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  136369. */
  136370. get hdrAutoExposure(): boolean;
  136371. /**
  136372. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  136373. */
  136374. set hdrAutoExposure(value: boolean);
  136375. /**
  136376. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  136377. */
  136378. lensColorTexture: Nullable<Texture>;
  136379. /**
  136380. * The overall strengh for the lens flare effect
  136381. */
  136382. lensFlareStrength: number;
  136383. /**
  136384. * Dispersion coefficient for lens flare ghosts
  136385. */
  136386. lensFlareGhostDispersal: number;
  136387. /**
  136388. * Main lens flare halo width
  136389. */
  136390. lensFlareHaloWidth: number;
  136391. /**
  136392. * Based on the lens distortion effect, defines how much the lens flare result
  136393. * is distorted
  136394. */
  136395. lensFlareDistortionStrength: number;
  136396. /**
  136397. * Configures the blur intensity used for for lens flare (halo)
  136398. */
  136399. lensFlareBlurWidth: number;
  136400. /**
  136401. * Lens star texture must be used to simulate rays on the flares and is available
  136402. * in the documentation
  136403. */
  136404. lensStarTexture: Nullable<Texture>;
  136405. /**
  136406. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  136407. * flare effect by taking account of the dirt texture
  136408. */
  136409. lensFlareDirtTexture: Nullable<Texture>;
  136410. /**
  136411. * Represents the focal length for the depth of field effect
  136412. */
  136413. depthOfFieldDistance: number;
  136414. /**
  136415. * Represents the blur intensity for the blurred part of the depth of field effect
  136416. */
  136417. depthOfFieldBlurWidth: number;
  136418. /**
  136419. * Gets how much the image is blurred by the movement while using the motion blur post-process
  136420. */
  136421. get motionStrength(): number;
  136422. /**
  136423. * Sets how much the image is blurred by the movement while using the motion blur post-process
  136424. */
  136425. set motionStrength(strength: number);
  136426. /**
  136427. * Gets wether or not the motion blur post-process is object based or screen based.
  136428. */
  136429. get objectBasedMotionBlur(): boolean;
  136430. /**
  136431. * Sets wether or not the motion blur post-process should be object based or screen based
  136432. */
  136433. set objectBasedMotionBlur(value: boolean);
  136434. /**
  136435. * List of animations for the pipeline (IAnimatable implementation)
  136436. */
  136437. animations: Animation[];
  136438. /**
  136439. * Private members
  136440. */
  136441. private _scene;
  136442. private _currentDepthOfFieldSource;
  136443. private _basePostProcess;
  136444. private _fixedExposure;
  136445. private _currentExposure;
  136446. private _hdrAutoExposure;
  136447. private _hdrCurrentLuminance;
  136448. private _motionStrength;
  136449. private _isObjectBasedMotionBlur;
  136450. private _floatTextureType;
  136451. private _camerasToBeAttached;
  136452. private _ratio;
  136453. private _bloomEnabled;
  136454. private _depthOfFieldEnabled;
  136455. private _vlsEnabled;
  136456. private _lensFlareEnabled;
  136457. private _hdrEnabled;
  136458. private _motionBlurEnabled;
  136459. private _fxaaEnabled;
  136460. private _motionBlurSamples;
  136461. private _volumetricLightStepsCount;
  136462. private _samples;
  136463. /**
  136464. * @ignore
  136465. * Specifies if the bloom pipeline is enabled
  136466. */
  136467. get BloomEnabled(): boolean;
  136468. set BloomEnabled(enabled: boolean);
  136469. /**
  136470. * @ignore
  136471. * Specifies if the depth of field pipeline is enabed
  136472. */
  136473. get DepthOfFieldEnabled(): boolean;
  136474. set DepthOfFieldEnabled(enabled: boolean);
  136475. /**
  136476. * @ignore
  136477. * Specifies if the lens flare pipeline is enabed
  136478. */
  136479. get LensFlareEnabled(): boolean;
  136480. set LensFlareEnabled(enabled: boolean);
  136481. /**
  136482. * @ignore
  136483. * Specifies if the HDR pipeline is enabled
  136484. */
  136485. get HDREnabled(): boolean;
  136486. set HDREnabled(enabled: boolean);
  136487. /**
  136488. * @ignore
  136489. * Specifies if the volumetric lights scattering effect is enabled
  136490. */
  136491. get VLSEnabled(): boolean;
  136492. set VLSEnabled(enabled: boolean);
  136493. /**
  136494. * @ignore
  136495. * Specifies if the motion blur effect is enabled
  136496. */
  136497. get MotionBlurEnabled(): boolean;
  136498. set MotionBlurEnabled(enabled: boolean);
  136499. /**
  136500. * Specifies if anti-aliasing is enabled
  136501. */
  136502. get fxaaEnabled(): boolean;
  136503. set fxaaEnabled(enabled: boolean);
  136504. /**
  136505. * Specifies the number of steps used to calculate the volumetric lights
  136506. * Typically in interval [50, 200]
  136507. */
  136508. get volumetricLightStepsCount(): number;
  136509. set volumetricLightStepsCount(count: number);
  136510. /**
  136511. * Specifies the number of samples used for the motion blur effect
  136512. * Typically in interval [16, 64]
  136513. */
  136514. get motionBlurSamples(): number;
  136515. set motionBlurSamples(samples: number);
  136516. /**
  136517. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  136518. */
  136519. get samples(): number;
  136520. set samples(sampleCount: number);
  136521. /**
  136522. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  136523. * @constructor
  136524. * @param name The rendering pipeline name
  136525. * @param scene The scene linked to this pipeline
  136526. * @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)
  136527. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  136528. * @param cameras The array of cameras that the rendering pipeline will be attached to
  136529. */
  136530. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  136531. private _buildPipeline;
  136532. private _createDownSampleX4PostProcess;
  136533. private _createBrightPassPostProcess;
  136534. private _createBlurPostProcesses;
  136535. private _createTextureAdderPostProcess;
  136536. private _createVolumetricLightPostProcess;
  136537. private _createLuminancePostProcesses;
  136538. private _createHdrPostProcess;
  136539. private _createLensFlarePostProcess;
  136540. private _createDepthOfFieldPostProcess;
  136541. private _createMotionBlurPostProcess;
  136542. private _getDepthTexture;
  136543. private _disposePostProcesses;
  136544. /**
  136545. * Dispose of the pipeline and stop all post processes
  136546. */
  136547. dispose(): void;
  136548. /**
  136549. * Serialize the rendering pipeline (Used when exporting)
  136550. * @returns the serialized object
  136551. */
  136552. serialize(): any;
  136553. /**
  136554. * Parse the serialized pipeline
  136555. * @param source Source pipeline.
  136556. * @param scene The scene to load the pipeline to.
  136557. * @param rootUrl The URL of the serialized pipeline.
  136558. * @returns An instantiated pipeline from the serialized object.
  136559. */
  136560. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  136561. /**
  136562. * Luminance steps
  136563. */
  136564. static LuminanceSteps: number;
  136565. }
  136566. }
  136567. declare module BABYLON {
  136568. /** @hidden */
  136569. export var tonemapPixelShader: {
  136570. name: string;
  136571. shader: string;
  136572. };
  136573. }
  136574. declare module BABYLON {
  136575. /** Defines operator used for tonemapping */
  136576. export enum TonemappingOperator {
  136577. /** Hable */
  136578. Hable = 0,
  136579. /** Reinhard */
  136580. Reinhard = 1,
  136581. /** HejiDawson */
  136582. HejiDawson = 2,
  136583. /** Photographic */
  136584. Photographic = 3
  136585. }
  136586. /**
  136587. * Defines a post process to apply tone mapping
  136588. */
  136589. export class TonemapPostProcess extends PostProcess {
  136590. private _operator;
  136591. /** Defines the required exposure adjustement */
  136592. exposureAdjustment: number;
  136593. /**
  136594. * Creates a new TonemapPostProcess
  136595. * @param name defines the name of the postprocess
  136596. * @param _operator defines the operator to use
  136597. * @param exposureAdjustment defines the required exposure adjustement
  136598. * @param camera defines the camera to use (can be null)
  136599. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  136600. * @param engine defines the hosting engine (can be ignore if camera is set)
  136601. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  136602. */
  136603. constructor(name: string, _operator: TonemappingOperator,
  136604. /** Defines the required exposure adjustement */
  136605. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  136606. }
  136607. }
  136608. declare module BABYLON {
  136609. /** @hidden */
  136610. export var depthVertexShader: {
  136611. name: string;
  136612. shader: string;
  136613. };
  136614. }
  136615. declare module BABYLON {
  136616. /** @hidden */
  136617. export var volumetricLightScatteringPixelShader: {
  136618. name: string;
  136619. shader: string;
  136620. };
  136621. }
  136622. declare module BABYLON {
  136623. /** @hidden */
  136624. export var volumetricLightScatteringPassVertexShader: {
  136625. name: string;
  136626. shader: string;
  136627. };
  136628. }
  136629. declare module BABYLON {
  136630. /** @hidden */
  136631. export var volumetricLightScatteringPassPixelShader: {
  136632. name: string;
  136633. shader: string;
  136634. };
  136635. }
  136636. declare module BABYLON {
  136637. /**
  136638. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  136639. */
  136640. export class VolumetricLightScatteringPostProcess extends PostProcess {
  136641. private _volumetricLightScatteringPass;
  136642. private _volumetricLightScatteringRTT;
  136643. private _viewPort;
  136644. private _screenCoordinates;
  136645. private _cachedDefines;
  136646. /**
  136647. * If not undefined, the mesh position is computed from the attached node position
  136648. */
  136649. attachedNode: {
  136650. position: Vector3;
  136651. };
  136652. /**
  136653. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  136654. */
  136655. customMeshPosition: Vector3;
  136656. /**
  136657. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  136658. */
  136659. useCustomMeshPosition: boolean;
  136660. /**
  136661. * If the post-process should inverse the light scattering direction
  136662. */
  136663. invert: boolean;
  136664. /**
  136665. * The internal mesh used by the post-process
  136666. */
  136667. mesh: Mesh;
  136668. /**
  136669. * @hidden
  136670. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  136671. */
  136672. get useDiffuseColor(): boolean;
  136673. set useDiffuseColor(useDiffuseColor: boolean);
  136674. /**
  136675. * Array containing the excluded meshes not rendered in the internal pass
  136676. */
  136677. excludedMeshes: AbstractMesh[];
  136678. /**
  136679. * Controls the overall intensity of the post-process
  136680. */
  136681. exposure: number;
  136682. /**
  136683. * Dissipates each sample's contribution in range [0, 1]
  136684. */
  136685. decay: number;
  136686. /**
  136687. * Controls the overall intensity of each sample
  136688. */
  136689. weight: number;
  136690. /**
  136691. * Controls the density of each sample
  136692. */
  136693. density: number;
  136694. /**
  136695. * @constructor
  136696. * @param name The post-process name
  136697. * @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)
  136698. * @param camera The camera that the post-process will be attached to
  136699. * @param mesh The mesh used to create the light scattering
  136700. * @param samples The post-process quality, default 100
  136701. * @param samplingModeThe post-process filtering mode
  136702. * @param engine The babylon engine
  136703. * @param reusable If the post-process is reusable
  136704. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  136705. */
  136706. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  136707. /**
  136708. * Returns the string "VolumetricLightScatteringPostProcess"
  136709. * @returns "VolumetricLightScatteringPostProcess"
  136710. */
  136711. getClassName(): string;
  136712. private _isReady;
  136713. /**
  136714. * Sets the new light position for light scattering effect
  136715. * @param position The new custom light position
  136716. */
  136717. setCustomMeshPosition(position: Vector3): void;
  136718. /**
  136719. * Returns the light position for light scattering effect
  136720. * @return Vector3 The custom light position
  136721. */
  136722. getCustomMeshPosition(): Vector3;
  136723. /**
  136724. * Disposes the internal assets and detaches the post-process from the camera
  136725. */
  136726. dispose(camera: Camera): void;
  136727. /**
  136728. * Returns the render target texture used by the post-process
  136729. * @return the render target texture used by the post-process
  136730. */
  136731. getPass(): RenderTargetTexture;
  136732. private _meshExcluded;
  136733. private _createPass;
  136734. private _updateMeshScreenCoordinates;
  136735. /**
  136736. * Creates a default mesh for the Volumeric Light Scattering post-process
  136737. * @param name The mesh name
  136738. * @param scene The scene where to create the mesh
  136739. * @return the default mesh
  136740. */
  136741. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  136742. }
  136743. }
  136744. declare module BABYLON {
  136745. interface Scene {
  136746. /** @hidden (Backing field) */
  136747. _boundingBoxRenderer: BoundingBoxRenderer;
  136748. /** @hidden (Backing field) */
  136749. _forceShowBoundingBoxes: boolean;
  136750. /**
  136751. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  136752. */
  136753. forceShowBoundingBoxes: boolean;
  136754. /**
  136755. * Gets the bounding box renderer associated with the scene
  136756. * @returns a BoundingBoxRenderer
  136757. */
  136758. getBoundingBoxRenderer(): BoundingBoxRenderer;
  136759. }
  136760. interface AbstractMesh {
  136761. /** @hidden (Backing field) */
  136762. _showBoundingBox: boolean;
  136763. /**
  136764. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  136765. */
  136766. showBoundingBox: boolean;
  136767. }
  136768. /**
  136769. * Component responsible of rendering the bounding box of the meshes in a scene.
  136770. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  136771. */
  136772. export class BoundingBoxRenderer implements ISceneComponent {
  136773. /**
  136774. * The component name helpfull to identify the component in the list of scene components.
  136775. */
  136776. readonly name: string;
  136777. /**
  136778. * The scene the component belongs to.
  136779. */
  136780. scene: Scene;
  136781. /**
  136782. * Color of the bounding box lines placed in front of an object
  136783. */
  136784. frontColor: Color3;
  136785. /**
  136786. * Color of the bounding box lines placed behind an object
  136787. */
  136788. backColor: Color3;
  136789. /**
  136790. * Defines if the renderer should show the back lines or not
  136791. */
  136792. showBackLines: boolean;
  136793. /**
  136794. * @hidden
  136795. */
  136796. renderList: SmartArray<BoundingBox>;
  136797. private _colorShader;
  136798. private _vertexBuffers;
  136799. private _indexBuffer;
  136800. private _fillIndexBuffer;
  136801. private _fillIndexData;
  136802. /**
  136803. * Instantiates a new bounding box renderer in a scene.
  136804. * @param scene the scene the renderer renders in
  136805. */
  136806. constructor(scene: Scene);
  136807. /**
  136808. * Registers the component in a given scene
  136809. */
  136810. register(): void;
  136811. private _evaluateSubMesh;
  136812. private _activeMesh;
  136813. private _prepareRessources;
  136814. private _createIndexBuffer;
  136815. /**
  136816. * Rebuilds the elements related to this component in case of
  136817. * context lost for instance.
  136818. */
  136819. rebuild(): void;
  136820. /**
  136821. * @hidden
  136822. */
  136823. reset(): void;
  136824. /**
  136825. * Render the bounding boxes of a specific rendering group
  136826. * @param renderingGroupId defines the rendering group to render
  136827. */
  136828. render(renderingGroupId: number): void;
  136829. /**
  136830. * In case of occlusion queries, we can render the occlusion bounding box through this method
  136831. * @param mesh Define the mesh to render the occlusion bounding box for
  136832. */
  136833. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  136834. /**
  136835. * Dispose and release the resources attached to this renderer.
  136836. */
  136837. dispose(): void;
  136838. }
  136839. }
  136840. declare module BABYLON {
  136841. /** @hidden */
  136842. export var depthPixelShader: {
  136843. name: string;
  136844. shader: string;
  136845. };
  136846. }
  136847. declare module BABYLON {
  136848. /**
  136849. * This represents a depth renderer in Babylon.
  136850. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  136851. */
  136852. export class DepthRenderer {
  136853. private _scene;
  136854. private _depthMap;
  136855. private _effect;
  136856. private readonly _storeNonLinearDepth;
  136857. private readonly _clearColor;
  136858. /** Get if the depth renderer is using packed depth or not */
  136859. readonly isPacked: boolean;
  136860. private _cachedDefines;
  136861. private _camera;
  136862. /**
  136863. * Specifiess that the depth renderer will only be used within
  136864. * the camera it is created for.
  136865. * This can help forcing its rendering during the camera processing.
  136866. */
  136867. useOnlyInActiveCamera: boolean;
  136868. /** @hidden */
  136869. static _SceneComponentInitialization: (scene: Scene) => void;
  136870. /**
  136871. * Instantiates a depth renderer
  136872. * @param scene The scene the renderer belongs to
  136873. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  136874. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  136875. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136876. */
  136877. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  136878. /**
  136879. * Creates the depth rendering effect and checks if the effect is ready.
  136880. * @param subMesh The submesh to be used to render the depth map of
  136881. * @param useInstances If multiple world instances should be used
  136882. * @returns if the depth renderer is ready to render the depth map
  136883. */
  136884. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136885. /**
  136886. * Gets the texture which the depth map will be written to.
  136887. * @returns The depth map texture
  136888. */
  136889. getDepthMap(): RenderTargetTexture;
  136890. /**
  136891. * Disposes of the depth renderer.
  136892. */
  136893. dispose(): void;
  136894. }
  136895. }
  136896. declare module BABYLON {
  136897. interface Scene {
  136898. /** @hidden (Backing field) */
  136899. _depthRenderer: {
  136900. [id: string]: DepthRenderer;
  136901. };
  136902. /**
  136903. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  136904. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  136905. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136906. * @returns the created depth renderer
  136907. */
  136908. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  136909. /**
  136910. * Disables a depth renderer for a given camera
  136911. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  136912. */
  136913. disableDepthRenderer(camera?: Nullable<Camera>): void;
  136914. }
  136915. /**
  136916. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  136917. * in several rendering techniques.
  136918. */
  136919. export class DepthRendererSceneComponent implements ISceneComponent {
  136920. /**
  136921. * The component name helpfull to identify the component in the list of scene components.
  136922. */
  136923. readonly name: string;
  136924. /**
  136925. * The scene the component belongs to.
  136926. */
  136927. scene: Scene;
  136928. /**
  136929. * Creates a new instance of the component for the given scene
  136930. * @param scene Defines the scene to register the component in
  136931. */
  136932. constructor(scene: Scene);
  136933. /**
  136934. * Registers the component in a given scene
  136935. */
  136936. register(): void;
  136937. /**
  136938. * Rebuilds the elements related to this component in case of
  136939. * context lost for instance.
  136940. */
  136941. rebuild(): void;
  136942. /**
  136943. * Disposes the component and the associated ressources
  136944. */
  136945. dispose(): void;
  136946. private _gatherRenderTargets;
  136947. private _gatherActiveCameraRenderTargets;
  136948. }
  136949. }
  136950. declare module BABYLON {
  136951. /** @hidden */
  136952. export var outlinePixelShader: {
  136953. name: string;
  136954. shader: string;
  136955. };
  136956. }
  136957. declare module BABYLON {
  136958. /** @hidden */
  136959. export var outlineVertexShader: {
  136960. name: string;
  136961. shader: string;
  136962. };
  136963. }
  136964. declare module BABYLON {
  136965. interface Scene {
  136966. /** @hidden */
  136967. _outlineRenderer: OutlineRenderer;
  136968. /**
  136969. * Gets the outline renderer associated with the scene
  136970. * @returns a OutlineRenderer
  136971. */
  136972. getOutlineRenderer(): OutlineRenderer;
  136973. }
  136974. interface AbstractMesh {
  136975. /** @hidden (Backing field) */
  136976. _renderOutline: boolean;
  136977. /**
  136978. * Gets or sets a boolean indicating if the outline must be rendered as well
  136979. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  136980. */
  136981. renderOutline: boolean;
  136982. /** @hidden (Backing field) */
  136983. _renderOverlay: boolean;
  136984. /**
  136985. * Gets or sets a boolean indicating if the overlay must be rendered as well
  136986. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  136987. */
  136988. renderOverlay: boolean;
  136989. }
  136990. /**
  136991. * This class is responsible to draw bothe outline/overlay of meshes.
  136992. * It should not be used directly but through the available method on mesh.
  136993. */
  136994. export class OutlineRenderer implements ISceneComponent {
  136995. /**
  136996. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  136997. */
  136998. private static _StencilReference;
  136999. /**
  137000. * The name of the component. Each component must have a unique name.
  137001. */
  137002. name: string;
  137003. /**
  137004. * The scene the component belongs to.
  137005. */
  137006. scene: Scene;
  137007. /**
  137008. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  137009. */
  137010. zOffset: number;
  137011. private _engine;
  137012. private _effect;
  137013. private _cachedDefines;
  137014. private _savedDepthWrite;
  137015. /**
  137016. * Instantiates a new outline renderer. (There could be only one per scene).
  137017. * @param scene Defines the scene it belongs to
  137018. */
  137019. constructor(scene: Scene);
  137020. /**
  137021. * Register the component to one instance of a scene.
  137022. */
  137023. register(): void;
  137024. /**
  137025. * Rebuilds the elements related to this component in case of
  137026. * context lost for instance.
  137027. */
  137028. rebuild(): void;
  137029. /**
  137030. * Disposes the component and the associated ressources.
  137031. */
  137032. dispose(): void;
  137033. /**
  137034. * Renders the outline in the canvas.
  137035. * @param subMesh Defines the sumesh to render
  137036. * @param batch Defines the batch of meshes in case of instances
  137037. * @param useOverlay Defines if the rendering is for the overlay or the outline
  137038. */
  137039. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  137040. /**
  137041. * Returns whether or not the outline renderer is ready for a given submesh.
  137042. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  137043. * @param subMesh Defines the submesh to check readyness for
  137044. * @param useInstances Defines wheter wee are trying to render instances or not
  137045. * @returns true if ready otherwise false
  137046. */
  137047. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137048. private _beforeRenderingMesh;
  137049. private _afterRenderingMesh;
  137050. }
  137051. }
  137052. declare module BABYLON {
  137053. /**
  137054. * Defines the basic options interface of a Sprite Frame Source Size.
  137055. */
  137056. export interface ISpriteJSONSpriteSourceSize {
  137057. /**
  137058. * number of the original width of the Frame
  137059. */
  137060. w: number;
  137061. /**
  137062. * number of the original height of the Frame
  137063. */
  137064. h: number;
  137065. }
  137066. /**
  137067. * Defines the basic options interface of a Sprite Frame Data.
  137068. */
  137069. export interface ISpriteJSONSpriteFrameData {
  137070. /**
  137071. * number of the x offset of the Frame
  137072. */
  137073. x: number;
  137074. /**
  137075. * number of the y offset of the Frame
  137076. */
  137077. y: number;
  137078. /**
  137079. * number of the width of the Frame
  137080. */
  137081. w: number;
  137082. /**
  137083. * number of the height of the Frame
  137084. */
  137085. h: number;
  137086. }
  137087. /**
  137088. * Defines the basic options interface of a JSON Sprite.
  137089. */
  137090. export interface ISpriteJSONSprite {
  137091. /**
  137092. * string name of the Frame
  137093. */
  137094. filename: string;
  137095. /**
  137096. * ISpriteJSONSpriteFrame basic object of the frame data
  137097. */
  137098. frame: ISpriteJSONSpriteFrameData;
  137099. /**
  137100. * boolean to flag is the frame was rotated.
  137101. */
  137102. rotated: boolean;
  137103. /**
  137104. * boolean to flag is the frame was trimmed.
  137105. */
  137106. trimmed: boolean;
  137107. /**
  137108. * ISpriteJSONSpriteFrame basic object of the source data
  137109. */
  137110. spriteSourceSize: ISpriteJSONSpriteFrameData;
  137111. /**
  137112. * ISpriteJSONSpriteFrame basic object of the source data
  137113. */
  137114. sourceSize: ISpriteJSONSpriteSourceSize;
  137115. }
  137116. /**
  137117. * Defines the basic options interface of a JSON atlas.
  137118. */
  137119. export interface ISpriteJSONAtlas {
  137120. /**
  137121. * Array of objects that contain the frame data.
  137122. */
  137123. frames: Array<ISpriteJSONSprite>;
  137124. /**
  137125. * object basic object containing the sprite meta data.
  137126. */
  137127. meta?: object;
  137128. }
  137129. }
  137130. declare module BABYLON {
  137131. /** @hidden */
  137132. export var spriteMapPixelShader: {
  137133. name: string;
  137134. shader: string;
  137135. };
  137136. }
  137137. declare module BABYLON {
  137138. /** @hidden */
  137139. export var spriteMapVertexShader: {
  137140. name: string;
  137141. shader: string;
  137142. };
  137143. }
  137144. declare module BABYLON {
  137145. /**
  137146. * Defines the basic options interface of a SpriteMap
  137147. */
  137148. export interface ISpriteMapOptions {
  137149. /**
  137150. * Vector2 of the number of cells in the grid.
  137151. */
  137152. stageSize?: Vector2;
  137153. /**
  137154. * Vector2 of the size of the output plane in World Units.
  137155. */
  137156. outputSize?: Vector2;
  137157. /**
  137158. * Vector3 of the position of the output plane in World Units.
  137159. */
  137160. outputPosition?: Vector3;
  137161. /**
  137162. * Vector3 of the rotation of the output plane.
  137163. */
  137164. outputRotation?: Vector3;
  137165. /**
  137166. * number of layers that the system will reserve in resources.
  137167. */
  137168. layerCount?: number;
  137169. /**
  137170. * number of max animation frames a single cell will reserve in resources.
  137171. */
  137172. maxAnimationFrames?: number;
  137173. /**
  137174. * number cell index of the base tile when the system compiles.
  137175. */
  137176. baseTile?: number;
  137177. /**
  137178. * boolean flip the sprite after its been repositioned by the framing data.
  137179. */
  137180. flipU?: boolean;
  137181. /**
  137182. * Vector3 scalar of the global RGB values of the SpriteMap.
  137183. */
  137184. colorMultiply?: Vector3;
  137185. }
  137186. /**
  137187. * Defines the IDisposable interface in order to be cleanable from resources.
  137188. */
  137189. export interface ISpriteMap extends IDisposable {
  137190. /**
  137191. * String name of the SpriteMap.
  137192. */
  137193. name: string;
  137194. /**
  137195. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  137196. */
  137197. atlasJSON: ISpriteJSONAtlas;
  137198. /**
  137199. * Texture of the SpriteMap.
  137200. */
  137201. spriteSheet: Texture;
  137202. /**
  137203. * The parameters to initialize the SpriteMap with.
  137204. */
  137205. options: ISpriteMapOptions;
  137206. }
  137207. /**
  137208. * Class used to manage a grid restricted sprite deployment on an Output plane.
  137209. */
  137210. export class SpriteMap implements ISpriteMap {
  137211. /** The Name of the spriteMap */
  137212. name: string;
  137213. /** The JSON file with the frame and meta data */
  137214. atlasJSON: ISpriteJSONAtlas;
  137215. /** The systems Sprite Sheet Texture */
  137216. spriteSheet: Texture;
  137217. /** Arguments passed with the Constructor */
  137218. options: ISpriteMapOptions;
  137219. /** Public Sprite Storage array, parsed from atlasJSON */
  137220. sprites: Array<ISpriteJSONSprite>;
  137221. /** Returns the Number of Sprites in the System */
  137222. get spriteCount(): number;
  137223. /** Returns the Position of Output Plane*/
  137224. get position(): Vector3;
  137225. /** Returns the Position of Output Plane*/
  137226. set position(v: Vector3);
  137227. /** Returns the Rotation of Output Plane*/
  137228. get rotation(): Vector3;
  137229. /** Returns the Rotation of Output Plane*/
  137230. set rotation(v: Vector3);
  137231. /** Sets the AnimationMap*/
  137232. get animationMap(): RawTexture;
  137233. /** Sets the AnimationMap*/
  137234. set animationMap(v: RawTexture);
  137235. /** Scene that the SpriteMap was created in */
  137236. private _scene;
  137237. /** Texture Buffer of Float32 that holds tile frame data*/
  137238. private _frameMap;
  137239. /** Texture Buffers of Float32 that holds tileMap data*/
  137240. private _tileMaps;
  137241. /** Texture Buffer of Float32 that holds Animation Data*/
  137242. private _animationMap;
  137243. /** Custom ShaderMaterial Central to the System*/
  137244. private _material;
  137245. /** Custom ShaderMaterial Central to the System*/
  137246. private _output;
  137247. /** Systems Time Ticker*/
  137248. private _time;
  137249. /**
  137250. * Creates a new SpriteMap
  137251. * @param name defines the SpriteMaps Name
  137252. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  137253. * @param spriteSheet is the Texture that the Sprites are on.
  137254. * @param options a basic deployment configuration
  137255. * @param scene The Scene that the map is deployed on
  137256. */
  137257. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  137258. /**
  137259. * Returns tileID location
  137260. * @returns Vector2 the cell position ID
  137261. */
  137262. getTileID(): Vector2;
  137263. /**
  137264. * Gets the UV location of the mouse over the SpriteMap.
  137265. * @returns Vector2 the UV position of the mouse interaction
  137266. */
  137267. getMousePosition(): Vector2;
  137268. /**
  137269. * Creates the "frame" texture Buffer
  137270. * -------------------------------------
  137271. * Structure of frames
  137272. * "filename": "Falling-Water-2.png",
  137273. * "frame": {"x":69,"y":103,"w":24,"h":32},
  137274. * "rotated": true,
  137275. * "trimmed": true,
  137276. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  137277. * "sourceSize": {"w":32,"h":32}
  137278. * @returns RawTexture of the frameMap
  137279. */
  137280. private _createFrameBuffer;
  137281. /**
  137282. * Creates the tileMap texture Buffer
  137283. * @param buffer normally and array of numbers, or a false to generate from scratch
  137284. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  137285. * @returns RawTexture of the tileMap
  137286. */
  137287. private _createTileBuffer;
  137288. /**
  137289. * Modifies the data of the tileMaps
  137290. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  137291. * @param pos is the iVector2 Coordinates of the Tile
  137292. * @param tile The SpriteIndex of the new Tile
  137293. */
  137294. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  137295. /**
  137296. * Creates the animationMap texture Buffer
  137297. * @param buffer normally and array of numbers, or a false to generate from scratch
  137298. * @returns RawTexture of the animationMap
  137299. */
  137300. private _createTileAnimationBuffer;
  137301. /**
  137302. * Modifies the data of the animationMap
  137303. * @param cellID is the Index of the Sprite
  137304. * @param _frame is the target Animation frame
  137305. * @param toCell is the Target Index of the next frame of the animation
  137306. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  137307. * @param speed is a global scalar of the time variable on the map.
  137308. */
  137309. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  137310. /**
  137311. * Exports the .tilemaps file
  137312. */
  137313. saveTileMaps(): void;
  137314. /**
  137315. * Imports the .tilemaps file
  137316. * @param url of the .tilemaps file
  137317. */
  137318. loadTileMaps(url: string): void;
  137319. /**
  137320. * Release associated resources
  137321. */
  137322. dispose(): void;
  137323. }
  137324. }
  137325. declare module BABYLON {
  137326. /**
  137327. * Class used to manage multiple sprites of different sizes on the same spritesheet
  137328. * @see http://doc.babylonjs.com/babylon101/sprites
  137329. */
  137330. export class SpritePackedManager extends SpriteManager {
  137331. /** defines the packed manager's name */
  137332. name: string;
  137333. /**
  137334. * Creates a new sprite manager from a packed sprite sheet
  137335. * @param name defines the manager's name
  137336. * @param imgUrl defines the sprite sheet url
  137337. * @param capacity defines the maximum allowed number of sprites
  137338. * @param scene defines the hosting scene
  137339. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  137340. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  137341. * @param samplingMode defines the smapling mode to use with spritesheet
  137342. * @param fromPacked set to true; do not alter
  137343. */
  137344. constructor(
  137345. /** defines the packed manager's name */
  137346. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  137347. }
  137348. }
  137349. declare module BABYLON {
  137350. /**
  137351. * Defines the list of states available for a task inside a AssetsManager
  137352. */
  137353. export enum AssetTaskState {
  137354. /**
  137355. * Initialization
  137356. */
  137357. INIT = 0,
  137358. /**
  137359. * Running
  137360. */
  137361. RUNNING = 1,
  137362. /**
  137363. * Done
  137364. */
  137365. DONE = 2,
  137366. /**
  137367. * Error
  137368. */
  137369. ERROR = 3
  137370. }
  137371. /**
  137372. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  137373. */
  137374. export abstract class AbstractAssetTask {
  137375. /**
  137376. * Task name
  137377. */ name: string;
  137378. /**
  137379. * Callback called when the task is successful
  137380. */
  137381. onSuccess: (task: any) => void;
  137382. /**
  137383. * Callback called when the task is not successful
  137384. */
  137385. onError: (task: any, message?: string, exception?: any) => void;
  137386. /**
  137387. * Creates a new AssetsManager
  137388. * @param name defines the name of the task
  137389. */
  137390. constructor(
  137391. /**
  137392. * Task name
  137393. */ name: string);
  137394. private _isCompleted;
  137395. private _taskState;
  137396. private _errorObject;
  137397. /**
  137398. * Get if the task is completed
  137399. */
  137400. get isCompleted(): boolean;
  137401. /**
  137402. * Gets the current state of the task
  137403. */
  137404. get taskState(): AssetTaskState;
  137405. /**
  137406. * Gets the current error object (if task is in error)
  137407. */
  137408. get errorObject(): {
  137409. message?: string;
  137410. exception?: any;
  137411. };
  137412. /**
  137413. * Internal only
  137414. * @hidden
  137415. */
  137416. _setErrorObject(message?: string, exception?: any): void;
  137417. /**
  137418. * Execute the current task
  137419. * @param scene defines the scene where you want your assets to be loaded
  137420. * @param onSuccess is a callback called when the task is successfully executed
  137421. * @param onError is a callback called if an error occurs
  137422. */
  137423. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137424. /**
  137425. * Execute the current task
  137426. * @param scene defines the scene where you want your assets to be loaded
  137427. * @param onSuccess is a callback called when the task is successfully executed
  137428. * @param onError is a callback called if an error occurs
  137429. */
  137430. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137431. /**
  137432. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  137433. * This can be used with failed tasks that have the reason for failure fixed.
  137434. */
  137435. reset(): void;
  137436. private onErrorCallback;
  137437. private onDoneCallback;
  137438. }
  137439. /**
  137440. * Define the interface used by progress events raised during assets loading
  137441. */
  137442. export interface IAssetsProgressEvent {
  137443. /**
  137444. * Defines the number of remaining tasks to process
  137445. */
  137446. remainingCount: number;
  137447. /**
  137448. * Defines the total number of tasks
  137449. */
  137450. totalCount: number;
  137451. /**
  137452. * Defines the task that was just processed
  137453. */
  137454. task: AbstractAssetTask;
  137455. }
  137456. /**
  137457. * Class used to share progress information about assets loading
  137458. */
  137459. export class AssetsProgressEvent implements IAssetsProgressEvent {
  137460. /**
  137461. * Defines the number of remaining tasks to process
  137462. */
  137463. remainingCount: number;
  137464. /**
  137465. * Defines the total number of tasks
  137466. */
  137467. totalCount: number;
  137468. /**
  137469. * Defines the task that was just processed
  137470. */
  137471. task: AbstractAssetTask;
  137472. /**
  137473. * Creates a AssetsProgressEvent
  137474. * @param remainingCount defines the number of remaining tasks to process
  137475. * @param totalCount defines the total number of tasks
  137476. * @param task defines the task that was just processed
  137477. */
  137478. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  137479. }
  137480. /**
  137481. * Define a task used by AssetsManager to load meshes
  137482. */
  137483. export class MeshAssetTask extends AbstractAssetTask {
  137484. /**
  137485. * Defines the name of the task
  137486. */
  137487. name: string;
  137488. /**
  137489. * Defines the list of mesh's names you want to load
  137490. */
  137491. meshesNames: any;
  137492. /**
  137493. * Defines the root url to use as a base to load your meshes and associated resources
  137494. */
  137495. rootUrl: string;
  137496. /**
  137497. * Defines the filename of the scene to load from
  137498. */
  137499. sceneFilename: string;
  137500. /**
  137501. * Gets the list of loaded meshes
  137502. */
  137503. loadedMeshes: Array<AbstractMesh>;
  137504. /**
  137505. * Gets the list of loaded particle systems
  137506. */
  137507. loadedParticleSystems: Array<IParticleSystem>;
  137508. /**
  137509. * Gets the list of loaded skeletons
  137510. */
  137511. loadedSkeletons: Array<Skeleton>;
  137512. /**
  137513. * Gets the list of loaded animation groups
  137514. */
  137515. loadedAnimationGroups: Array<AnimationGroup>;
  137516. /**
  137517. * Callback called when the task is successful
  137518. */
  137519. onSuccess: (task: MeshAssetTask) => void;
  137520. /**
  137521. * Callback called when the task is successful
  137522. */
  137523. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  137524. /**
  137525. * Creates a new MeshAssetTask
  137526. * @param name defines the name of the task
  137527. * @param meshesNames defines the list of mesh's names you want to load
  137528. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  137529. * @param sceneFilename defines the filename of the scene to load from
  137530. */
  137531. constructor(
  137532. /**
  137533. * Defines the name of the task
  137534. */
  137535. name: string,
  137536. /**
  137537. * Defines the list of mesh's names you want to load
  137538. */
  137539. meshesNames: any,
  137540. /**
  137541. * Defines the root url to use as a base to load your meshes and associated resources
  137542. */
  137543. rootUrl: string,
  137544. /**
  137545. * Defines the filename of the scene to load from
  137546. */
  137547. sceneFilename: string);
  137548. /**
  137549. * Execute the current task
  137550. * @param scene defines the scene where you want your assets to be loaded
  137551. * @param onSuccess is a callback called when the task is successfully executed
  137552. * @param onError is a callback called if an error occurs
  137553. */
  137554. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137555. }
  137556. /**
  137557. * Define a task used by AssetsManager to load text content
  137558. */
  137559. export class TextFileAssetTask extends AbstractAssetTask {
  137560. /**
  137561. * Defines the name of the task
  137562. */
  137563. name: string;
  137564. /**
  137565. * Defines the location of the file to load
  137566. */
  137567. url: string;
  137568. /**
  137569. * Gets the loaded text string
  137570. */
  137571. text: string;
  137572. /**
  137573. * Callback called when the task is successful
  137574. */
  137575. onSuccess: (task: TextFileAssetTask) => void;
  137576. /**
  137577. * Callback called when the task is successful
  137578. */
  137579. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  137580. /**
  137581. * Creates a new TextFileAssetTask object
  137582. * @param name defines the name of the task
  137583. * @param url defines the location of the file to load
  137584. */
  137585. constructor(
  137586. /**
  137587. * Defines the name of the task
  137588. */
  137589. name: string,
  137590. /**
  137591. * Defines the location of the file to load
  137592. */
  137593. url: string);
  137594. /**
  137595. * Execute the current task
  137596. * @param scene defines the scene where you want your assets to be loaded
  137597. * @param onSuccess is a callback called when the task is successfully executed
  137598. * @param onError is a callback called if an error occurs
  137599. */
  137600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137601. }
  137602. /**
  137603. * Define a task used by AssetsManager to load binary data
  137604. */
  137605. export class BinaryFileAssetTask extends AbstractAssetTask {
  137606. /**
  137607. * Defines the name of the task
  137608. */
  137609. name: string;
  137610. /**
  137611. * Defines the location of the file to load
  137612. */
  137613. url: string;
  137614. /**
  137615. * Gets the lodaded data (as an array buffer)
  137616. */
  137617. data: ArrayBuffer;
  137618. /**
  137619. * Callback called when the task is successful
  137620. */
  137621. onSuccess: (task: BinaryFileAssetTask) => void;
  137622. /**
  137623. * Callback called when the task is successful
  137624. */
  137625. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  137626. /**
  137627. * Creates a new BinaryFileAssetTask object
  137628. * @param name defines the name of the new task
  137629. * @param url defines the location of the file to load
  137630. */
  137631. constructor(
  137632. /**
  137633. * Defines the name of the task
  137634. */
  137635. name: string,
  137636. /**
  137637. * Defines the location of the file to load
  137638. */
  137639. url: string);
  137640. /**
  137641. * Execute the current task
  137642. * @param scene defines the scene where you want your assets to be loaded
  137643. * @param onSuccess is a callback called when the task is successfully executed
  137644. * @param onError is a callback called if an error occurs
  137645. */
  137646. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137647. }
  137648. /**
  137649. * Define a task used by AssetsManager to load images
  137650. */
  137651. export class ImageAssetTask extends AbstractAssetTask {
  137652. /**
  137653. * Defines the name of the task
  137654. */
  137655. name: string;
  137656. /**
  137657. * Defines the location of the image to load
  137658. */
  137659. url: string;
  137660. /**
  137661. * Gets the loaded images
  137662. */
  137663. image: HTMLImageElement;
  137664. /**
  137665. * Callback called when the task is successful
  137666. */
  137667. onSuccess: (task: ImageAssetTask) => void;
  137668. /**
  137669. * Callback called when the task is successful
  137670. */
  137671. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  137672. /**
  137673. * Creates a new ImageAssetTask
  137674. * @param name defines the name of the task
  137675. * @param url defines the location of the image to load
  137676. */
  137677. constructor(
  137678. /**
  137679. * Defines the name of the task
  137680. */
  137681. name: string,
  137682. /**
  137683. * Defines the location of the image to load
  137684. */
  137685. url: string);
  137686. /**
  137687. * Execute the current task
  137688. * @param scene defines the scene where you want your assets to be loaded
  137689. * @param onSuccess is a callback called when the task is successfully executed
  137690. * @param onError is a callback called if an error occurs
  137691. */
  137692. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137693. }
  137694. /**
  137695. * Defines the interface used by texture loading tasks
  137696. */
  137697. export interface ITextureAssetTask<TEX extends BaseTexture> {
  137698. /**
  137699. * Gets the loaded texture
  137700. */
  137701. texture: TEX;
  137702. }
  137703. /**
  137704. * Define a task used by AssetsManager to load 2D textures
  137705. */
  137706. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  137707. /**
  137708. * Defines the name of the task
  137709. */
  137710. name: string;
  137711. /**
  137712. * Defines the location of the file to load
  137713. */
  137714. url: string;
  137715. /**
  137716. * Defines if mipmap should not be generated (default is false)
  137717. */
  137718. noMipmap?: boolean | undefined;
  137719. /**
  137720. * Defines if texture must be inverted on Y axis (default is false)
  137721. */
  137722. invertY?: boolean | undefined;
  137723. /**
  137724. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  137725. */
  137726. samplingMode: number;
  137727. /**
  137728. * Gets the loaded texture
  137729. */
  137730. texture: Texture;
  137731. /**
  137732. * Callback called when the task is successful
  137733. */
  137734. onSuccess: (task: TextureAssetTask) => void;
  137735. /**
  137736. * Callback called when the task is successful
  137737. */
  137738. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  137739. /**
  137740. * Creates a new TextureAssetTask object
  137741. * @param name defines the name of the task
  137742. * @param url defines the location of the file to load
  137743. * @param noMipmap defines if mipmap should not be generated (default is false)
  137744. * @param invertY defines if texture must be inverted on Y axis (default is false)
  137745. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  137746. */
  137747. constructor(
  137748. /**
  137749. * Defines the name of the task
  137750. */
  137751. name: string,
  137752. /**
  137753. * Defines the location of the file to load
  137754. */
  137755. url: string,
  137756. /**
  137757. * Defines if mipmap should not be generated (default is false)
  137758. */
  137759. noMipmap?: boolean | undefined,
  137760. /**
  137761. * Defines if texture must be inverted on Y axis (default is false)
  137762. */
  137763. invertY?: boolean | undefined,
  137764. /**
  137765. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  137766. */
  137767. samplingMode?: number);
  137768. /**
  137769. * Execute the current task
  137770. * @param scene defines the scene where you want your assets to be loaded
  137771. * @param onSuccess is a callback called when the task is successfully executed
  137772. * @param onError is a callback called if an error occurs
  137773. */
  137774. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137775. }
  137776. /**
  137777. * Define a task used by AssetsManager to load cube textures
  137778. */
  137779. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  137780. /**
  137781. * Defines the name of the task
  137782. */
  137783. name: string;
  137784. /**
  137785. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  137786. */
  137787. url: string;
  137788. /**
  137789. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  137790. */
  137791. extensions?: string[] | undefined;
  137792. /**
  137793. * Defines if mipmaps should not be generated (default is false)
  137794. */
  137795. noMipmap?: boolean | undefined;
  137796. /**
  137797. * Defines the explicit list of files (undefined by default)
  137798. */
  137799. files?: string[] | undefined;
  137800. /**
  137801. * Gets the loaded texture
  137802. */
  137803. texture: CubeTexture;
  137804. /**
  137805. * Callback called when the task is successful
  137806. */
  137807. onSuccess: (task: CubeTextureAssetTask) => void;
  137808. /**
  137809. * Callback called when the task is successful
  137810. */
  137811. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  137812. /**
  137813. * Creates a new CubeTextureAssetTask
  137814. * @param name defines the name of the task
  137815. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  137816. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  137817. * @param noMipmap defines if mipmaps should not be generated (default is false)
  137818. * @param files defines the explicit list of files (undefined by default)
  137819. */
  137820. constructor(
  137821. /**
  137822. * Defines the name of the task
  137823. */
  137824. name: string,
  137825. /**
  137826. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  137827. */
  137828. url: string,
  137829. /**
  137830. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  137831. */
  137832. extensions?: string[] | undefined,
  137833. /**
  137834. * Defines if mipmaps should not be generated (default is false)
  137835. */
  137836. noMipmap?: boolean | undefined,
  137837. /**
  137838. * Defines the explicit list of files (undefined by default)
  137839. */
  137840. files?: string[] | undefined);
  137841. /**
  137842. * Execute the current task
  137843. * @param scene defines the scene where you want your assets to be loaded
  137844. * @param onSuccess is a callback called when the task is successfully executed
  137845. * @param onError is a callback called if an error occurs
  137846. */
  137847. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137848. }
  137849. /**
  137850. * Define a task used by AssetsManager to load HDR cube textures
  137851. */
  137852. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  137853. /**
  137854. * Defines the name of the task
  137855. */
  137856. name: string;
  137857. /**
  137858. * Defines the location of the file to load
  137859. */
  137860. url: string;
  137861. /**
  137862. * Defines the desired size (the more it increases the longer the generation will be)
  137863. */
  137864. size: number;
  137865. /**
  137866. * Defines if mipmaps should not be generated (default is false)
  137867. */
  137868. noMipmap: boolean;
  137869. /**
  137870. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  137871. */
  137872. generateHarmonics: boolean;
  137873. /**
  137874. * 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)
  137875. */
  137876. gammaSpace: boolean;
  137877. /**
  137878. * Internal Use Only
  137879. */
  137880. reserved: boolean;
  137881. /**
  137882. * Gets the loaded texture
  137883. */
  137884. texture: HDRCubeTexture;
  137885. /**
  137886. * Callback called when the task is successful
  137887. */
  137888. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  137889. /**
  137890. * Callback called when the task is successful
  137891. */
  137892. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  137893. /**
  137894. * Creates a new HDRCubeTextureAssetTask object
  137895. * @param name defines the name of the task
  137896. * @param url defines the location of the file to load
  137897. * @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.
  137898. * @param noMipmap defines if mipmaps should not be generated (default is false)
  137899. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  137900. * @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)
  137901. * @param reserved Internal use only
  137902. */
  137903. constructor(
  137904. /**
  137905. * Defines the name of the task
  137906. */
  137907. name: string,
  137908. /**
  137909. * Defines the location of the file to load
  137910. */
  137911. url: string,
  137912. /**
  137913. * Defines the desired size (the more it increases the longer the generation will be)
  137914. */
  137915. size: number,
  137916. /**
  137917. * Defines if mipmaps should not be generated (default is false)
  137918. */
  137919. noMipmap?: boolean,
  137920. /**
  137921. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  137922. */
  137923. generateHarmonics?: boolean,
  137924. /**
  137925. * 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)
  137926. */
  137927. gammaSpace?: boolean,
  137928. /**
  137929. * Internal Use Only
  137930. */
  137931. reserved?: boolean);
  137932. /**
  137933. * Execute the current task
  137934. * @param scene defines the scene where you want your assets to be loaded
  137935. * @param onSuccess is a callback called when the task is successfully executed
  137936. * @param onError is a callback called if an error occurs
  137937. */
  137938. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137939. }
  137940. /**
  137941. * Define a task used by AssetsManager to load Equirectangular cube textures
  137942. */
  137943. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  137944. /**
  137945. * Defines the name of the task
  137946. */
  137947. name: string;
  137948. /**
  137949. * Defines the location of the file to load
  137950. */
  137951. url: string;
  137952. /**
  137953. * Defines the desired size (the more it increases the longer the generation will be)
  137954. */
  137955. size: number;
  137956. /**
  137957. * Defines if mipmaps should not be generated (default is false)
  137958. */
  137959. noMipmap: boolean;
  137960. /**
  137961. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  137962. * but the standard material would require them in Gamma space) (default is true)
  137963. */
  137964. gammaSpace: boolean;
  137965. /**
  137966. * Gets the loaded texture
  137967. */
  137968. texture: EquiRectangularCubeTexture;
  137969. /**
  137970. * Callback called when the task is successful
  137971. */
  137972. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  137973. /**
  137974. * Callback called when the task is successful
  137975. */
  137976. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  137977. /**
  137978. * Creates a new EquiRectangularCubeTextureAssetTask object
  137979. * @param name defines the name of the task
  137980. * @param url defines the location of the file to load
  137981. * @param size defines the desired size (the more it increases the longer the generation will be)
  137982. * If the size is omitted this implies you are using a preprocessed cubemap.
  137983. * @param noMipmap defines if mipmaps should not be generated (default is false)
  137984. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  137985. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  137986. * (default is true)
  137987. */
  137988. constructor(
  137989. /**
  137990. * Defines the name of the task
  137991. */
  137992. name: string,
  137993. /**
  137994. * Defines the location of the file to load
  137995. */
  137996. url: string,
  137997. /**
  137998. * Defines the desired size (the more it increases the longer the generation will be)
  137999. */
  138000. size: number,
  138001. /**
  138002. * Defines if mipmaps should not be generated (default is false)
  138003. */
  138004. noMipmap?: boolean,
  138005. /**
  138006. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  138007. * but the standard material would require them in Gamma space) (default is true)
  138008. */
  138009. gammaSpace?: boolean);
  138010. /**
  138011. * Execute the current task
  138012. * @param scene defines the scene where you want your assets to be loaded
  138013. * @param onSuccess is a callback called when the task is successfully executed
  138014. * @param onError is a callback called if an error occurs
  138015. */
  138016. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  138017. }
  138018. /**
  138019. * This class can be used to easily import assets into a scene
  138020. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  138021. */
  138022. export class AssetsManager {
  138023. private _scene;
  138024. private _isLoading;
  138025. protected _tasks: AbstractAssetTask[];
  138026. protected _waitingTasksCount: number;
  138027. protected _totalTasksCount: number;
  138028. /**
  138029. * Callback called when all tasks are processed
  138030. */
  138031. onFinish: (tasks: AbstractAssetTask[]) => void;
  138032. /**
  138033. * Callback called when a task is successful
  138034. */
  138035. onTaskSuccess: (task: AbstractAssetTask) => void;
  138036. /**
  138037. * Callback called when a task had an error
  138038. */
  138039. onTaskError: (task: AbstractAssetTask) => void;
  138040. /**
  138041. * Callback called when a task is done (whatever the result is)
  138042. */
  138043. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  138044. /**
  138045. * Observable called when all tasks are processed
  138046. */
  138047. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  138048. /**
  138049. * Observable called when a task had an error
  138050. */
  138051. onTaskErrorObservable: Observable<AbstractAssetTask>;
  138052. /**
  138053. * Observable called when all tasks were executed
  138054. */
  138055. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  138056. /**
  138057. * Observable called when a task is done (whatever the result is)
  138058. */
  138059. onProgressObservable: Observable<IAssetsProgressEvent>;
  138060. /**
  138061. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  138062. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  138063. */
  138064. useDefaultLoadingScreen: boolean;
  138065. /**
  138066. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  138067. * when all assets have been downloaded.
  138068. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  138069. */
  138070. autoHideLoadingUI: boolean;
  138071. /**
  138072. * Creates a new AssetsManager
  138073. * @param scene defines the scene to work on
  138074. */
  138075. constructor(scene: Scene);
  138076. /**
  138077. * Add a MeshAssetTask to the list of active tasks
  138078. * @param taskName defines the name of the new task
  138079. * @param meshesNames defines the name of meshes to load
  138080. * @param rootUrl defines the root url to use to locate files
  138081. * @param sceneFilename defines the filename of the scene file
  138082. * @returns a new MeshAssetTask object
  138083. */
  138084. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  138085. /**
  138086. * Add a TextFileAssetTask to the list of active tasks
  138087. * @param taskName defines the name of the new task
  138088. * @param url defines the url of the file to load
  138089. * @returns a new TextFileAssetTask object
  138090. */
  138091. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  138092. /**
  138093. * Add a BinaryFileAssetTask to the list of active tasks
  138094. * @param taskName defines the name of the new task
  138095. * @param url defines the url of the file to load
  138096. * @returns a new BinaryFileAssetTask object
  138097. */
  138098. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  138099. /**
  138100. * Add a ImageAssetTask to the list of active tasks
  138101. * @param taskName defines the name of the new task
  138102. * @param url defines the url of the file to load
  138103. * @returns a new ImageAssetTask object
  138104. */
  138105. addImageTask(taskName: string, url: string): ImageAssetTask;
  138106. /**
  138107. * Add a TextureAssetTask to the list of active tasks
  138108. * @param taskName defines the name of the new task
  138109. * @param url defines the url of the file to load
  138110. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  138111. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  138112. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138113. * @returns a new TextureAssetTask object
  138114. */
  138115. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  138116. /**
  138117. * Add a CubeTextureAssetTask to the list of active tasks
  138118. * @param taskName defines the name of the new task
  138119. * @param url defines the url of the file to load
  138120. * @param extensions defines the extension to use to load the cube map (can be null)
  138121. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  138122. * @param files defines the list of files to load (can be null)
  138123. * @returns a new CubeTextureAssetTask object
  138124. */
  138125. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  138126. /**
  138127. *
  138128. * Add a HDRCubeTextureAssetTask to the list of active tasks
  138129. * @param taskName defines the name of the new task
  138130. * @param url defines the url of the file to load
  138131. * @param size defines the size you want for the cubemap (can be null)
  138132. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  138133. * @param generateHarmonics defines if you want to automatically generate (true by default)
  138134. * @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)
  138135. * @param reserved Internal use only
  138136. * @returns a new HDRCubeTextureAssetTask object
  138137. */
  138138. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  138139. /**
  138140. *
  138141. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  138142. * @param taskName defines the name of the new task
  138143. * @param url defines the url of the file to load
  138144. * @param size defines the size you want for the cubemap (can be null)
  138145. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  138146. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  138147. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  138148. * @returns a new EquiRectangularCubeTextureAssetTask object
  138149. */
  138150. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  138151. /**
  138152. * Remove a task from the assets manager.
  138153. * @param task the task to remove
  138154. */
  138155. removeTask(task: AbstractAssetTask): void;
  138156. private _decreaseWaitingTasksCount;
  138157. private _runTask;
  138158. /**
  138159. * Reset the AssetsManager and remove all tasks
  138160. * @return the current instance of the AssetsManager
  138161. */
  138162. reset(): AssetsManager;
  138163. /**
  138164. * Start the loading process
  138165. * @return the current instance of the AssetsManager
  138166. */
  138167. load(): AssetsManager;
  138168. /**
  138169. * Start the loading process as an async operation
  138170. * @return a promise returning the list of failed tasks
  138171. */
  138172. loadAsync(): Promise<void>;
  138173. }
  138174. }
  138175. declare module BABYLON {
  138176. /**
  138177. * Wrapper class for promise with external resolve and reject.
  138178. */
  138179. export class Deferred<T> {
  138180. /**
  138181. * The promise associated with this deferred object.
  138182. */
  138183. readonly promise: Promise<T>;
  138184. private _resolve;
  138185. private _reject;
  138186. /**
  138187. * The resolve method of the promise associated with this deferred object.
  138188. */
  138189. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  138190. /**
  138191. * The reject method of the promise associated with this deferred object.
  138192. */
  138193. get reject(): (reason?: any) => void;
  138194. /**
  138195. * Constructor for this deferred object.
  138196. */
  138197. constructor();
  138198. }
  138199. }
  138200. declare module BABYLON {
  138201. /**
  138202. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  138203. */
  138204. export class MeshExploder {
  138205. private _centerMesh;
  138206. private _meshes;
  138207. private _meshesOrigins;
  138208. private _toCenterVectors;
  138209. private _scaledDirection;
  138210. private _newPosition;
  138211. private _centerPosition;
  138212. /**
  138213. * Explodes meshes from a center mesh.
  138214. * @param meshes The meshes to explode.
  138215. * @param centerMesh The mesh to be center of explosion.
  138216. */
  138217. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  138218. private _setCenterMesh;
  138219. /**
  138220. * Get class name
  138221. * @returns "MeshExploder"
  138222. */
  138223. getClassName(): string;
  138224. /**
  138225. * "Exploded meshes"
  138226. * @returns Array of meshes with the centerMesh at index 0.
  138227. */
  138228. getMeshes(): Array<Mesh>;
  138229. /**
  138230. * Explodes meshes giving a specific direction
  138231. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  138232. */
  138233. explode(direction?: number): void;
  138234. }
  138235. }
  138236. declare module BABYLON {
  138237. /**
  138238. * Class used to help managing file picking and drag'n'drop
  138239. */
  138240. export class FilesInput {
  138241. /**
  138242. * List of files ready to be loaded
  138243. */
  138244. static get FilesToLoad(): {
  138245. [key: string]: File;
  138246. };
  138247. /**
  138248. * Callback called when a file is processed
  138249. */
  138250. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  138251. private _engine;
  138252. private _currentScene;
  138253. private _sceneLoadedCallback;
  138254. private _progressCallback;
  138255. private _additionalRenderLoopLogicCallback;
  138256. private _textureLoadingCallback;
  138257. private _startingProcessingFilesCallback;
  138258. private _onReloadCallback;
  138259. private _errorCallback;
  138260. private _elementToMonitor;
  138261. private _sceneFileToLoad;
  138262. private _filesToLoad;
  138263. /**
  138264. * Creates a new FilesInput
  138265. * @param engine defines the rendering engine
  138266. * @param scene defines the hosting scene
  138267. * @param sceneLoadedCallback callback called when scene is loaded
  138268. * @param progressCallback callback called to track progress
  138269. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  138270. * @param textureLoadingCallback callback called when a texture is loading
  138271. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  138272. * @param onReloadCallback callback called when a reload is requested
  138273. * @param errorCallback callback call if an error occurs
  138274. */
  138275. 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);
  138276. private _dragEnterHandler;
  138277. private _dragOverHandler;
  138278. private _dropHandler;
  138279. /**
  138280. * Calls this function to listen to drag'n'drop events on a specific DOM element
  138281. * @param elementToMonitor defines the DOM element to track
  138282. */
  138283. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  138284. /**
  138285. * Release all associated resources
  138286. */
  138287. dispose(): void;
  138288. private renderFunction;
  138289. private drag;
  138290. private drop;
  138291. private _traverseFolder;
  138292. private _processFiles;
  138293. /**
  138294. * Load files from a drop event
  138295. * @param event defines the drop event to use as source
  138296. */
  138297. loadFiles(event: any): void;
  138298. private _processReload;
  138299. /**
  138300. * Reload the current scene from the loaded files
  138301. */
  138302. reload(): void;
  138303. }
  138304. }
  138305. declare module BABYLON {
  138306. /**
  138307. * Defines the root class used to create scene optimization to use with SceneOptimizer
  138308. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138309. */
  138310. export class SceneOptimization {
  138311. /**
  138312. * Defines the priority of this optimization (0 by default which means first in the list)
  138313. */
  138314. priority: number;
  138315. /**
  138316. * Gets a string describing the action executed by the current optimization
  138317. * @returns description string
  138318. */
  138319. getDescription(): string;
  138320. /**
  138321. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138322. * @param scene defines the current scene where to apply this optimization
  138323. * @param optimizer defines the current optimizer
  138324. * @returns true if everything that can be done was applied
  138325. */
  138326. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138327. /**
  138328. * Creates the SceneOptimization object
  138329. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  138330. * @param desc defines the description associated with the optimization
  138331. */
  138332. constructor(
  138333. /**
  138334. * Defines the priority of this optimization (0 by default which means first in the list)
  138335. */
  138336. priority?: number);
  138337. }
  138338. /**
  138339. * Defines an optimization used to reduce the size of render target textures
  138340. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138341. */
  138342. export class TextureOptimization extends SceneOptimization {
  138343. /**
  138344. * Defines the priority of this optimization (0 by default which means first in the list)
  138345. */
  138346. priority: number;
  138347. /**
  138348. * 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
  138349. */
  138350. maximumSize: number;
  138351. /**
  138352. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  138353. */
  138354. step: number;
  138355. /**
  138356. * Gets a string describing the action executed by the current optimization
  138357. * @returns description string
  138358. */
  138359. getDescription(): string;
  138360. /**
  138361. * Creates the TextureOptimization object
  138362. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  138363. * @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
  138364. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  138365. */
  138366. constructor(
  138367. /**
  138368. * Defines the priority of this optimization (0 by default which means first in the list)
  138369. */
  138370. priority?: number,
  138371. /**
  138372. * 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
  138373. */
  138374. maximumSize?: number,
  138375. /**
  138376. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  138377. */
  138378. step?: number);
  138379. /**
  138380. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138381. * @param scene defines the current scene where to apply this optimization
  138382. * @param optimizer defines the current optimizer
  138383. * @returns true if everything that can be done was applied
  138384. */
  138385. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138386. }
  138387. /**
  138388. * Defines an optimization used to increase or decrease the rendering resolution
  138389. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138390. */
  138391. export class HardwareScalingOptimization extends SceneOptimization {
  138392. /**
  138393. * Defines the priority of this optimization (0 by default which means first in the list)
  138394. */
  138395. priority: number;
  138396. /**
  138397. * Defines the maximum scale to use (2 by default)
  138398. */
  138399. maximumScale: number;
  138400. /**
  138401. * Defines the step to use between two passes (0.5 by default)
  138402. */
  138403. step: number;
  138404. private _currentScale;
  138405. private _directionOffset;
  138406. /**
  138407. * Gets a string describing the action executed by the current optimization
  138408. * @return description string
  138409. */
  138410. getDescription(): string;
  138411. /**
  138412. * Creates the HardwareScalingOptimization object
  138413. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  138414. * @param maximumScale defines the maximum scale to use (2 by default)
  138415. * @param step defines the step to use between two passes (0.5 by default)
  138416. */
  138417. constructor(
  138418. /**
  138419. * Defines the priority of this optimization (0 by default which means first in the list)
  138420. */
  138421. priority?: number,
  138422. /**
  138423. * Defines the maximum scale to use (2 by default)
  138424. */
  138425. maximumScale?: number,
  138426. /**
  138427. * Defines the step to use between two passes (0.5 by default)
  138428. */
  138429. step?: number);
  138430. /**
  138431. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138432. * @param scene defines the current scene where to apply this optimization
  138433. * @param optimizer defines the current optimizer
  138434. * @returns true if everything that can be done was applied
  138435. */
  138436. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138437. }
  138438. /**
  138439. * Defines an optimization used to remove shadows
  138440. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138441. */
  138442. export class ShadowsOptimization extends SceneOptimization {
  138443. /**
  138444. * Gets a string describing the action executed by the current optimization
  138445. * @return description string
  138446. */
  138447. getDescription(): string;
  138448. /**
  138449. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138450. * @param scene defines the current scene where to apply this optimization
  138451. * @param optimizer defines the current optimizer
  138452. * @returns true if everything that can be done was applied
  138453. */
  138454. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138455. }
  138456. /**
  138457. * Defines an optimization used to turn post-processes off
  138458. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138459. */
  138460. export class PostProcessesOptimization extends SceneOptimization {
  138461. /**
  138462. * Gets a string describing the action executed by the current optimization
  138463. * @return description string
  138464. */
  138465. getDescription(): string;
  138466. /**
  138467. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138468. * @param scene defines the current scene where to apply this optimization
  138469. * @param optimizer defines the current optimizer
  138470. * @returns true if everything that can be done was applied
  138471. */
  138472. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138473. }
  138474. /**
  138475. * Defines an optimization used to turn lens flares off
  138476. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138477. */
  138478. export class LensFlaresOptimization extends SceneOptimization {
  138479. /**
  138480. * Gets a string describing the action executed by the current optimization
  138481. * @return description string
  138482. */
  138483. getDescription(): string;
  138484. /**
  138485. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138486. * @param scene defines the current scene where to apply this optimization
  138487. * @param optimizer defines the current optimizer
  138488. * @returns true if everything that can be done was applied
  138489. */
  138490. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138491. }
  138492. /**
  138493. * Defines an optimization based on user defined callback.
  138494. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138495. */
  138496. export class CustomOptimization extends SceneOptimization {
  138497. /**
  138498. * Callback called to apply the custom optimization.
  138499. */
  138500. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  138501. /**
  138502. * Callback called to get custom description
  138503. */
  138504. onGetDescription: () => string;
  138505. /**
  138506. * Gets a string describing the action executed by the current optimization
  138507. * @returns description string
  138508. */
  138509. getDescription(): string;
  138510. /**
  138511. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138512. * @param scene defines the current scene where to apply this optimization
  138513. * @param optimizer defines the current optimizer
  138514. * @returns true if everything that can be done was applied
  138515. */
  138516. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138517. }
  138518. /**
  138519. * Defines an optimization used to turn particles off
  138520. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138521. */
  138522. export class ParticlesOptimization extends SceneOptimization {
  138523. /**
  138524. * Gets a string describing the action executed by the current optimization
  138525. * @return description string
  138526. */
  138527. getDescription(): string;
  138528. /**
  138529. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138530. * @param scene defines the current scene where to apply this optimization
  138531. * @param optimizer defines the current optimizer
  138532. * @returns true if everything that can be done was applied
  138533. */
  138534. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138535. }
  138536. /**
  138537. * Defines an optimization used to turn render targets off
  138538. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138539. */
  138540. export class RenderTargetsOptimization extends SceneOptimization {
  138541. /**
  138542. * Gets a string describing the action executed by the current optimization
  138543. * @return description string
  138544. */
  138545. getDescription(): string;
  138546. /**
  138547. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138548. * @param scene defines the current scene where to apply this optimization
  138549. * @param optimizer defines the current optimizer
  138550. * @returns true if everything that can be done was applied
  138551. */
  138552. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138553. }
  138554. /**
  138555. * Defines an optimization used to merge meshes with compatible materials
  138556. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138557. */
  138558. export class MergeMeshesOptimization extends SceneOptimization {
  138559. private static _UpdateSelectionTree;
  138560. /**
  138561. * Gets or sets a boolean which defines if optimization octree has to be updated
  138562. */
  138563. static get UpdateSelectionTree(): boolean;
  138564. /**
  138565. * Gets or sets a boolean which defines if optimization octree has to be updated
  138566. */
  138567. static set UpdateSelectionTree(value: boolean);
  138568. /**
  138569. * Gets a string describing the action executed by the current optimization
  138570. * @return description string
  138571. */
  138572. getDescription(): string;
  138573. private _canBeMerged;
  138574. /**
  138575. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138576. * @param scene defines the current scene where to apply this optimization
  138577. * @param optimizer defines the current optimizer
  138578. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  138579. * @returns true if everything that can be done was applied
  138580. */
  138581. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  138582. }
  138583. /**
  138584. * Defines a list of options used by SceneOptimizer
  138585. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138586. */
  138587. export class SceneOptimizerOptions {
  138588. /**
  138589. * Defines the target frame rate to reach (60 by default)
  138590. */
  138591. targetFrameRate: number;
  138592. /**
  138593. * Defines the interval between two checkes (2000ms by default)
  138594. */
  138595. trackerDuration: number;
  138596. /**
  138597. * Gets the list of optimizations to apply
  138598. */
  138599. optimizations: SceneOptimization[];
  138600. /**
  138601. * Creates a new list of options used by SceneOptimizer
  138602. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  138603. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  138604. */
  138605. constructor(
  138606. /**
  138607. * Defines the target frame rate to reach (60 by default)
  138608. */
  138609. targetFrameRate?: number,
  138610. /**
  138611. * Defines the interval between two checkes (2000ms by default)
  138612. */
  138613. trackerDuration?: number);
  138614. /**
  138615. * Add a new optimization
  138616. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  138617. * @returns the current SceneOptimizerOptions
  138618. */
  138619. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  138620. /**
  138621. * Add a new custom optimization
  138622. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  138623. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  138624. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  138625. * @returns the current SceneOptimizerOptions
  138626. */
  138627. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  138628. /**
  138629. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  138630. * @param targetFrameRate defines the target frame rate (60 by default)
  138631. * @returns a SceneOptimizerOptions object
  138632. */
  138633. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  138634. /**
  138635. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  138636. * @param targetFrameRate defines the target frame rate (60 by default)
  138637. * @returns a SceneOptimizerOptions object
  138638. */
  138639. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  138640. /**
  138641. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  138642. * @param targetFrameRate defines the target frame rate (60 by default)
  138643. * @returns a SceneOptimizerOptions object
  138644. */
  138645. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  138646. }
  138647. /**
  138648. * Class used to run optimizations in order to reach a target frame rate
  138649. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138650. */
  138651. export class SceneOptimizer implements IDisposable {
  138652. private _isRunning;
  138653. private _options;
  138654. private _scene;
  138655. private _currentPriorityLevel;
  138656. private _targetFrameRate;
  138657. private _trackerDuration;
  138658. private _currentFrameRate;
  138659. private _sceneDisposeObserver;
  138660. private _improvementMode;
  138661. /**
  138662. * Defines an observable called when the optimizer reaches the target frame rate
  138663. */
  138664. onSuccessObservable: Observable<SceneOptimizer>;
  138665. /**
  138666. * Defines an observable called when the optimizer enables an optimization
  138667. */
  138668. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  138669. /**
  138670. * Defines an observable called when the optimizer is not able to reach the target frame rate
  138671. */
  138672. onFailureObservable: Observable<SceneOptimizer>;
  138673. /**
  138674. * Gets a boolean indicating if the optimizer is in improvement mode
  138675. */
  138676. get isInImprovementMode(): boolean;
  138677. /**
  138678. * Gets the current priority level (0 at start)
  138679. */
  138680. get currentPriorityLevel(): number;
  138681. /**
  138682. * Gets the current frame rate checked by the SceneOptimizer
  138683. */
  138684. get currentFrameRate(): number;
  138685. /**
  138686. * Gets or sets the current target frame rate (60 by default)
  138687. */
  138688. get targetFrameRate(): number;
  138689. /**
  138690. * Gets or sets the current target frame rate (60 by default)
  138691. */
  138692. set targetFrameRate(value: number);
  138693. /**
  138694. * Gets or sets the current interval between two checks (every 2000ms by default)
  138695. */
  138696. get trackerDuration(): number;
  138697. /**
  138698. * Gets or sets the current interval between two checks (every 2000ms by default)
  138699. */
  138700. set trackerDuration(value: number);
  138701. /**
  138702. * Gets the list of active optimizations
  138703. */
  138704. get optimizations(): SceneOptimization[];
  138705. /**
  138706. * Creates a new SceneOptimizer
  138707. * @param scene defines the scene to work on
  138708. * @param options defines the options to use with the SceneOptimizer
  138709. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  138710. * @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)
  138711. */
  138712. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  138713. /**
  138714. * Stops the current optimizer
  138715. */
  138716. stop(): void;
  138717. /**
  138718. * Reset the optimizer to initial step (current priority level = 0)
  138719. */
  138720. reset(): void;
  138721. /**
  138722. * Start the optimizer. By default it will try to reach a specific framerate
  138723. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  138724. */
  138725. start(): void;
  138726. private _checkCurrentState;
  138727. /**
  138728. * Release all resources
  138729. */
  138730. dispose(): void;
  138731. /**
  138732. * Helper function to create a SceneOptimizer with one single line of code
  138733. * @param scene defines the scene to work on
  138734. * @param options defines the options to use with the SceneOptimizer
  138735. * @param onSuccess defines a callback to call on success
  138736. * @param onFailure defines a callback to call on failure
  138737. * @returns the new SceneOptimizer object
  138738. */
  138739. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  138740. }
  138741. }
  138742. declare module BABYLON {
  138743. /**
  138744. * Class used to serialize a scene into a string
  138745. */
  138746. export class SceneSerializer {
  138747. /**
  138748. * Clear cache used by a previous serialization
  138749. */
  138750. static ClearCache(): void;
  138751. /**
  138752. * Serialize a scene into a JSON compatible object
  138753. * @param scene defines the scene to serialize
  138754. * @returns a JSON compatible object
  138755. */
  138756. static Serialize(scene: Scene): any;
  138757. /**
  138758. * Serialize a mesh into a JSON compatible object
  138759. * @param toSerialize defines the mesh to serialize
  138760. * @param withParents defines if parents must be serialized as well
  138761. * @param withChildren defines if children must be serialized as well
  138762. * @returns a JSON compatible object
  138763. */
  138764. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  138765. }
  138766. }
  138767. declare module BABYLON {
  138768. /**
  138769. * Class used to host texture specific utilities
  138770. */
  138771. export class TextureTools {
  138772. /**
  138773. * Uses the GPU to create a copy texture rescaled at a given size
  138774. * @param texture Texture to copy from
  138775. * @param width defines the desired width
  138776. * @param height defines the desired height
  138777. * @param useBilinearMode defines if bilinear mode has to be used
  138778. * @return the generated texture
  138779. */
  138780. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  138781. }
  138782. }
  138783. declare module BABYLON {
  138784. /**
  138785. * This represents the different options available for the video capture.
  138786. */
  138787. export interface VideoRecorderOptions {
  138788. /** Defines the mime type of the video. */
  138789. mimeType: string;
  138790. /** Defines the FPS the video should be recorded at. */
  138791. fps: number;
  138792. /** Defines the chunk size for the recording data. */
  138793. recordChunckSize: number;
  138794. /** The audio tracks to attach to the recording. */
  138795. audioTracks?: MediaStreamTrack[];
  138796. }
  138797. /**
  138798. * This can help with recording videos from BabylonJS.
  138799. * This is based on the available WebRTC functionalities of the browser.
  138800. *
  138801. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  138802. */
  138803. export class VideoRecorder {
  138804. private static readonly _defaultOptions;
  138805. /**
  138806. * Returns whether or not the VideoRecorder is available in your browser.
  138807. * @param engine Defines the Babylon Engine.
  138808. * @returns true if supported otherwise false.
  138809. */
  138810. static IsSupported(engine: Engine): boolean;
  138811. private readonly _options;
  138812. private _canvas;
  138813. private _mediaRecorder;
  138814. private _recordedChunks;
  138815. private _fileName;
  138816. private _resolve;
  138817. private _reject;
  138818. /**
  138819. * True when a recording is already in progress.
  138820. */
  138821. get isRecording(): boolean;
  138822. /**
  138823. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  138824. * @param engine Defines the BabylonJS Engine you wish to record.
  138825. * @param options Defines options that can be used to customize the capture.
  138826. */
  138827. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  138828. /**
  138829. * Stops the current recording before the default capture timeout passed in the startRecording function.
  138830. */
  138831. stopRecording(): void;
  138832. /**
  138833. * Starts recording the canvas for a max duration specified in parameters.
  138834. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  138835. * If null no automatic download will start and you can rely on the promise to get the data back.
  138836. * @param maxDuration Defines the maximum recording time in seconds.
  138837. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  138838. * @return A promise callback at the end of the recording with the video data in Blob.
  138839. */
  138840. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  138841. /**
  138842. * Releases internal resources used during the recording.
  138843. */
  138844. dispose(): void;
  138845. private _handleDataAvailable;
  138846. private _handleError;
  138847. private _handleStop;
  138848. }
  138849. }
  138850. declare module BABYLON {
  138851. /**
  138852. * Class containing a set of static utilities functions for screenshots
  138853. */
  138854. export class ScreenshotTools {
  138855. /**
  138856. * Captures a screenshot of the current rendering
  138857. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  138858. * @param engine defines the rendering engine
  138859. * @param camera defines the source camera
  138860. * @param size This parameter can be set to a single number or to an object with the
  138861. * following (optional) properties: precision, width, height. If a single number is passed,
  138862. * it will be used for both width and height. If an object is passed, the screenshot size
  138863. * will be derived from the parameters. The precision property is a multiplier allowing
  138864. * rendering at a higher or lower resolution
  138865. * @param successCallback defines the callback receives a single parameter which contains the
  138866. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  138867. * src parameter of an <img> to display it
  138868. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  138869. * Check your browser for supported MIME types
  138870. */
  138871. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  138872. /**
  138873. * Captures a screenshot of the current rendering
  138874. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  138875. * @param engine defines the rendering engine
  138876. * @param camera defines the source camera
  138877. * @param size This parameter can be set to a single number or to an object with the
  138878. * following (optional) properties: precision, width, height. If a single number is passed,
  138879. * it will be used for both width and height. If an object is passed, the screenshot size
  138880. * will be derived from the parameters. The precision property is a multiplier allowing
  138881. * rendering at a higher or lower resolution
  138882. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  138883. * Check your browser for supported MIME types
  138884. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  138885. * to the src parameter of an <img> to display it
  138886. */
  138887. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  138888. /**
  138889. * Generates an image screenshot from the specified camera.
  138890. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  138891. * @param engine The engine to use for rendering
  138892. * @param camera The camera to use for rendering
  138893. * @param size This parameter can be set to a single number or to an object with the
  138894. * following (optional) properties: precision, width, height. If a single number is passed,
  138895. * it will be used for both width and height. If an object is passed, the screenshot size
  138896. * will be derived from the parameters. The precision property is a multiplier allowing
  138897. * rendering at a higher or lower resolution
  138898. * @param successCallback The callback receives a single parameter which contains the
  138899. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  138900. * src parameter of an <img> to display it
  138901. * @param mimeType The MIME type of the screenshot image (default: image/png).
  138902. * Check your browser for supported MIME types
  138903. * @param samples Texture samples (default: 1)
  138904. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  138905. * @param fileName A name for for the downloaded file.
  138906. */
  138907. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  138908. /**
  138909. * Generates an image screenshot from the specified camera.
  138910. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  138911. * @param engine The engine to use for rendering
  138912. * @param camera The camera to use for rendering
  138913. * @param size This parameter can be set to a single number or to an object with the
  138914. * following (optional) properties: precision, width, height. If a single number is passed,
  138915. * it will be used for both width and height. If an object is passed, the screenshot size
  138916. * will be derived from the parameters. The precision property is a multiplier allowing
  138917. * rendering at a higher or lower resolution
  138918. * @param mimeType The MIME type of the screenshot image (default: image/png).
  138919. * Check your browser for supported MIME types
  138920. * @param samples Texture samples (default: 1)
  138921. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  138922. * @param fileName A name for for the downloaded file.
  138923. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  138924. * to the src parameter of an <img> to display it
  138925. */
  138926. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  138927. /**
  138928. * Gets height and width for screenshot size
  138929. * @private
  138930. */
  138931. private static _getScreenshotSize;
  138932. }
  138933. }
  138934. declare module BABYLON {
  138935. /**
  138936. * Interface for a data buffer
  138937. */
  138938. export interface IDataBuffer {
  138939. /**
  138940. * Reads bytes from the data buffer.
  138941. * @param byteOffset The byte offset to read
  138942. * @param byteLength The byte length to read
  138943. * @returns A promise that resolves when the bytes are read
  138944. */
  138945. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  138946. /**
  138947. * The byte length of the buffer.
  138948. */
  138949. readonly byteLength: number;
  138950. }
  138951. /**
  138952. * Utility class for reading from a data buffer
  138953. */
  138954. export class DataReader {
  138955. /**
  138956. * The data buffer associated with this data reader.
  138957. */
  138958. readonly buffer: IDataBuffer;
  138959. /**
  138960. * The current byte offset from the beginning of the data buffer.
  138961. */
  138962. byteOffset: number;
  138963. private _dataView;
  138964. private _dataByteOffset;
  138965. /**
  138966. * Constructor
  138967. * @param buffer The buffer to read
  138968. */
  138969. constructor(buffer: IDataBuffer);
  138970. /**
  138971. * Loads the given byte length.
  138972. * @param byteLength The byte length to load
  138973. * @returns A promise that resolves when the load is complete
  138974. */
  138975. loadAsync(byteLength: number): Promise<void>;
  138976. /**
  138977. * Read a unsigned 32-bit integer from the currently loaded data range.
  138978. * @returns The 32-bit integer read
  138979. */
  138980. readUint32(): number;
  138981. /**
  138982. * Read a byte array from the currently loaded data range.
  138983. * @param byteLength The byte length to read
  138984. * @returns The byte array read
  138985. */
  138986. readUint8Array(byteLength: number): Uint8Array;
  138987. /**
  138988. * Read a string from the currently loaded data range.
  138989. * @param byteLength The byte length to read
  138990. * @returns The string read
  138991. */
  138992. readString(byteLength: number): string;
  138993. /**
  138994. * Skips the given byte length the currently loaded data range.
  138995. * @param byteLength The byte length to skip
  138996. */
  138997. skipBytes(byteLength: number): void;
  138998. }
  138999. }
  139000. declare module BABYLON {
  139001. /**
  139002. * A cursor which tracks a point on a path
  139003. */
  139004. export class PathCursor {
  139005. private path;
  139006. /**
  139007. * Stores path cursor callbacks for when an onchange event is triggered
  139008. */
  139009. private _onchange;
  139010. /**
  139011. * The value of the path cursor
  139012. */
  139013. value: number;
  139014. /**
  139015. * The animation array of the path cursor
  139016. */
  139017. animations: Animation[];
  139018. /**
  139019. * Initializes the path cursor
  139020. * @param path The path to track
  139021. */
  139022. constructor(path: Path2);
  139023. /**
  139024. * Gets the cursor point on the path
  139025. * @returns A point on the path cursor at the cursor location
  139026. */
  139027. getPoint(): Vector3;
  139028. /**
  139029. * Moves the cursor ahead by the step amount
  139030. * @param step The amount to move the cursor forward
  139031. * @returns This path cursor
  139032. */
  139033. moveAhead(step?: number): PathCursor;
  139034. /**
  139035. * Moves the cursor behind by the step amount
  139036. * @param step The amount to move the cursor back
  139037. * @returns This path cursor
  139038. */
  139039. moveBack(step?: number): PathCursor;
  139040. /**
  139041. * Moves the cursor by the step amount
  139042. * If the step amount is greater than one, an exception is thrown
  139043. * @param step The amount to move the cursor
  139044. * @returns This path cursor
  139045. */
  139046. move(step: number): PathCursor;
  139047. /**
  139048. * Ensures that the value is limited between zero and one
  139049. * @returns This path cursor
  139050. */
  139051. private ensureLimits;
  139052. /**
  139053. * Runs onchange callbacks on change (used by the animation engine)
  139054. * @returns This path cursor
  139055. */
  139056. private raiseOnChange;
  139057. /**
  139058. * Executes a function on change
  139059. * @param f A path cursor onchange callback
  139060. * @returns This path cursor
  139061. */
  139062. onchange(f: (cursor: PathCursor) => void): PathCursor;
  139063. }
  139064. }
  139065. declare module BABYLON {
  139066. /** @hidden */
  139067. export var blurPixelShader: {
  139068. name: string;
  139069. shader: string;
  139070. };
  139071. }
  139072. declare module BABYLON {
  139073. /** @hidden */
  139074. export var pointCloudVertexDeclaration: {
  139075. name: string;
  139076. shader: string;
  139077. };
  139078. }
  139079. // Mixins
  139080. interface Window {
  139081. mozIndexedDB: IDBFactory;
  139082. webkitIndexedDB: IDBFactory;
  139083. msIndexedDB: IDBFactory;
  139084. webkitURL: typeof URL;
  139085. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  139086. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  139087. WebGLRenderingContext: WebGLRenderingContext;
  139088. MSGesture: MSGesture;
  139089. CANNON: any;
  139090. AudioContext: AudioContext;
  139091. webkitAudioContext: AudioContext;
  139092. PointerEvent: any;
  139093. Math: Math;
  139094. Uint8Array: Uint8ArrayConstructor;
  139095. Float32Array: Float32ArrayConstructor;
  139096. mozURL: typeof URL;
  139097. msURL: typeof URL;
  139098. VRFrameData: any; // WebVR, from specs 1.1
  139099. DracoDecoderModule: any;
  139100. setImmediate(handler: (...args: any[]) => void): number;
  139101. }
  139102. interface HTMLCanvasElement {
  139103. requestPointerLock(): void;
  139104. msRequestPointerLock?(): void;
  139105. mozRequestPointerLock?(): void;
  139106. webkitRequestPointerLock?(): void;
  139107. /** Track wether a record is in progress */
  139108. isRecording: boolean;
  139109. /** Capture Stream method defined by some browsers */
  139110. captureStream(fps?: number): MediaStream;
  139111. }
  139112. interface CanvasRenderingContext2D {
  139113. msImageSmoothingEnabled: boolean;
  139114. }
  139115. interface MouseEvent {
  139116. mozMovementX: number;
  139117. mozMovementY: number;
  139118. webkitMovementX: number;
  139119. webkitMovementY: number;
  139120. msMovementX: number;
  139121. msMovementY: number;
  139122. }
  139123. interface Navigator {
  139124. mozGetVRDevices: (any: any) => any;
  139125. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  139126. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  139127. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  139128. webkitGetGamepads(): Gamepad[];
  139129. msGetGamepads(): Gamepad[];
  139130. webkitGamepads(): Gamepad[];
  139131. }
  139132. interface HTMLVideoElement {
  139133. mozSrcObject: any;
  139134. }
  139135. interface Math {
  139136. fround(x: number): number;
  139137. imul(a: number, b: number): number;
  139138. }
  139139. interface WebGLRenderingContext {
  139140. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  139141. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  139142. vertexAttribDivisor(index: number, divisor: number): void;
  139143. createVertexArray(): any;
  139144. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  139145. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  139146. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  139147. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  139148. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  139149. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  139150. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  139151. // Queries
  139152. createQuery(): WebGLQuery;
  139153. deleteQuery(query: WebGLQuery): void;
  139154. beginQuery(target: number, query: WebGLQuery): void;
  139155. endQuery(target: number): void;
  139156. getQueryParameter(query: WebGLQuery, pname: number): any;
  139157. getQuery(target: number, pname: number): any;
  139158. MAX_SAMPLES: number;
  139159. RGBA8: number;
  139160. READ_FRAMEBUFFER: number;
  139161. DRAW_FRAMEBUFFER: number;
  139162. UNIFORM_BUFFER: number;
  139163. HALF_FLOAT_OES: number;
  139164. RGBA16F: number;
  139165. RGBA32F: number;
  139166. R32F: number;
  139167. RG32F: number;
  139168. RGB32F: number;
  139169. R16F: number;
  139170. RG16F: number;
  139171. RGB16F: number;
  139172. RED: number;
  139173. RG: number;
  139174. R8: number;
  139175. RG8: number;
  139176. UNSIGNED_INT_24_8: number;
  139177. DEPTH24_STENCIL8: number;
  139178. MIN: number;
  139179. MAX: number;
  139180. /* Multiple Render Targets */
  139181. drawBuffers(buffers: number[]): void;
  139182. readBuffer(src: number): void;
  139183. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  139184. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  139185. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  139186. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  139187. // Occlusion Query
  139188. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  139189. ANY_SAMPLES_PASSED: number;
  139190. QUERY_RESULT_AVAILABLE: number;
  139191. QUERY_RESULT: number;
  139192. }
  139193. interface WebGLProgram {
  139194. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  139195. }
  139196. interface EXT_disjoint_timer_query {
  139197. QUERY_COUNTER_BITS_EXT: number;
  139198. TIME_ELAPSED_EXT: number;
  139199. TIMESTAMP_EXT: number;
  139200. GPU_DISJOINT_EXT: number;
  139201. QUERY_RESULT_EXT: number;
  139202. QUERY_RESULT_AVAILABLE_EXT: number;
  139203. queryCounterEXT(query: WebGLQuery, target: number): void;
  139204. createQueryEXT(): WebGLQuery;
  139205. beginQueryEXT(target: number, query: WebGLQuery): void;
  139206. endQueryEXT(target: number): void;
  139207. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  139208. deleteQueryEXT(query: WebGLQuery): void;
  139209. }
  139210. interface WebGLUniformLocation {
  139211. _currentState: any;
  139212. }
  139213. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  139214. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  139215. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  139216. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  139217. interface WebGLRenderingContext {
  139218. readonly RASTERIZER_DISCARD: number;
  139219. readonly DEPTH_COMPONENT24: number;
  139220. readonly TEXTURE_3D: number;
  139221. readonly TEXTURE_2D_ARRAY: number;
  139222. readonly TEXTURE_COMPARE_FUNC: number;
  139223. readonly TEXTURE_COMPARE_MODE: number;
  139224. readonly COMPARE_REF_TO_TEXTURE: number;
  139225. readonly TEXTURE_WRAP_R: number;
  139226. readonly HALF_FLOAT: number;
  139227. readonly RGB8: number;
  139228. readonly RED_INTEGER: number;
  139229. readonly RG_INTEGER: number;
  139230. readonly RGB_INTEGER: number;
  139231. readonly RGBA_INTEGER: number;
  139232. readonly R8_SNORM: number;
  139233. readonly RG8_SNORM: number;
  139234. readonly RGB8_SNORM: number;
  139235. readonly RGBA8_SNORM: number;
  139236. readonly R8I: number;
  139237. readonly RG8I: number;
  139238. readonly RGB8I: number;
  139239. readonly RGBA8I: number;
  139240. readonly R8UI: number;
  139241. readonly RG8UI: number;
  139242. readonly RGB8UI: number;
  139243. readonly RGBA8UI: number;
  139244. readonly R16I: number;
  139245. readonly RG16I: number;
  139246. readonly RGB16I: number;
  139247. readonly RGBA16I: number;
  139248. readonly R16UI: number;
  139249. readonly RG16UI: number;
  139250. readonly RGB16UI: number;
  139251. readonly RGBA16UI: number;
  139252. readonly R32I: number;
  139253. readonly RG32I: number;
  139254. readonly RGB32I: number;
  139255. readonly RGBA32I: number;
  139256. readonly R32UI: number;
  139257. readonly RG32UI: number;
  139258. readonly RGB32UI: number;
  139259. readonly RGBA32UI: number;
  139260. readonly RGB10_A2UI: number;
  139261. readonly R11F_G11F_B10F: number;
  139262. readonly RGB9_E5: number;
  139263. readonly RGB10_A2: number;
  139264. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  139265. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  139266. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  139267. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  139268. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  139269. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  139270. 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;
  139271. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  139272. readonly TRANSFORM_FEEDBACK: number;
  139273. readonly INTERLEAVED_ATTRIBS: number;
  139274. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  139275. createTransformFeedback(): WebGLTransformFeedback;
  139276. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  139277. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  139278. beginTransformFeedback(primitiveMode: number): void;
  139279. endTransformFeedback(): void;
  139280. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  139281. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  139282. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  139283. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  139284. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  139285. }
  139286. interface ImageBitmap {
  139287. readonly width: number;
  139288. readonly height: number;
  139289. close(): void;
  139290. }
  139291. interface WebGLQuery extends WebGLObject {
  139292. }
  139293. declare var WebGLQuery: {
  139294. prototype: WebGLQuery;
  139295. new(): WebGLQuery;
  139296. };
  139297. interface WebGLSampler extends WebGLObject {
  139298. }
  139299. declare var WebGLSampler: {
  139300. prototype: WebGLSampler;
  139301. new(): WebGLSampler;
  139302. };
  139303. interface WebGLSync extends WebGLObject {
  139304. }
  139305. declare var WebGLSync: {
  139306. prototype: WebGLSync;
  139307. new(): WebGLSync;
  139308. };
  139309. interface WebGLTransformFeedback extends WebGLObject {
  139310. }
  139311. declare var WebGLTransformFeedback: {
  139312. prototype: WebGLTransformFeedback;
  139313. new(): WebGLTransformFeedback;
  139314. };
  139315. interface WebGLVertexArrayObject extends WebGLObject {
  139316. }
  139317. declare var WebGLVertexArrayObject: {
  139318. prototype: WebGLVertexArrayObject;
  139319. new(): WebGLVertexArrayObject;
  139320. };
  139321. // Type definitions for WebVR API
  139322. // Project: https://w3c.github.io/webvr/
  139323. // Definitions by: six a <https://github.com/lostfictions>
  139324. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  139325. interface VRDisplay extends EventTarget {
  139326. /**
  139327. * Dictionary of capabilities describing the VRDisplay.
  139328. */
  139329. readonly capabilities: VRDisplayCapabilities;
  139330. /**
  139331. * z-depth defining the far plane of the eye view frustum
  139332. * enables mapping of values in the render target depth
  139333. * attachment to scene coordinates. Initially set to 10000.0.
  139334. */
  139335. depthFar: number;
  139336. /**
  139337. * z-depth defining the near plane of the eye view frustum
  139338. * enables mapping of values in the render target depth
  139339. * attachment to scene coordinates. Initially set to 0.01.
  139340. */
  139341. depthNear: number;
  139342. /**
  139343. * An identifier for this distinct VRDisplay. Used as an
  139344. * association point in the Gamepad API.
  139345. */
  139346. readonly displayId: number;
  139347. /**
  139348. * A display name, a user-readable name identifying it.
  139349. */
  139350. readonly displayName: string;
  139351. readonly isConnected: boolean;
  139352. readonly isPresenting: boolean;
  139353. /**
  139354. * If this VRDisplay supports room-scale experiences, the optional
  139355. * stage attribute contains details on the room-scale parameters.
  139356. */
  139357. readonly stageParameters: VRStageParameters | null;
  139358. /**
  139359. * Passing the value returned by `requestAnimationFrame` to
  139360. * `cancelAnimationFrame` will unregister the callback.
  139361. * @param handle Define the hanle of the request to cancel
  139362. */
  139363. cancelAnimationFrame(handle: number): void;
  139364. /**
  139365. * Stops presenting to the VRDisplay.
  139366. * @returns a promise to know when it stopped
  139367. */
  139368. exitPresent(): Promise<void>;
  139369. /**
  139370. * Return the current VREyeParameters for the given eye.
  139371. * @param whichEye Define the eye we want the parameter for
  139372. * @returns the eye parameters
  139373. */
  139374. getEyeParameters(whichEye: string): VREyeParameters;
  139375. /**
  139376. * Populates the passed VRFrameData with the information required to render
  139377. * the current frame.
  139378. * @param frameData Define the data structure to populate
  139379. * @returns true if ok otherwise false
  139380. */
  139381. getFrameData(frameData: VRFrameData): boolean;
  139382. /**
  139383. * Get the layers currently being presented.
  139384. * @returns the list of VR layers
  139385. */
  139386. getLayers(): VRLayer[];
  139387. /**
  139388. * Return a VRPose containing the future predicted pose of the VRDisplay
  139389. * when the current frame will be presented. The value returned will not
  139390. * change until JavaScript has returned control to the browser.
  139391. *
  139392. * The VRPose will contain the position, orientation, velocity,
  139393. * and acceleration of each of these properties.
  139394. * @returns the pose object
  139395. */
  139396. getPose(): VRPose;
  139397. /**
  139398. * Return the current instantaneous pose of the VRDisplay, with no
  139399. * prediction applied.
  139400. * @returns the current instantaneous pose
  139401. */
  139402. getImmediatePose(): VRPose;
  139403. /**
  139404. * The callback passed to `requestAnimationFrame` will be called
  139405. * any time a new frame should be rendered. When the VRDisplay is
  139406. * presenting the callback will be called at the native refresh
  139407. * rate of the HMD. When not presenting this function acts
  139408. * identically to how window.requestAnimationFrame acts. Content should
  139409. * make no assumptions of frame rate or vsync behavior as the HMD runs
  139410. * asynchronously from other displays and at differing refresh rates.
  139411. * @param callback Define the eaction to run next frame
  139412. * @returns the request handle it
  139413. */
  139414. requestAnimationFrame(callback: FrameRequestCallback): number;
  139415. /**
  139416. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  139417. * Repeat calls while already presenting will update the VRLayers being displayed.
  139418. * @param layers Define the list of layer to present
  139419. * @returns a promise to know when the request has been fulfilled
  139420. */
  139421. requestPresent(layers: VRLayer[]): Promise<void>;
  139422. /**
  139423. * Reset the pose for this display, treating its current position and
  139424. * orientation as the "origin/zero" values. VRPose.position,
  139425. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  139426. * updated when calling resetPose(). This should be called in only
  139427. * sitting-space experiences.
  139428. */
  139429. resetPose(): void;
  139430. /**
  139431. * The VRLayer provided to the VRDisplay will be captured and presented
  139432. * in the HMD. Calling this function has the same effect on the source
  139433. * canvas as any other operation that uses its source image, and canvases
  139434. * created without preserveDrawingBuffer set to true will be cleared.
  139435. * @param pose Define the pose to submit
  139436. */
  139437. submitFrame(pose?: VRPose): void;
  139438. }
  139439. declare var VRDisplay: {
  139440. prototype: VRDisplay;
  139441. new(): VRDisplay;
  139442. };
  139443. interface VRLayer {
  139444. leftBounds?: number[] | Float32Array | null;
  139445. rightBounds?: number[] | Float32Array | null;
  139446. source?: HTMLCanvasElement | null;
  139447. }
  139448. interface VRDisplayCapabilities {
  139449. readonly canPresent: boolean;
  139450. readonly hasExternalDisplay: boolean;
  139451. readonly hasOrientation: boolean;
  139452. readonly hasPosition: boolean;
  139453. readonly maxLayers: number;
  139454. }
  139455. interface VREyeParameters {
  139456. /** @deprecated */
  139457. readonly fieldOfView: VRFieldOfView;
  139458. readonly offset: Float32Array;
  139459. readonly renderHeight: number;
  139460. readonly renderWidth: number;
  139461. }
  139462. interface VRFieldOfView {
  139463. readonly downDegrees: number;
  139464. readonly leftDegrees: number;
  139465. readonly rightDegrees: number;
  139466. readonly upDegrees: number;
  139467. }
  139468. interface VRFrameData {
  139469. readonly leftProjectionMatrix: Float32Array;
  139470. readonly leftViewMatrix: Float32Array;
  139471. readonly pose: VRPose;
  139472. readonly rightProjectionMatrix: Float32Array;
  139473. readonly rightViewMatrix: Float32Array;
  139474. readonly timestamp: number;
  139475. }
  139476. interface VRPose {
  139477. readonly angularAcceleration: Float32Array | null;
  139478. readonly angularVelocity: Float32Array | null;
  139479. readonly linearAcceleration: Float32Array | null;
  139480. readonly linearVelocity: Float32Array | null;
  139481. readonly orientation: Float32Array | null;
  139482. readonly position: Float32Array | null;
  139483. readonly timestamp: number;
  139484. }
  139485. interface VRStageParameters {
  139486. sittingToStandingTransform?: Float32Array;
  139487. sizeX?: number;
  139488. sizeY?: number;
  139489. }
  139490. interface Navigator {
  139491. getVRDisplays(): Promise<VRDisplay[]>;
  139492. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  139493. }
  139494. interface Window {
  139495. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  139496. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  139497. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  139498. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  139499. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  139500. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  139501. }
  139502. interface Gamepad {
  139503. readonly displayId: number;
  139504. }
  139505. type XRSessionMode =
  139506. | "inline"
  139507. | "immersive-vr"
  139508. | "immersive-ar";
  139509. type XRReferenceSpaceType =
  139510. | "viewer"
  139511. | "local"
  139512. | "local-floor"
  139513. | "bounded-floor"
  139514. | "unbounded";
  139515. type XREnvironmentBlendMode =
  139516. | "opaque"
  139517. | "additive"
  139518. | "alpha-blend";
  139519. type XRVisibilityState =
  139520. | "visible"
  139521. | "visible-blurred"
  139522. | "hidden";
  139523. type XRHandedness =
  139524. | "none"
  139525. | "left"
  139526. | "right";
  139527. type XRTargetRayMode =
  139528. | "gaze"
  139529. | "tracked-pointer"
  139530. | "screen";
  139531. type XREye =
  139532. | "none"
  139533. | "left"
  139534. | "right";
  139535. interface XRSpace extends EventTarget {
  139536. }
  139537. interface XRRenderState {
  139538. depthNear?: number;
  139539. depthFar?: number;
  139540. inlineVerticalFieldOfView?: number;
  139541. baseLayer?: XRWebGLLayer;
  139542. }
  139543. interface XRInputSource {
  139544. handedness: XRHandedness;
  139545. targetRayMode: XRTargetRayMode;
  139546. targetRaySpace: XRSpace;
  139547. gripSpace: XRSpace | undefined;
  139548. gamepad: Gamepad | undefined;
  139549. profiles: Array<string>;
  139550. }
  139551. interface XRSession extends XRAnchorCreator {
  139552. addEventListener: Function;
  139553. removeEventListener: Function;
  139554. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  139555. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  139556. requestAnimationFrame: Function;
  139557. end(): Promise<void>;
  139558. renderState: XRRenderState;
  139559. inputSources: Array<XRInputSource>;
  139560. // AR hit test
  139561. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  139562. updateWorldTrackingState(options: {
  139563. planeDetectionState?: { enabled: boolean; }
  139564. }): void;
  139565. }
  139566. interface XRReferenceSpace extends XRSpace {
  139567. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  139568. onreset: any;
  139569. }
  139570. type XRPlaneSet = Set<XRPlane>;
  139571. type XRAnchorSet = Set<XRAnchor>;
  139572. interface XRFrame {
  139573. session: XRSession;
  139574. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  139575. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  139576. // Anchors
  139577. trackedAnchors?: XRAnchorSet;
  139578. // Planes
  139579. worldInformation: {
  139580. detectedPlanes?: XRPlaneSet;
  139581. };
  139582. }
  139583. interface XRViewerPose extends XRPose {
  139584. views: Array<XRView>;
  139585. }
  139586. interface XRPose {
  139587. transform: XRRigidTransform;
  139588. emulatedPosition: boolean;
  139589. }
  139590. interface XRWebGLLayerOptions {
  139591. antialias?: boolean;
  139592. depth?: boolean;
  139593. stencil?: boolean;
  139594. alpha?: boolean;
  139595. multiview?: boolean;
  139596. framebufferScaleFactor?: number;
  139597. }
  139598. declare var XRWebGLLayer: {
  139599. prototype: XRWebGLLayer;
  139600. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  139601. };
  139602. interface XRWebGLLayer {
  139603. framebuffer: WebGLFramebuffer;
  139604. framebufferWidth: number;
  139605. framebufferHeight: number;
  139606. getViewport: Function;
  139607. }
  139608. declare class XRRigidTransform {
  139609. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  139610. position: DOMPointReadOnly;
  139611. orientation: DOMPointReadOnly;
  139612. matrix: Float32Array;
  139613. inverse: XRRigidTransform;
  139614. }
  139615. interface XRView {
  139616. eye: XREye;
  139617. projectionMatrix: Float32Array;
  139618. transform: XRRigidTransform;
  139619. }
  139620. interface XRInputSourceChangeEvent {
  139621. session: XRSession;
  139622. removed: Array<XRInputSource>;
  139623. added: Array<XRInputSource>;
  139624. }
  139625. interface XRInputSourceEvent extends Event {
  139626. readonly frame: XRFrame;
  139627. readonly inputSource: XRInputSource;
  139628. }
  139629. // Experimental(er) features
  139630. declare class XRRay {
  139631. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  139632. origin: DOMPointReadOnly;
  139633. direction: DOMPointReadOnly;
  139634. matrix: Float32Array;
  139635. }
  139636. interface XRHitResult {
  139637. hitMatrix: Float32Array;
  139638. }
  139639. interface XRAnchor {
  139640. // remove?
  139641. id?: string;
  139642. anchorSpace: XRSpace;
  139643. lastChangedTime: number;
  139644. detach(): void;
  139645. }
  139646. interface XRPlane extends XRAnchorCreator {
  139647. orientation: "Horizontal" | "Vertical";
  139648. planeSpace: XRSpace;
  139649. polygon: Array<DOMPointReadOnly>;
  139650. lastChangedTime: number;
  139651. }
  139652. interface XRAnchorCreator {
  139653. // AR Anchors
  139654. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  139655. }